Re: Postgres behavior - Conditional statements - Mailing list pgsql-sql

From Tom Lane
Subject Re: Postgres behavior - Conditional statements
Date
Msg-id 1905.1393257750@sss.pgh.pa.us
Whole thread Raw
In response to Postgres behavior - Conditional statements  (Kumar Babu P G <kumar.pulakunta@gmail.com>)
Responses Re: Postgres behavior - Conditional statements
List pgsql-sql
Kumar Babu P G <kumar.pulakunta@gmail.com> writes:
> Found strange behavior of postgres between 9.1 and 9.2. Can some one
> pointout the reason for the difference in column name of the output between
> the versions?
> postgres=> select case when exists (select 1 from test where a=1) then 0
> else (select b from test where a=2) end;

http://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=5ec6b7f1b87f0fa006b8e08a11cd4e99bcb67358

The behavior of CASE didn't change, but the behavior of the sub-select
did.  More simply, 9.1 gives this

regression=# select (select b from test where a=2);    ?column? 
----------        
(1 row)

while 9.2 and up give

regression=# select (select b from test where a=2);b 
--- 
(1 row)

        regards, tom lane



pgsql-sql by date:

Previous
From: Pena Kupen
Date:
Subject: Re: array in function
Next
From: David Johnston
Date:
Subject: Re: Postgres behavior - Conditional statements