Postgres behavior - Conditional statements

From: Kumar Babu P G <kumar(dot)pulakunta(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Postgres behavior - Conditional statements
Date: 2014-02-24 06:37:24
Message-ID: CAA5_7crQLLN=Wr7gp4ykhmTZxrbtSfXjucQeoi2uyec79N1Z7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

HI All,

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 9.1

postgres=> create table test (a int, b int);

CREATE TABLE

postgres=> insert into test values (1,1);

INSERT 0 1

postgres=> select case when exists (select 1 from test where a=1) then 0
else (select b from test where a=2) end;

* case *

*------*

0

(1 row)

Postgres 9.2

postgres=> select case when exists (select 1 from test where a=1) then 0
else (select b from test where a=2) end;

* b *

*---*

0

(1 row)

Regards,

Kumar.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message amul sul 2014-02-24 06:47:28 SRF_RETURN_NEXT Error: rows returned by function are not all of the same row type
Previous Message Pavel Stehule 2014-02-20 04:17:05 Re: How to unnest an array with element indexes