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: | 2022-02-07 08:06:54 |
Message-ID: | 3df848ce-f0cc-3211-2df5-abe19c11a8e9@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.
The test output changes show the effects nicely.
Obviously, the copy-and-paste code in set_rtable_names() could be
refactored a bit better, perhaps. I also just named the generated
aliases "ju" with numbers added, maybe there are other ideas for how to
generate these names.
Attachment | Content-Type | Size |
---|---|---|
0001-Use-JOIN-USING-aliases-in-ruleutils.c.patch | text/plain | 21.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Sharma | 2022-02-07 08:08:38 | Re: Synchronizing slots from primary to standby |
Previous Message | Dilip Kumar | 2022-02-07 07:57:13 | Re: [BUG]Update Toast data failure in logical replication |