Re: general purpose array_sort

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "andreas(at)proxel(dot)se" <andreas(at)proxel(dot)se>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>
Subject: Re: general purpose array_sort
Date: 2024-09-30 05:01:25
Message-ID: CAEG8a3+B=QpHWuLc3OqyF9GxzNPofQBwv9k3rdZty+-LYoYCJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Sep 29, 2024 at 10:51 AM David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Sat, Sep 28, 2024 at 7:05 PM Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>>
>> On Sat, Sep 28, 2024 at 10:41 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>> >
>> > <parameter>dir</parameter> can have only two potential values, make it
>> > as a boolean would be more easier?
>> > you didn't mention information: "by default, it will sort by
>> > ascending order; the sort collation by default is using the array
>> > element type's collation"
>> >
>> > tuplesort_begin_datum can do null-first, null-last, so the
>> > one-dimension array can allow null values.
>>
>> The following(create extension intarry first) will give an error, I
>> keep the same for array_sort.
>>
>> SELECT sort('{1234234,-30,234234, null}');
>>
>
> I would suggest accepting:
> asc
> desc
> asc nulls first
> asc nulls last *
> desc nulls first *
> desc nulls last
>
> As valid inputs for "dir" - and that the starred options are the defaults when null position is omitted.
>
> In short, mimic create index.
>
> David J.
>

PFA v3 with David's suggestion addressed.

--
Regards
Junwang Zhao

Attachment Content-Type Size
v3-0001-general-purpose-array_sort.patch application/octet-stream 17.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo NAGATA 2024-09-30 05:20:21 Re: First draft of PG 17 release notes
Previous Message Shlok Kyal 2024-09-30 04:58:17 Re: long-standing data loss bug in initial sync of logical replication