Re: [HACKERS] partial aggregation with internal state type - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] partial aggregation with internal state type
Date
Msg-id 2148.1497028470@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] partial aggregation with internal state type  (Jeff Janes <jeff.janes@gmail.com>)
List pgsql-hackers
Jeff Janes <jeff.janes@gmail.com> writes:
> On Fri, Jun 9, 2017 at 9:06 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The issue is how to initialize the state value to begin with.

> Why does it need to be initialized?  initializing a NULL state upon first
> use is already the job of sfunc.

Right, but for partial aggregation the combinefunc has the same kind of
role as the sfunc.

> Can't it just be left NULL if both inputs
> are NULL?  (and use serialize/deserialize to change the memory context of
> the not-NULL argument if one is NULL and one is not NULL)

Huh?  That would assume that the deserialize function is identical to what
the combinefunc would do for the first input.  I'm not sure it's even the
right abstract type signature for that.  I think you're also assuming too
much about what the combine and deserialize functions will do in terms
of memory context usage.

In the end it's not very clear to me what you hope to gain here.  It's
not like there's any chance of omitting the combinefunc altogether.
Requiring it to do something sane with a NULL initial combined state
doesn't seem like much of a burden.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Supun Nakandala
Date:
Subject: Re: [HACKERS] How to refer to resource files from UDFs written in C
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings