From: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Use JOIN USING aliases in ruleutils.c |
Date: | 2021-12-20 11:30:02 |
Message-ID: | eb0a2639-af2b-449d-94a7-16728091c8ac@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
When reverse-compiling a query, ruleutils.c has some complicated code to
handle the join output columns of a JOIN USING join. There used to be
no way to qualify those columns, and so if there was a naming conflict
anywhere in the query, those output columns had to be renamed to be
unique throughout the query.
Since PostgreSQL 14, we have a new feature that allows adding an alias
to a JOIN USING clause. This provides a better solution to this
problem. This patch changes the logic in ruleutils.c so that if naming
conflicts with JOIN USING output columns are found in the query, these
JOIN USING aliases with generated names are attached everywhere and the
columns are then qualified everywhere.
I made it so that new JOIN USING aliases are only created if needed in
the query, since we already have the logic of has_dangerous_join_using()
to compute when that is needed. We could probably do away with that too
and always use them, but I think that would be surprising and not what
people want.
The regression test changes illustrate the effects very well.
This is PoC-level right now. You will find blatant code duplication in
set_rtable_names(), and for now I have only commented out some code that
could be removed, not actually removed it.
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Use-JOIN-USING-aliases-in-ruleutils.c.patch | text/plain | 21.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Shinya Kato | 2021-12-20 12:05:23 | Re: Emit a warning if the extension's GUC is set incorrectly |
Previous Message | Michael Paquier | 2021-12-20 11:21:51 | Re: pg_upgrade should truncate/remove its logs before running |