From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Rikard Pavelic <rikard(dot)pavelic(at)zg(dot)htnet(dot)hr> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: unintuitive subquery record wrapping |
Date: | 2010-09-18 15:50:23 |
Message-ID: | 12802.1284825023@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Rikard Pavelic <rikard(dot)pavelic(at)zg(dot)htnet(dot)hr> writes:
> I'm arguing that is seems wrong that I need to match alias name like this
> select t from (select t from t) t
> or like this
> select sq from (select sq from t sq) sq
> to get unwrapped type.
This reminds me of the old joke ...
Patient: Doctor, it hurts when I do this.
Doctor: So don't do that!
When you write a query like that, there are two ways to resolve the
reference: it could be naming the (single) output column of the
subquery, or it could be naming the entire record result of the
subquery. PG tries those alternatives in that order. If you don't
like that, maybe you shouldn't use conflicting alias names.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Bret Green | 2010-09-19 01:43:49 | how to insert multiple rows and get the ids back in a temp table (pgplsql)? |
Previous Message | Arjen Nienhuis | 2010-09-18 13:22:41 | Re: unintuitive subquery record wrapping |