From: Laurenz Albe <laurenz.albe@cybertec.at>
To: tbogusiak@gmail.com
To: pgsql-docs@lists.postgresql.org
Subject: Re: Duplicates being removed from intarray on subtraction of another intarray
Date: Mon, 18 Mar 2024 17:01:32 +0100
Message-ID: <396e990fa8ae32bf5c1e3bf2473778e6e296fbfe.camel@cybertec.at> (raw)
In-Reply-To: <171075007381.7104.7931589808177869854@wrigleys.postgresql.org>
References: <171075007381.7104.7931589808177869854@wrigleys.postgresql.org>
On Mon, 2024-03-18 at 08:21 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/16/intarray.html
>
> Hi,
> I recently ran into an unusual issue with the intarray extension where if
> you subtract one array from another the result is *also* sorted and
> de-duplicated. The documentation does not seem to imply that this should be
> the case, stating only that the operator "removes elements of the right
> array from the left array" and not that it also de-duplicates and sorts the
> result... It seems to only occur when subtracting an array. Is this the
> intended behavior?
>
> SELECT '{3,1,1,2,2,2}'::int[] - 1; --> {3,2,2,2} as you would expect
> SELECT '{3,1,1,2,2,2}'::int[] - '{1}'::int[]; --> {2,3} instead of
> {3,2,2,2}
There is no harm in documenting that; I propose the attached patch.
Yours,
Laurenz Albe
Attachments:
[text/x-patch] v1-0001-Documentation-fix-for-intarray-s-operator.patch (967B, ../396e990fa8ae32bf5c1e3bf2473778e6e296fbfe.camel@cybertec.at/2-v1-0001-Documentation-fix-for-intarray-s-operator.patch)
download | inline diff:
From 96a7fed7be768c047f8a74a4431716da0beb0e28 Mon Sep 17 00:00:00 2001
From: Laurenz Albe <laurenz.albe@cybertec.at>
Date: Mon, 18 Mar 2024 16:59:43 +0100
Subject: [PATCH v1] Documentation fix for intarray's "-" operator
Document that int[] - int[] removes duplicates as well as
elements of the right array.
Discussion: https://postgr.es/m/171075007381.7104.7931589808177869854%40wrigleys.postgresql.org
---
doc/src/sgml/intarray.sgml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgmlindex c72d49b01d..ec1d525042 100644--- a/doc/src/sgml/intarray.sgml+++ b/doc/src/sgml/intarray.sgml@@ -312,7 +312,7 @@
<returnvalue>integer[]</returnvalue>
</para>
<para>
- Removes elements of the right array from the left array.+ Removes elements of the right array and duplicate entries from the left array.
</para></entry>
</row>
--
2.44.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: laurenz.albe@cybertec.at, tbogusiak@gmail.com, pgsql-docs@lists.postgresql.org
Subject: Re: Duplicates being removed from intarray on subtraction of another intarray
In-Reply-To: <396e990fa8ae32bf5c1e3bf2473778e6e296fbfe.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox