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

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC
Дата
Msg-id CAKAnmmJ=SfR-C3f9Y6Soi=g-QPRqaxzY5pbUa3QMZsStHMJP6A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #19350: Short circuit optimization missed when running sqlscriptes in JDBC  ("ZhangChi" <798604270@qq.com>)
Ответы Re: BUG #19350: Short circuit optimization missed when runningsqlscriptes in JDBC
Список 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 по дате отправления: