>> But in the following expression: >> >> template1=# SELECT CASE WHEN (SELECT 0)=0 THEN 0 ELSE 1/0 END; >> ERROR: division by zero >> >> (Just to be sure, a "SELECT (SELECT 0)=0;" returns true) >> >> It seems that when the "CASE WHEN expression" is a query, the evaluation >> order changes. >> According to the documentation, this behaviour is wrong. Just to keep you updated: We have updated the documentation to alert people to this behaviour: http://www.postgresql.org/docs/devel/static/functions-conditional.html#FUNCTIONS-CASE There were considerations to change the behaviour, but that would mean that query execution time suffers in many cases. It was decided that the problem occurs only in rather artificial queries, and that it would not be worth changing the normally useful behaviour of constant folding during query planning. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general