Re: array_reverse() - Mailing list pgsql-general

From Merlin Moncure
Subject Re: array_reverse()
Date
Msg-id b42b73150911020633j62bdf6c8idb5d6324ad23d634@mail.gmail.com
Whole thread Raw
In response to Re: array_reverse()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Mon, Nov 2, 2009 at 9:20 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Craig Ringer <craig@postnewspapers.com.au> writes:
>> Before I go ahead and try to write a decent quality version: is there
>> any chance an array_reverse() function (in C) would be accepted into Pg
>> mainline?
>
> What would it mean for a multi-dimensional array?

Couple of possibilities?:
*) Could raise an error for ndim != 1
*) could reverse top dimension only only (I like this the best), so that:

reverse(array[array[1,2], array[3,4]]) -> {{3,4},{1,2}};

*) maybe overload the above so that:
reverse(array[array[1,2], array[3,4]], array[1]) -> {{2,1},{3,4}};
reverse(array[array[1,2], array[3,4]], array[2]) -> {{1,2},{4,3}};

The second term would be int array of 1 to ndim -1 dimensions, so you
can re-arrange an array slice without restacking it.

merlin

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: array_reverse()
Next
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: [PERFORM] Problem with database performance, Debian 4gb ram ?