Skip site navigation (1) Skip section navigation (2)

Re: array_agg() NULL Handling

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Thom Brown <thom(at)linux(dot)com>, David Fetter <david(at)fetter(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array_agg() NULL Handling
Date: 2010-09-01 18:52:40
Message-ID: AANLkTi=vjPvU4Y9AxmgDwr7r07ZmijjTEYdmLwBS4H_5@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
2010/9/1 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> 2010/9/1 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
>

nice dark trick :) -  but it doesn't work

ERROR:  aggregate 16395 needs to have compatible input type and transition type
postgres=#

Pavel



>                        regards, tom lane
>

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2010-09-01 19:31:33
Subject: Re: compiling with RELCACHE_FORCE_RELEASE doesn't pass regression
Previous:From: Tom LaneDate: 2010-09-01 18:46:00
Subject: Re: array_agg() NULL Handling

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group