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