Re: Alias of VALUES RTE in explain plan - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Alias of VALUES RTE in explain plan
Date
Msg-id CA+TgmoZE_+WcEkYUdhSuVzV1M=kV7kEbBHCkrHvQK04hQFcR3Q@mail.gmail.com
Whole thread Raw
In response to Re: Alias of VALUES RTE in explain plan  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Alias of VALUES RTE in explain plan
List pgsql-hackers
On Mon, Jan 6, 2025 at 3:45 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>         SELECT ... FROM (VALUES (...) ORDER BY a) v(a,b,c)
>
> If it'd been like that all along, nobody would blink at it I think,
> even though you could argue that it's action-at-a-distance to let
> an outer alias affect what happens inside the implicit subquery.

To be honest, that pushdown feels really uncomfortable to me. To me,
the natural syntax for associating an alias with a VALUES clause would
be something like "VALUES (...) myalias" or, if you also wanted column
aliasing, "VALUES (...) myalias(a,b,c)". That would feel just like
what we allow when aliasing a table or a function reference. But to
not allow that syntax but then allow the outer alias to propagate
inward in this one case seems quite strange to me. It doesn't really
seem evil in a vacuum, but it seems non-orthogonal with what we do
everywhere else, because aliases in SQL generally flow outward, not
inward.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: Log connection establishment timings
Next
From: Nathan Bossart
Date:
Subject: Re: Statistics Import and Export