Use JOIN USING aliases in ruleutils.c - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Use JOIN USING aliases in ruleutils.c
Date
Msg-id 3df848ce-f0cc-3211-2df5-abe19c11a8e9@enterprisedb.com
Whole thread Raw
Responses Re: Use JOIN USING aliases in ruleutils.c  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: [BUG]Update Toast data failure in logical replication
Next
From: Ashutosh Sharma
Date:
Subject: Re: Synchronizing slots from primary to standby