Re: array_reverse()

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: array_reverse()
Date: 2009-11-02 14:33:16
Message-ID: b42b73150911020633j62bdf6c8idb5d6324ad23d634@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 2, 2009 at 9:20 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Craig Ringer <craig(at)postnewspapers(dot)com(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2009-11-02 14:33:52 Re: [PERFORM] Problem with database performance, Debian 4gb ram ?
Previous Message Ivan Voras 2009-11-02 14:22:03 Re: Problem with database performance, Debian 4gb ram ?