Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Friday, June 20, 2025, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:
Bug reference: 18965
Logged by: Todd Brandys
Email address: brandystodd@gmail.com
PostgreSQL version: 17.5
Operating system: Linux
Description:
In the circumstance where a function evaluation is performed within Boolean
expression, the evaluation seems to continue past a function returning a
TRUE value.
Where did we claim we perform short-circuiting?
David J.
Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
От:
Jeff Davis <pgsql@j-davis.com>
Дата:
On Fri, 2025-06-20 at 11:14 -0700, David G. Johnston wrote: > > In the circumstance where a function evaluation is performed within > > Boolean > > expression, the evaluation seems to continue past a function > > returning a > > TRUE value. > > > > Where did we claim we perform short-circuiting? Even if you force the execution-time evaluation order with CASE, you can still get an error: EXPLAIN SELECT CASE WHEN random() < 2 THEN TRUE ELSE (1/0 = 0) END; ERROR: division by zero The expression "random() < 2" is always true, so at execution time the second branch will never be reached. But it is reached at planning time. Regards, Jeff Davis