Doc: clarify description of degenerate NATURAL joins.
authorTom Lane
Thu, 20 Jul 2017 16:41:26 +0000 (12:41 -0400)
committerTom Lane
Thu, 20 Jul 2017 16:41:45 +0000 (12:41 -0400)
Claiming that NATURAL JOIN is equivalent to CROSS JOIN when there are
no common column names is only strictly correct if it's an inner join;
you can't say e.g. CROSS LEFT JOIN.  Better to explain it as meaning
JOIN ON TRUE, instead.  Per a suggestion from David Johnston.

Discussion: https://postgr.es/m/CAKFQuwb+mYszQhDS9f_dqRrk1=Pe-S6D=XMkAXcDf4ykKPmgKQ@mail.gmail.com

doc/src/sgml/queries.sgml
doc/src/sgml/ref/select.sgml

index 1010f0508bc04ed149a6a384d8a2babd82bda5ff..81ccbe6399cb7e2b07bf022fd4a908d6b7a8b352 100644 (file)
@@ -393,8 +393,8 @@ FROM table_reference table_r
         consisting of all column names that appear in both
         input tables.  As with USING, these columns appear
         only once in the output table.  If there are no common
-        column names, NATURAL behaves like
-        CROSS JOIN.
+        column names, NATURAL JOIN behaves like
+        JOIN ... ON TRUE, producing a cross-product join.
        
 
        
index b1727b9807ab8518f9745a71cdd38d8b17c89096..f740a128b164f6deb5d9723efbbafc34e4cd5df8 100644 (file)
@@ -494,9 +494,12 @@ TABLE [ ONLY ] table_name [ * ]
      
       NATURAL
       
-       NATURAL is shorthand for a
+       
+        NATURAL is shorthand for a
         USING list that mentions all columns in the two
-        tables that have the same names.
+        tables that have matching names.  If there are no common
+        column names, NATURAL is equivalent
+        to ON TRUE.