Re: array_accum aggregate - Mailing list pgsql-hackers

From Tom Lane
Subject Re: array_accum aggregate
Date
Msg-id 13184.1160192359@sss.pgh.pa.us
Whole thread Raw
In response to Re: array_accum aggregate  (Stephen Frost <sfrost@snowman.net>)
Responses Re: array_accum aggregate  ("Florian G. Pflug" <fgp@phlo.org>)
Re: array_accum aggregate  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
Stephen Frost <sfrost@snowman.net> writes:
> * Tom Lane (tgl@sss.pgh.pa.us) wrote:
>> It looks like it should work to have just one polymorphic aggregate
>> definition, eg, array_accum(anyelement) returns anyarray.

> I was hoping to do that, but since it's an aggregate the ffunc format is
> pre-defined to require accepting the 'internal state' and nothing else,
> and to return 'anyelement' or 'anyarray' one of the inputs must be an
> 'anyelement' or 'anyarray', aiui.

Hmm ... I hadn't been thinking about what the state type would need to
be, but certainly "bytea" is a lie given what you're really doing.
We've run into this same problem in contrib/intagg: sometimes you'd like
to use a state data structure that isn't any regular SQL datatype, and
in particular isn't just a single blob of memory.  That's a problem from
nodeAgg's point of view because it expects to be responsible for copying
the state value from one context to another.  Don't have an immediate
idea for a solution ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Added links to the release notes
Next
From: "Sergey E. Koposov"
Date:
Subject: FailedAssertion() in 8.2beta1