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

From Greg Sabino Mullane
Subject Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC
Date
Msg-id CAKAnmmJ=SfR-C3f9Y6Soi=g-QPRqaxzY5pbUa3QMZsStHMJP6A@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC  ("ZhangChi" <798604270@qq.com>)
Responses Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC
List pgsql-bugs
I wonder why this query triggers an error under JDBC but not in the CLI.

Fails as expected from the command line:

prepare foo1 as select 99 / $1::int * $2;
PREPARE
execute foo1(0, null);
ERROR:  division by zero

prepare foo2 as select 99 / ($1::int * $2);
PREPARE
execute foo2(0, null);
 ?column?
----------
        ☃
(1 row)

prepare foo3 as select (99 / $1::int) * $2;
PREPARE
execute foo3(0, null);
ERROR:  division by zero

If you want the "null combined with anything = null" to always happen before the "divide by zero is wrong" make your query specific like in foo2 above.


Cheers,
Greg

--
Enterprise Postgres Software Products & Tech Support

pgsql-bugs by date:

Previous
From: Robert Haas
Date:
Subject: Re: BUG #19354: JOHAB rejects valid byte sequences
Next
From: Tom Lane
Date:
Subject: Re: BUG #19354: JOHAB rejects valid byte sequences