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

From: ZhangChi <798604270(at)qq(dot)com>
To: David G(dot) Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC
Date: 2025-12-10 14:01:22
Message-ID: tencent_95746975D7E33A69DE8B0CD8642AAE343405@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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(dot)g(dot)johnston(at)gmail(dot)com&gt;
Date: 2025-12-10 21:46
To: ZhangChi <798604270(at)qq(dot)com&gt;
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org&gt;
Subject: Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC

On Wednesday, December 10, 2025, ZhangChi <798604270(at)qq(dot)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;

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-12-10 14:51:20 BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem.
Previous Message David G. Johnston 2025-12-10 13:46:51 Re: BUG #19350: Short circuit optimization missed when running sql scriptes in JDBC