On Thu, Feb 23, 2017 at 7:50 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Maybe the best answer is to not do it immediately when transforming the
> subselect's RTE, but to go back after we've finished transforming the
> entire FROM clause and add aliases to any RTEs that lack them. I think
> probably at that point you could just examine the RTE list and not worry
> about any jointree data structures at all. It might be worth adding a
> flag to ParseState to remember whether any aliases require assignment, so
> that you could skip looking in the standard case.
Right, something along these lines makes sense to me. If we try to
generate an alias before we know what all the things that it might
later conflict with are, then somebody will always be able to write a
query where it breaks.
>> I've no idea for this yet and Tom already was concerned what this might
>> break. There are several places in the transform phase where the
>> refnames are required (e.g. isLockedRefname()).
>
> Yeah. This would be cleaner in some sense but also a lot more delicate.
> Not sure it's worth the trouble.
It sounds like a lot of trouble. It does also sound nicer. I suppose
whether it's worth the trouble is for the person doing the work to
decide.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company