Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC
Dave Cramer <davecramer@postgres.rocks>
From: Dave Cramer <davecramer@postgres.rocks>
To: ZhangChi <798604270@qq.com>
Cc: Greg Sabino Mullane <htamfids@gmail.com>,
"David G. Johnston" <david.g.johnston@gmail.com>, "pgsql-bugs@lists.postgresql.org" <pgsql-bugs@lists.postgresql.org>
Date: 2025-12-17T12:55:25Z
Lists: 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
>
>