Re: [PATCH] Negative Transition Aggregate Functions (WIP) - Mailing list pgsql-hackers

From Florian Pflug
Subject Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Date
Msg-id 0D073BF1-DB88-403D-8B7B-2208A6FA6C1F@phlo.org
Whole thread Raw
In response to Re: [PATCH] Negative Transition Aggregate Functions (WIP)  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: [PATCH] Negative Transition Aggregate Functions (WIP)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Jan10, 2014, at 09:34 , David Rowley <dgrowleyml@gmail.com> wrote:
> I just don't quite know yet the base way for the inverse transition function to communicate this to the caller yet.
Ifyou have any ideas on the best way to do this then I'd really like to hear them. 

Could they maybe just return NULL as the new state? It would mean that
aggregates that do want to provide an inverse transition function couldn't
use NULL as a valid aggregate state, but do we need to support that?

Looking at the code it seems that for quite a few existing aggregates,
the state remains NULL until the first non-NULL input is processed. But
that doesn't hurt much - those aggregates can remain as they are until
someone wants to add an inverse transfer function. Once that happens,
there's a choice between living with needless rescans on trailing NULL
inputs or changing the state type.

This solution isn't particularly pretty, but I don't currently see a good
alternative that allows implementing inverse transfer functions is something
other than C and avoid needless overhead for those which are written in C.

best regards,
Florian Pflug




pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: array_length(anyarray)
Next
From: Merlin Moncure
Date:
Subject: Re: array_length(anyarray)