intarray sort returns wrong result

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: intarray sort returns wrong result
Date: 2024-11-12 00:58:08
Message-ID: CAEG8a3+trLbTSrXDRH2Og9Atu+qvm5qr52wfYkJoGVn=cqKO6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

While working on general array sort[1], I played with intarray
extension, found a bug (or at least inconsistency) when sorting
multidimensional int array:

create extension intarray;
select sort('{{1,2,3}, {2,3,4}}');

this returns {{1,2,2},{3,3,4}} instead of {{1,2,3},{2,3,4}}

I think this is misleading, if int array is only for one dimension
array, we should
error out when sorting multidimensional int array. Or we can do something like
attached POC patch to make it work with multidimensional int array.

Thoughts?

[1]: https://www.postgresql.org/message-id/CAEG8a3KD7ZmQpxNhfPxyc0BjTTTUXiqb56VuMgB7Muu0%2ByV%3DqQ%40mail.gmail.com

--
Regards
Junwang Zhao

Attachment Content-Type Size
v1-0001-int-array-support-multi-dim.patch application/octet-stream 3.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-11-12 01:13:44 Re: intarray sort returns wrong result
Previous Message Andy Fan 2024-11-12 00:33:33 Re: explain plans for foreign servers