Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5512427

Browse files
committed
Doc: clarify description of degenerate NATURAL joins.
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
1 parent 41ada83 commit 5512427

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

doc/src/sgml/queries.sgml

+2-2
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
393393
consisting of all column names that appear in both
394394
input tables. As with <literal>USING</>, these columns appear
395395
only once in the output table. If there are no common
396-
column names, <literal>NATURAL</literal> behaves like
397-
<literal>CROSS JOIN</literal>.
396+
column names, <literal>NATURAL JOIN</literal> behaves like
397+
<literal>JOIN ... ON TRUE</literal>, producing a cross-product join.
398398
</para>
399399

400400
<note>

doc/src/sgml/ref/select.sgml

+5-2
Original file line numberDiff line numberDiff line change
@@ -603,9 +603,12 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ]
603603
<varlistentry>
604604
<term><literal>NATURAL</literal></term>
605605
<listitem>
606-
<para><literal>NATURAL</literal> is shorthand for a
606+
<para>
607+
<literal>NATURAL</literal> is shorthand for a
607608
<literal>USING</> list that mentions all columns in the two
608-
tables that have the same names.
609+
tables that have matching names. If there are no common
610+
column names, <literal>NATURAL</literal> is equivalent
611+
to <literal>ON TRUE</>.
609612
</para>
610613
</listitem>
611614
</varlistentry>

0 commit comments

Comments
 (0)