Re: Join Correlation Name

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>
Cc: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Join Correlation Name
Date: 2019-10-29 14:20:27
Message-ID: 12416.1572358827@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com> writes:
> On 29/10/2019 12:24, Isaac Morland wrote:
>> If you need to refer specifically to the non-qualified version in a
>> different part of the query, you can give an alias to the result of
>> the join:
>> ... (a join b using (z)) as t ...

> Yes, this is about having standard SQL syntax for that.

Please present an argument why this proposal is standard SQL syntax.
I see no support for it in the spec. AFAICS this proposal is just an
inconsistent wart; it makes it possible to write

(a join b using (z) as q) as t

and then what do you do? Moreover, why should you be able to
attach an alias to a USING join but not other sorts of joins?

After digging around in the spec for awhile, it seems like
there actually isn't any way to attach an alias to a join
per spec.

According to SQL:2011 7.6 <table reference>, you can attach an
AS clause to every variant of <table primary> *except* the
<parenthesized joined table> variant. And there's nothing
about AS clauses in 7.7 <joined table>, which is where it would
have to be mentioned if this proposal were spec-compliant.

What our grammar effectively does is to allow an AS clause to be
attached to <parenthesized joined table> as well, which seems
like the most natural thing to do if the committee ever decide
to rectify the shortcoming.

Anyway, we already have the functionality covered, and I don't
think we need another non-spec, non-orthogonal way to do it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shay Rojansky 2019-10-29 14:27:11 Re: strpos behavior change around empty substring in PG12
Previous Message Heikki Linnakangas 2019-10-29 14:11:13 Re: strpos behavior change around empty substring in PG12