unintuitive subquery record wrapping

From: Rikard Pavelic <rikard(dot)pavelic(at)zg(dot)htnet(dot)hr>
To: pgsql-general(at)postgresql(dot)org
Subject: unintuitive subquery record wrapping
Date: 2010-09-18 01:59:23
Message-ID: 4C941CFB.5090401@zg.htnet.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm puzzled if this is by design or just overlooked...

create table t(a int, b varchar);

insert into t values(1,'x');

For basic query:
select t from t
result is of type t.

If I query:
select sq from (select t from t) sq;
result is of type record.

I need to query like this:
select (sq).t from (select t from t) sq;
or like this:
select t from (select t from t) t;
to get result of type t.

Wrapping t to record if another alias is used seems a bit unintuitive to me?
Is this by design and if yes, why?

Regards,
Rikard

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-09-18 02:31:19 Re: unintuitive subquery record wrapping
Previous Message Thom Brown 2010-09-18 01:50:40 Re: Referring to function parameter in function