Re: [PATCH] Negative Transition Aggregate Functions (WIP)

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Greg Stark <stark(at)mit(dot)edu>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Date: 2014-04-11 17:25:02
Message-ID: 37F8748C-31A3-43B6-858C-33252429081D@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Apr11, 2014, at 19:04 , Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> It strikes me that your second point
>
>> 2) It allows strict aggregates whose state type and input type aren't
>> binary coercible to return NULL if all inputs were NULL without any
>> special coding. As it stands today, this doesn't work without some
>> kind of counter in the state, because the final function otherwise
>> won't know if there were non-NULL inputs or not. Aggregates whose state
>> and input types are binary coercible get around that by setting the
>> initial value to NULL while *still* being strict, and relying on the
>> state replacement behaviour of the aggregate machinery.
>
> could be addressed by the initfunc idea, but I'm still not sufficiently
> excited by that one. Given the problem with internal-type transition
> values, I think this could only win if there are cases where it would let
> us use a regular SQL type instead of internal for the transition value;
> and I'm not sure that there are many/any such cases.

Yes, the idea had come up at some point during the review discussion. I
agree that it's only worthwhile if it works for state type internal - though
I think there ought to be a way to allow that. We could for example simply
decree that the initfunc's first parameter must be of type internal if it's
return type is, and then just pass NULL for that parameter.

What I like about the initfunc idea is that it also naturally extends to
ordered-set aggregates, I think it'd be very useful for some possible
ordered-set aggregates to received their direct arguments beforehand and not
afterwards.

But that all seems largely orthogonal to the invtrans patch.

best regards,
Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-04-11 17:25:43 Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Previous Message Tom Lane 2014-04-11 17:04:42 Re: [PATCH] Negative Transition Aggregate Functions (WIP)