diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-09-23 12:37:04 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-09-23 12:37:04 -0400 |
commit | 7cd99d39472e913c0849cfb5f75cd0173ab98735 (patch) | |
tree | 506f8a730856bad3b0ae8b934d2517c4a7e959cc /doc/src | |
parent | 8873c5b2017f87f8f7626782e67f5cd177cc4dff (diff) |
Doc: clarify handling of duplicate elements in array containment tests.
The array <@ and @> operators do not worry about duplicates: if every
member of array X matches some element of array Y, then X is contained
in 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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 5b1a2b4190c..1ef25bcbce2 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -12733,14 +12733,14 @@ SELECT NULLIF(value, '(none)') ... <row> <entry> <literal>@></literal> </entry> <entry>contains</entry> - <entry><literal>ARRAY[1,4,3] @> ARRAY[3,1]</literal></entry> + <entry><literal>ARRAY[1,4,3] @> ARRAY[3,1,3]</literal></entry> <entry><literal>t</literal></entry> </row> <row> <entry> <literal><@</literal> </entry> <entry>is contained by</entry> - <entry><literal>ARRAY[2,7] <@ ARRAY[1,7,4,2,6]</literal></entry> + <entry><literal>ARRAY[2,2,7] <@ ARRAY[1,7,4,2,6]</literal></entry> <entry><literal>t</literal></entry> </row> @@ -12783,8 +12783,10 @@ SELECT NULLIF(value, '(none)') ... </table> <para> - Array comparisons compare the array contents element-by-element, - using the default B-tree comparison function for the element data type. + The array ordering operators (<literal><</literal>, + <literal>>=</literal>, etc) compare the array contents + element-by-element, using the default B-tree comparison function for + the element data type, and sort based on the first difference. In multidimensional arrays the elements are visited in row-major order (last subscript varies most rapidly). If the contents of two arrays are equal but the dimensionality is @@ -12796,6 +12798,15 @@ SELECT NULLIF(value, '(none)') ... </para> <para> + The array containment operators (<literal><@</literal> + and <literal>@></literal>) consider one array to be contained in + another one if each of its elements appears in the other one. + Duplicates are not treated specially, thus <literal>ARRAY[1]</literal> + and <literal>ARRAY[1,1]</literal> are each considered to contain the + other. + </para> + + <para> See <xref linkend="arrays"/> for more details about array operator behavior. See <xref linkend="indexes-types"/> for more details about which operators support indexed operations. |