Re: array_to_set functions

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: Decibel! <decibel(at)decibel(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: array_to_set functions
Date: 2007-08-01 01:44:50
Message-ID: b42b73150707311844k430a9350wc49cb5be73541f31@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/1/07, Decibel! <decibel(at)decibel(dot)org> wrote:
> David Fetter and I just came up with these, perhaps others will find
> them useful:
>
> CREATE OR REPLACE FUNCTION array_to_set(anyarray, int) RETURNS SETOF anyelement LANGUAGE SQL AS $$
> SELECT $1[i] from generate_series(array_lower($1, $2), array_upper($1, $2)) i
> $$;
> CREATE OR REPLACE FUNCTION array_to_set(anyarray) RETURNS SETOF anyelement LANGUAGE SQL AS $$
> SELECT array_to_set($1, 1)
> $$;

very nice, although IMO there is a strong justification for these
functions to be in core and written in C for efficiency (along with
array_accum, which I have hand burn from copying and pasting out of
the documentation).

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-08-01 01:51:07 Re: Polymorphic functions' weird behavior
Previous Message Decibel! 2007-08-01 01:04:59 array_to_set functions