Re: Postgres behavior - Conditional statements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kumar Babu P G <kumar(dot)pulakunta(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Postgres behavior - Conditional statements
Date: 2014-02-24 16:02:30
Message-ID: 1905.1393257750@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Kumar Babu P G <kumar(dot)pulakunta(at)gmail(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2014-02-24 16:47:59 Re: Postgres behavior - Conditional statements
Previous Message Pena Kupen 2014-02-24 10:05:41 Re: array in function