Re: array_agg() NULL Handling - Mailing list pgsql-hackers

From Tom Lane
Subject Re: array_agg() NULL Handling
Date
Msg-id 28700.1283366760@sss.pgh.pa.us
Whole thread Raw
In response to Re: array_agg() NULL Handling  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: array_agg() NULL Handling  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> 2010/9/1 Tom Lane <tgl@sss.pgh.pa.us>:
>> Well, you can build your own version of array_agg with the same
>> implementation, except you mark the transition function as strict ...

> I am checking this now, and it is not possible - it needs a some
> initial value and there isn't possible to set a "internal" value.

Well, you can cheat a bit ...

regression=# create or replace function array_agg_transfn_strict(internal, anyelement) returns internal as
'array_agg_transfn'language internal immutable;
 
CREATE FUNCTION
regression=# create aggregate array_agg_strict(anyelement) (stype = internal,
sfunc = array_agg_transfn_strict, finalfunc = array_agg_finalfn);
CREATE AGGREGATE
regression=# create or replace function array_agg_transfn_strict(internal, anyelement) returns internal as
'array_agg_transfn'language internal strict immutable;
 
CREATE FUNCTION
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: compiling with RELCACHE_FORCE_RELEASE doesn't pass regression
Next
From: Pavel Stehule
Date:
Subject: Re: array_agg() NULL Handling