Re: [GENERAL] CASE Statement - Order of expression processing

2013-06-28 Thread Albe Laurenz
>> 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. >> Acc

Re: [GENERAL] CASE Statement - Order of expression processing

2013-06-18 Thread Albe Laurenz
Andrea Lombardoni wrote: > It gets even stranger: > > template1=# SELECT CASE WHEN (SELECT 0)=0 THEN 0 ELSE 1/(select 0) END; > case > -- > 0 > (1 row) > > Here it seems that the ELSE does not get evaluated (which is correct). Yes, of course, because both subselects will not get evaluat

Re: [GENERAL] CASE Statement - Order of expression processing

2013-06-18 Thread Andrea Lombardoni
On Mon, Jun 17, 2013 at 11:11 PM, Stefan Drees wrote: > > pg924=# SELECT CASE WHEN 1 != 1 THEN 1/0 ELSE ((SELECT 1)=1)::integer END; > case > -- > 1 > (1 row) > > here the 1/0 is happily ignored. > It gets even stranger: template1=# SELECT CASE WHEN (SELECT 0)=0 THEN 0 ELSE 1/(select

Re: [GENERAL] CASE Statement - Order of expression processing

2013-06-18 Thread Albe Laurenz
Stefan Drees wrote: > On 2013-06-17 22:17 +02:00, Andrea Lombardoni wrote: >> I observed the following behaviour (I tested the following statements in >> 9.0.4, 9.0.5 and 9.3beta1): >> >> $ psql template1 >> template1=# SELECT CASE WHEN 0=0 THEN 0 ELSE 1/0 END; >> case >> -- >> 0 >> (1

Re: [GENERAL] CASE Statement - Order of expression processing

2013-06-17 Thread Stefan Drees
On 2013-06-17 22:17 +02:00, Andrea Lombardoni wrote: I observed the following behaviour (I tested the following statements in 9.0.4, 9.0.5 and 9.3beta1): $ psql template1 template1=# SELECT CASE WHEN 0=0 THEN 0 ELSE 1/0 END; case -- 0 (1 row) template1=# SELECT CASE WHEN 1=0 THEN 0 E

[GENERAL] CASE Statement - Order of expression processing

2013-06-17 Thread Andrea Lombardoni
I observed the following behaviour (I tested the following statements in 9.0.4, 9.0.5 and 9.3beta1): $ psql template1 template1=# SELECT CASE WHEN 0=0 THEN 0 ELSE 1/0 END; case -- 0 (1 row) template1=# SELECT CASE WHEN 1=0 THEN 0 ELSE 1/0 END; ERROR: division by zero In this case the C