From: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "stefan(at)drees(dot)name" <stefan(at)drees(dot)name>, "andrea(at)lombardoni(dot)ch" <andrea(at)lombardoni(dot)ch> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: CASE Statement - Order of expression processing |
Date: | 2013-06-28 07:01:15 |
Message-ID: | A737B7A37273E048B164557ADEF4A58B17BC1412@ntex2010a.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Alban Hertroys | 2013-06-28 07:09:32 | Re: utf8 errors |
Previous Message | Alban Hertroys | 2013-06-28 06:39:02 | Re: utf8 errors |