Re: Fields re-ordered on JOIN with * and USING

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Fields re-ordered on JOIN with * and USING
Date: 2017-09-02 01:14:38
Message-ID: 6014.1504314878@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

... btw, a little digging shows that this ordering is required by the
SQL standard. The least excruciating version of the relevant text is
in SQL92 7.5 <joined table>:

d) Let SLCC be a <select list> of <derived column>s of the form

COALESCE ( TA.C, TB.C ) AS C

for every column C that is a corresponding join column, taken
in order of their ordinal positions in T1.

e) Let SL1 be a <select list> of those <column name>s of T1
that are not corresponding join columns, taken in order of
their ordinal positions in T1, and let SLT2 be a <select
list> of those <column name>s of T2 that are not correspond-
ing join columns, taken in order of their ordinal positions
in T2.

f) The descriptors of the columns of the result of the <joined
table> are the same as the descriptors of the columns of the
result of

SELECT SLCC, SLT1, SLT2 FROM TR1, TR2

Later versions of the standard use many more words to say the same thing.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ken Tanzer 2017-09-02 01:45:13 Re: Fields re-ordered on JOIN with * and USING
Previous Message Tom Lane 2017-09-02 01:04:30 Re: Fields re-ordered on JOIN with * and USING