pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Casey & Gina <cg@osss.net>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: Arrays are sorted when using intarray subtraction operator
Date: Tue, 04 Jun 2024 16:38:04 -0400
Message-ID: <584884.1717533484@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaahssqGJ+USNutNdu3M4ud98Ary2fxopzzshAxUvCPtw@mail.gmail.com>
References: <0815AFF7-BE47-456B-896C-FB952CC52EE0@osss.net>
	<CAKFQuwaahssqGJ+USNutNdu3M4ud98Ary2fxopzzshAxUvCPtw@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tuesday, June 4, 2024, Casey & Gina <cg@osss.net> wrote:
>> I've noticed that when using the `-` operator provided by the intarray
>> extension, it appears to sort the results.  Although I want the results
>> sorted, I'd expect to have to additionally use the `sort` function it
>> provides, as this behavior isn't documented.  I don't want to rely on
>> undocumented behavior, although it would simplify my queries to do so.  Is
>> the documentation lacking in this detail, or is it an unintended bug?

> I would consider it an undocumented effect as to what the resultant array
> with elements removed looks like.

It's an implementation detail: sorting the values makes it easy to
match up duplicates.

> If you need to ensure you have a sorted
> array use the sort function.

Yeah.  While I'd judge the implementation pretty unlikely to change,
feel free to add an explicit sort call if you feel uncomfortable
about relying on it.

			regards, tom lane





view thread (3+ messages)

Message-ID: <584884.1717533484@sss.pgh.pa.us>
Permalink:  ../584884.1717533484@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/584884.1717533484@sss.pgh.pa.us

 · 

reply

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, cg@osss.net
  Subject: Re: Arrays are sorted when using intarray subtraction operator
  In-Reply-To: <584884.1717533484@sss.pgh.pa.us>

* 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