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

From ZhangChi
Subject Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC
Date
Msg-id tencent_6A625E6BCFAF916999E0C64185022D99ED0A@qq.com
Whole thread Raw
In response to Re: BUG #19350: Short circuit optimization missed when running sql scriptes in JDBC  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC
List pgsql-bugs
Hi David J.

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

Original

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

On Wednesday, December 10, 2025, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      19350
Logged by:          Chi Zhang
Email address:      798604270@qq.com
PostgreSQL version: 17.6
Operating system:   ubuntu 24.04 with docker
Description:       

Hi,

In the following test case, if I run it in JDBC, the prepared statement will
trigger a divide by zero error. But if run it in command line, there will
not be the same error.


This isn’t a bug in PostgreSQL, it’s a bug in the query you’ve written.  The expectation of short-circuiting is flawed - the non-failure outcome is not something than can be relied upon.

David J.


pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #19350: Short circuit optimization missed when running sql scriptes in JDBC
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #19350: Short circuit optimization missed when running sql scriptes in JDBC