Search Postgresql Archives

Re: CASE Statement - Order of expression processing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux