Re: Allow an alias to be attached directly to a JOIN ... USING

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Allow an alias to be attached directly to a JOIN ... USING
Date: 2019-07-13 06:29:16
Message-ID: CA+hUKG+8FSn8d9j2rM2OLF0v0Vx0qPTT=STJrfV2xbpbTY4P4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 18, 2019 at 2:41 AM Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2019-07-13 06:31:58 Re: [PATCH] Implement uuid_version()
Previous Message Fabien COELHO 2019-07-13 06:08:35 Re: [PATCH] Implement uuid_version()