Re: [PATCH] Add array_reverse() function - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Add array_reverse() function
Date
Msg-id 1567735.1729526430@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Add array_reverse() function  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
List 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 by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: New "raw" COPY format
Next
From: Michail Nikolaev
Date:
Subject: Re: [BUG?] check_exclusion_or_unique_constraint false negative