Re: Allow an alias to be attached directly to a JOIN ... USING
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-07-13T06:29:16Z
Lists: pgsql-hackers
On Tue, Jun 18, 2019 at 2:41 AM Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote: > A small new feature in SQL:2016 allows attaching a table alias to a > JOIN/USING construct: > > <named columns join> ::= > USING <left paren> <join column list> <right paren> > [ AS <join correlation name> ] > > (The part in brackets is new.) > > This seems quite useful, and it seems the code would already support > this if we allow the grammar to accept this syntax. Neat. That's a refreshingly short patch to get a sql_features.txt line bumped to YES. > Patch attached. It does what it says on the tin. I see that USING is the important thing here; for (a NATURAL JOIN b) AS ab or (a JOIN b ON ...) AS ab you still need the parentheses or (respectively) it means something different (alias for B only) or doesn't parse. That makes sense. I noticed that the HINT when you accidentally use a base table name instead of a table alias is more helpful than the HINT you get when you use a base table name instead of a join alias. That seems like a potential improvement that is independent of this syntax change. -- Thomas Munro https://enterprisedb.com
Commits
-
Allow an alias to be attached to a JOIN ... USING
- 055fee7eb4dc 14.0 landed
-
Add p_names field to ParseNamespaceItem
- 66392d396508 14.0 landed