Re: general purpose array_sort

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, "andreas(at)proxel(dot)se" <andreas(at)proxel(dot)se>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: general purpose array_sort
Date: 2025-03-17 11:42:38
Message-ID: CAEG8a3KPOqHBcaiiBSqRzZcBZ7ocRihtWKHQt=dL_7fxdsAbzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Mar 16, 2025 at 9:50 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
>
> before commit 4618045bee4a6d3efcb489c319649d8dd9aaa738 ([0])

It seems that patch is treating int2vector and oidvector as scalar
types.

>
> select array_sort(array(select '1 4'::int2vector union all select '1
> 2'::int2vector));
> array_sort
> --------------------------
> [1:2][0:1]={{1,2},{1,4}}
> (1 row)
>

This query:
select array(select '1 4'::int2vector union all select '1 2'::int2vector);
get
[1:2][0:1]={{1,4},{1,2}}

So the behavior of array_sort is consistent.

> after
>
> select array_sort(array(select '1 4'::int2vector union all select '1
> 2'::int2vector));
> array_sort
> ---------------
> {"1 2","1 4"}
> (1 row)
>
> now look closer, the second is the expected result...
> I didn't dig deeper why commit 4618045bee made this patch result correct,
> but I guess it would be best to include such a test case,
> so I've attached a patch.
>

No objection for the test case, thanks.

>
> [0] https://git.postgresql.org/cgit/postgresql.git/commit/?id=4618045bee4a6d3efcb489c319649d8dd9aaa738

--
Regards
Junwang Zhao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-03-17 11:50:40 Re: 64 bit numbers vs format strings
Previous Message Tomas Vondra 2025-03-17 11:36:55 Re: Snapshot related assert failure on skink