Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-04 Thread Vik Fearing
On 07/02/2014 10:15 PM, Andrew Gierth wrote: (Had one request so far for a mode() variant that returns the unique modal value if one exists, otherwise null; so the current set of ordered-set aggs by no means exhausts the possible applications.) I resemble that remark. :) But seriously, am I

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-03 Thread Andrew Gierth
Tom == Tom Lane t...@sss.pgh.pa.us writes: Tom If we're going to do that, I think it needs to be in 9.4. Are Tom you going to work up a patch? How's this? (applies and passes regression on 9.4 and master) -- Andrew (irc:RhodiumToad) diff --git a/src/backend/executor/nodeAgg.c

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-03 Thread Andrew Gierth
Here are two more, cumulative with the previous patch and each other: The first removes the assumption in ordered_set_startup that the aggcontext can be cached in fn_extra, and puts it in the transvalue instead. The second exposes the OSA* structures in a header file, so that user-defined

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-03 Thread Tom Lane
Andrew Gierth and...@tao11.riddles.org.uk writes: Tom == Tom Lane t...@sss.pgh.pa.us writes: Tom If we're going to do that, I think it needs to be in 9.4. Are Tom you going to work up a patch? How's this? (applies and passes regression on 9.4 and master) Pushed with minor cosmetic

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-03 Thread Andrew Gierth
Tom == Tom Lane t...@sss.pgh.pa.us writes: How's this? (applies and passes regression on 9.4 and master) Tom Pushed with minor cosmetic adjustments. Thanks! -- Andrew (irc:RhodiumToad) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-03 Thread Tom Lane
Andrew Gierth and...@tao11.riddles.org.uk writes: Here are two more, cumulative with the previous patch and each other: The first removes the assumption in ordered_set_startup that the aggcontext can be cached in fn_extra, and puts it in the transvalue instead. OK, done. (ATM it seems like

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-02 Thread Tom Lane
Andrew Gierth and...@tao11.riddles.org.uk writes: 1. Assumptions about the relationship between aggcontext and fn_extra Tom's version of the ordered-set aggregate code makes the assumption that it is safe to store the aggcontext returned by AggCheckCallContext in a structure hung off

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-02 Thread Andrew Gierth
Tom == Tom Lane t...@sss.pgh.pa.us writes: Doing rollup via GroupAggregate by maintaining multiple transition values at a time (one per grouping set) means that the transfn is being called interleaved for transition values in different contexts. So the question becomes: is it wrong for

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-02 Thread Tom Lane
Andrew Gierth and...@tao11.riddles.org.uk writes: Tom == Tom Lane t...@sss.pgh.pa.us writes: Tom Another approach would be to remove AggGetPerAggEContext as such Tom from the API altogether, and instead offer an interface that Tom says register an aggregate cleanup callback, leaving it to

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-02 Thread Andrew Gierth
Tom == Tom Lane t...@sss.pgh.pa.us writes: Tom Another approach would be to remove AggGetPerAggEContext as such Tom from the API altogether, and instead offer an interface that Tom says register an aggregate cleanup callback, leaving it to the Tom agg/window core code to figure out which

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-02 Thread Tom Lane
Andrew Gierth and...@tao11.riddles.org.uk writes: Tom == Tom Lane t...@sss.pgh.pa.us writes: Tom If we're going to do that, I think it needs to be in 9.4. Are Tom you going to work up a patch? Do we want a decision on the fn_extra matter first, or shall I do one patch for the econtext,

Re: [HACKERS] Aggregate function API versus grouping sets

2014-07-02 Thread Andrew Gierth
Tom == Tom Lane t...@sss.pgh.pa.us writes: Do we want a decision on the fn_extra matter first, or shall I do one patch for the econtext, and a following one for fn_extra? Tom I think they're somewhat independent, and probably best patched Tom separately. In any case orderedsetagg.c's use