Rikard Pavelic <rikard.pavelic@zg.htnet.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