Re: [GENERAL] Fields re-ordered on JOIN with * and USING - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] Fields re-ordered on JOIN with * and USING
Date
Msg-id 6014.1504314878@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] Fields re-ordered on JOIN with * and USING  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: [GENERAL] Fields re-ordered on JOIN with * and USING  (Ken Tanzer <ken.tanzer@gmail.com>)
List 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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Fields re-ordered on JOIN with * and USING
Next
From: Ken Tanzer
Date:
Subject: Re: [GENERAL] Fields re-ordered on JOIN with * and USING