Re: array_agg for 8.3 - Mailing list pgsql-general

From Jeff Davis
Subject Re: array_agg for 8.3
Date
Msg-id 1232217781.7281.24.camel@jdavis
Whole thread Raw
In response to array_agg for 8.3  (Faheem Mitha <faheem@email.unc.edu>)
List pgsql-general
On Sat, 2009-01-17 at 02:09 -0500, Faheem Mitha wrote:
> Hi,
>
> Can anyone comment on the practicality of using the code for array_agg
> from the dev repos, file src/backend/utils/adt/array_userfuncs.c in 8.3 as
> a user defined function? It looks like this code was recently added, Nov
> 13th/14th. There are two functions, array_agg_transfn and
> array_agg_finalfn, but I'm not clear how to use them. The idea would be to
> compile and load them like as any other user-defined C function in 8.3. I
> was informed that directly trying to use these functions in 8.3 would not
> work. I realise this funcionality will be available in 8.4, but I don't
> want to wait.
>
> If anyone has working code along these lines, please send it to me. Also,
> please CC me on any reply. Thanks.


Hi,

I wrote a module that will include these functions in 8.3.

The reason it's not easy to just make them a normal UDF is because the
state type is "internal", and that's not allowed using regular SQL. I
got around this by updating the catalogs directly. I believe "internal"
is safe here because the state still uses one palloc() chunk (and it
matches the commit to 8.4, anyway).

Code review welcome.

Regards,
    Jeff Davis

Attachment

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: executing a sql script
Next
From: Jasen Betts
Date:
Subject: Re: Trigger to clone across databases?