Re: CASE Statement - Order of expression processing

From: Andrea Lombardoni <andrea(at)lombardoni(dot)ch>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CASE Statement - Order of expression processing
Date: 2013-06-18 07:31:25
Message-ID: CAMQ5dGop18aC2PiUNSEBrors54rty6M4C_L405fPvZKQA8+08w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jun 17, 2013 at 11:11 PM, Stefan Drees <stefan(at)drees(dot)name> 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 0) END;
case
------
0
(1 row)

Here it seems that the ELSE does not get evaluated (which is correct).

Bye

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2013-06-18 07:37:52 Re: JDBC prepared statement is not treated as prepared statement
Previous Message Albe Laurenz 2013-06-18 07:22:41 Re: CASE Statement - Order of expression processing