Skip to content

Commit a6088e1

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 e947838 commit a6088e1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

doc/src/sgml/queries.sgml

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,12 @@ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ]
494494
<varlistentry>
495495
<term><literal>NATURAL</literal></term>
496496
<listitem>
497-
<para><literal>NATURAL</literal> is shorthand for a
497+
<para>
498+
<literal>NATURAL</literal> is shorthand for a
498499
<literal>USING</> list that mentions all columns in the two
499-
tables that have the same names.
500+
tables that have matching names. If there are no common
501+
column names, <literal>NATURAL</literal> is equivalent
502+
to <literal>ON TRUE</>.
500503
</para>
501504
</listitem>
502505
</varlistentry>

0 commit comments

Comments
 (0)