Re: [HACKERS] partial aggregation with internal state type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] partial aggregation with internal state type
Дата
Msg-id 2148.1497028470@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] partial aggregation with internal state type  (Jeff Janes <jeff.janes@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Supun Nakandala
Дата:
Сообщение: Re: [HACKERS] How to refer to resource files from UDFs written in C
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] strcmp() tie-breaker for identical ICU-collated strings