Skip to content

Commit 22d0c30

Browse files
committed
Doc: improve description of IN and row-constructor comparisons.
IN and NOT IN work fine on records and arrays, so just say that they accept "expressions" not "scalar expressions". I think that that phrasing was meant to say that they don't work on set-returning expressions, but that's not the common meaning of "scalar". Revise the description of row-constructor comparisons to make it perhaps a bit less confusing. (This partially reverts some dubious wording changes made by commit f566515.) Per gripe from Ilya Nenashev. Back-patch to supported branches. In HEAD and v16, also drop a NOTE about pre-8.2 behavior, which is hopefully no longer of interest to anybody. Discussion: https://postgr.es/m/168968062460.632.14303906825812821399@wrigleys.postgresql.org
1 parent 04911fa commit 22d0c30

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

doc/src/sgml/func.sgml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16858,7 +16858,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2);
1685816858

1685916859
<para>
1686016860
The right-hand side is a parenthesized list
16861-
of scalar expressions. The result is <quote>true</quote> if the left-hand expression's
16861+
of expressions. The result is <quote>true</quote> if the left-hand expression's
1686216862
result is equal to any of the right-hand expressions. This is a shorthand
1686316863
notation for
1686416864

@@ -16889,7 +16889,7 @@ OR
1688916889

1689016890
<para>
1689116891
The right-hand side is a parenthesized list
16892-
of scalar expressions. The result is <quote>true</quote> if the left-hand expression's
16892+
of expressions. The result is <quote>true</quote> if the left-hand expression's
1689316893
result is unequal to all of the right-hand expressions. This is a shorthand
1689416894
notation for
1689516895

@@ -17000,26 +17000,24 @@ AND
1700017000
<para>
1700117001
Each side is a row constructor,
1700217002
as described in <xref linkend="sql-syntax-row-constructors"/>.
17003-
The two row values must have the same number of fields.
17004-
Each side is evaluated and they are compared row-wise. Row constructor
17005-
comparisons are allowed when the <replaceable>operator</replaceable> is
17003+
The two row constructors must have the same number of fields.
17004+
The given <replaceable>operator</replaceable> is applied to each pair
17005+
of corresponding fields. (Since the fields could be of different
17006+
types, this means that a different specific operator could be selected
17007+
for each pair.)
17008+
All the selected operators must be members of some B-tree operator
17009+
class, or be the negator of an <literal>=</literal> member of a B-tree
17010+
operator class, meaning that row constructor comparison is only
17011+
possible when the <replaceable>operator</replaceable> is
1700617012
<literal>=</literal>,
1700717013
<literal>&lt;&gt;</literal>,
1700817014
<literal>&lt;</literal>,
1700917015
<literal>&lt;=</literal>,
17010-
<literal>&gt;</literal> or
17011-
<literal>&gt;=</literal>.
17012-
Every row element must be of a type which has a default B-tree operator
17013-
class or the attempted comparison may generate an error.
17016+
<literal>&gt;</literal>, or
17017+
<literal>&gt;=</literal>,
17018+
or has semantics similar to one of these.
1701417019
</para>
1701517020

17016-
<note>
17017-
<para>
17018-
Errors related to the number or types of elements might not occur if
17019-
the comparison is resolved using earlier columns.
17020-
</para>
17021-
</note>
17022-
1702317021
<para>
1702417022
The <literal>=</literal> and <literal>&lt;&gt;</literal> cases work slightly differently
1702517023
from the others. Two rows are considered

0 commit comments

Comments
 (0)