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

Commit ed3dc22

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 eb145fd commit ed3dc22

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
@@ -391,8 +391,8 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
391391
consisting of all column names that appear in both
392392
input tables. As with <literal>USING</>, these columns appear
393393
only once in the output table. If there are no common
394-
column names, <literal>NATURAL</literal> behaves like
395-
<literal>CROSS JOIN</literal>.
394+
column names, <literal>NATURAL JOIN</literal> behaves like
395+
<literal>JOIN ... ON TRUE</literal>, producing a cross-product join.
396396
</para>
397397

398398
<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)