Re: Arrays are sorted when using intarray subtraction operator

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Arrays are sorted when using intarray subtraction operator
Дата
Msg-id 584884.1717533484@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Arrays are sorted when using intarray subtraction operator  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
"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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Arrays are sorted when using intarray subtraction operator
Следующее
От: Casey & Gina
Дата:
Сообщение: intarray bigint support