Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC - Mailing list pgsql-bugs

From Dave Cramer
Subject Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC
Date
Msg-id CADK3HH+EK4qM74YVGobr+oWcpe-EFoKGtQDDtt+Yd87nsVeHsQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC  ("ZhangChi" <798604270@qq.com>)
Responses Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC
Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC
List pgsql-bugs



On Tue, 16 Dec 2025 at 20:40, ZhangChi <798604270@qq.com> wrote:
Hi Greg,

Thanks for your reply. I can understand what you describe.

But my question is that in the CLI, the test case (like foo2) I showed can return the results. But when I run the same test case in JDBC, the test case triggers an error. I wonder why there is an inconsistency.

```
SET plan_cache_mode = force_generic_plan;
CREATE TABLE t0(c0 int4range);
INSERT INTO t0(c0) VALUES('[-1920846305,-1018839689)'::int4range);
PREPARE prepare_query (int8, int8) AS SELECT
((((((upper(t0.c0))))/($1)))*(($2::int8))) FROM ONLY t0;
EXECUTE prepare_query(0, NULL); -- trigger error in JDBC but no error in CLI
```


Possibly because JDBC does everything using the V3 protocol whereas psql does not. psql uses simple query.

Dave Cramer
www.postgres.rocks

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19358: Short circuit optimization exists in generic plan but missed in custom plan
Next
From: Greg Sabino Mullane
Date:
Subject: Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC