Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13cd97e

Browse files
committed
Doc: clarify handling of duplicate elements in array containment tests.
The array <@ and @> operators do not worry about duplicates: if everymember of array X matches some element of array Y, then X is containedin Y, even if several members of X get matched to the same Y member.This was not explicitly stated in the docs though, so improve matters.Discussion:https://postgr.es/m/156614120484.1310.310161642239149585@wrigleys.postgresql.org
1 parent887248e commit13cd97e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14058,14 +14058,14 @@ SELECT NULLIF(value, '(none)') ...
1405814058
<row>
1405914059
<entry> <literal>@&gt;</literal> </entry>
1406014060
<entry>contains</entry>
14061-
<entry><literal>ARRAY[1,4,3] @&gt; ARRAY[3,1]</literal></entry>
14061+
<entry><literal>ARRAY[1,4,3] @&gt; ARRAY[3,1,3]</literal></entry>
1406214062
<entry><literal>t</literal></entry>
1406314063
</row>
1406414064

1406514065
<row>
1406614066
<entry> <literal>&lt;@</literal> </entry>
1406714067
<entry>is contained by</entry>
14068-
<entry><literal>ARRAY[2,7] &lt;@ ARRAY[1,7,4,2,6]</literal></entry>
14068+
<entry><literal>ARRAY[2,2,7] &lt;@ ARRAY[1,7,4,2,6]</literal></entry>
1406914069
<entry><literal>t</literal></entry>
1407014070
</row>
1407114071

@@ -14108,8 +14108,10 @@ SELECT NULLIF(value, '(none)') ...
1410814108
</table>
1410914109

1411014110
<para>
14111-
Array comparisons compare the array contents element-by-element,
14112-
using the default B-tree comparison function for the element data type.
14111+
The array ordering operators (<literal>&lt;</literal>,
14112+
<literal>&gt;=</literal>, etc) compare the array contents
14113+
element-by-element, using the default B-tree comparison function for
14114+
the element data type, and sort based on the first difference.
1411314115
In multidimensional arrays the elements are visited in row-major order
1411414116
(last subscript varies most rapidly).
1411514117
If the contents of two arrays are equal but the dimensionality is
@@ -14120,6 +14122,15 @@ SELECT NULLIF(value, '(none)') ...
1412014122
number of dimensions or subscript ranges were different.)
1412114123
</para>
1412214124

14125+
<para>
14126+
The array containment operators (<literal>&lt;@</literal>
14127+
and <literal>@&gt;</literal>) consider one array to be contained in
14128+
another one if each of its elements appears in the other one.
14129+
Duplicates are not treated specially, thus <literal>ARRAY[1]</literal>
14130+
and <literal>ARRAY[1,1]</literal> are each considered to contain the
14131+
other.
14132+
</para>
14133+
1412314134
<para>
1412414135
See <xref linkend="arrays"/> for more details about array operator
1412514136
behavior. See <xref linkend="indexes-types"/> for more details about
@@ -18277,7 +18288,7 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
1827718288
<row>
1827818289
<entry> <literal>@&gt;</literal> </entry>
1827918290
<entry>contains element</entry>
18280-
<entry><literal>'{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] @> 'calvin=r*w/hobbes'::aclitem</literal></entry>
18291+
<entry><literal>'{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] @&gt; 'calvin=r*w/hobbes'::aclitem</literal></entry>
1828118292
<entry><literal>t</literal></entry>
1828218293
</row>
1828318294

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp