Re: [PATCH] Add array_reverse() function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH] Add array_reverse() function
Дата
Msg-id 1567735.1729526430@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [PATCH] Add array_reverse() function  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Список pgsql-hackers
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> writes:
> On Mon, Oct 21, 2024 at 2:36 PM Aleksander Alekseev
> <aleksander@timescale.com> wrote:
> + /*
> + * There is no point in reversing empty arrays or arrays with less than
> + * two items.
> + */
> + if (ARR_NDIM(array) < 1 || ARR_DIMS(array)[0] < 2)
> +     PG_RETURN_ARRAYTYPE_P(array);

> 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.

            regards, tom lane



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