Re: Duplicates being removed from intarray on subtraction of another intarray

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: tbogusiak(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Duplicates being removed from intarray on subtraction of another intarray
Date: 2024-03-18 16:01:32
Message-ID: 396e990fa8ae32bf5c1e3bf2473778e6e296fbfe.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v1-0001-Documentation-fix-for-intarray-s-operator.patch text/x-patch 967 bytes

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Erik Wienhold 2024-03-18 16:25:10 Re: Duplicates being removed from intarray on subtraction of another intarray
Previous Message Laurenz Albe 2024-03-18 15:58:03 Re: Discourage splitting pg_wal directory