Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC

ZhangChi <798604270@qq.com>

From: ZhangChi <798604270@qq.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Date: 2025-12-10T14:01:22Z
Lists: pgsql-bugs
Hi David J.


Yes! You are right. I mean, when I run this test case with the wrapper I provide, which executes each SQL statement with JDBC (but without the prepare API of JDBC), then the test case will trigger the error. But if I run it in CLI, for example `psql -U root -W root -p 5433 -h 127.0.0.1 < test.sql`, then there is no error. I do not modify the test caes. But it has different behaviours. I wonder the reason for this discrepancy.




         Original
         
       
From: David G. Johnston <david.g.johnston@gmail.com&gt;
Date: 2025-12-10 21:46
To: ZhangChi <798604270@qq.com&gt;
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org&gt;
Subject: Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC





On Wednesday, December 10, 2025, ZhangChi <798604270@qq.com&gt; wrote:
Hi David J.


Thanks for your reply. I wonder why this query triggers an error under JDBC but not in the CLI.


Because the planner can simplify the expression if it sees a constant null value but cannot when everything is injected via parameter.


David J.&nbsp;