Re: Duplicates being removed from intarray on subtraction of another intarray - Mailing list pgsql-docs

From Laurenz Albe
Subject Re: Duplicates being removed from intarray on subtraction of another intarray
Date
Msg-id 396e990fa8ae32bf5c1e3bf2473778e6e296fbfe.camel@cybertec.at
Whole thread Raw
In response to Duplicates being removed from intarray on subtraction of another intarray  (PG Doc comments form <noreply@postgresql.org>)
List pgsql-docs
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

Attachment

pgsql-docs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Discourage splitting pg_wal directory
Next
From: Erik Wienhold
Date:
Subject: Re: Duplicates being removed from intarray on subtraction of another intarray