Re: [GENERAL] aggregate returning anyarray and 'cannot determine result data type'

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] aggregate returning anyarray and 'cannot determine result data type'
Дата
Msg-id 22050.1398262053@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [GENERAL] aggregate returning anyarray and 'cannot determine result data type'  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [GENERAL] aggregate returning anyarray and 'cannot determine result data type'  (Tomas Vondra <tv@fuzzy.cz>)
Список pgsql-hackers
I wrote:
> The same problem came up in connection with the "ordered set" aggregates
> that were added recently, and that patch implemented an interesting
> workaround: the final function for an OSA gets additional dummy arguments
> of the same type as the aggregate inputs.  They are always passed as NULLs
> at runtime, and have no real value except if the aggregate is polymorphic
> --- but when it is, they provide a way to resolve the result type of a
> polymorphic final function, even if the state type is "internal" or
> otherwise non-polymorphic.

> I thought at the time that maybe we should offer this feature for regular
> aggregates as well as ordered-set ones, but didn't do anything about
> it because there hadn't been demand.

After sleeping on it, I'm convinced that this was an oversight that
we should fix before 9.4 ships.  The code changes should be pretty
minimal; the executor in particular probably needs *less* code to
do this in a uniform way.

> One potential issue though is that if sample_final existed in both
> signatures it wouldn't be very clear which one got selected for the
> aggregate.  Perhaps the best fix would be to invent a different
> CREATE AGGREGATE keyword for finalfns with extra arguments?

To be concrete: let's add a new boolean parameter with the semantics of
"final function takes extra dummy arguments" (default false).  There would
need to be one for the separate moving-aggregate final function too,
of course.

The best naming idea I've got right now is "finalfunc_extra" and
"mfinalfunc_extra", but maybe somebody can do better?
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Re: default opclass for jsonb (was Re: Call for GIST/GIN/SP-GIST opclass documentation)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Re: default opclass for jsonb (was Re: Call for GIST/GIN/SP-GIST opclass documentation)