From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [PATCH] Add array_reverse() function |
Date: | 2024-10-22 13:27:30 |
Message-ID: | CAJ7c6TMuPDMp2KxORDLT9+2Ggu47ye0X_VGyGYB5_F3NM-kb4A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi everyone,
Thanks for the feedback!
> > But it returns the input array as is. I think it should at least make
> > a new copy of input array.
>
> I don't think that's really necessary. We have other functions that
> will return an input value unchanged without copying it. A
> longstanding example is array_larger. Also, this code looks to be
> copied from array_shuffle.
It was indeed copied from array_shuffle().
Makes me wonder if we should have an utility function which would
contain common code for array_shuffle() and array_reverse().
Considering inconveniences such an approach caused in case of common
code for text and bytea types [1] I choose to copy the code and modify
it for the task.
> +
> + /* If the target array is empty, exit fast */
> + if (ndim < 1 || dims[0] < 1)
> + return construct_empty_array(elmtyp);
>
> This is taken care by the caller, at least the ndim < 1 case.
Agree. Here is the corrected patch.
[1]: https://postgr.es/m/CAJ7c6TO3X88dGd8C4Tb-Eq2ZDPz+9mP+KOwdzK_82BEz_cMPZg@mail.gmail.com
--
Best regards,
Aleksander Alekseev
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Add-array_reverse-function.patch | application/x-patch | 7.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Borisov | 2024-10-22 13:30:20 | Re: pgsql: Implement pg_wal_replay_wait() stored procedure |
Previous Message | Vik Fearing | 2024-10-22 13:12:43 | Re: Row pattern recognition |