Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-13 Thread Tom Lane
I wrote: > Moving on to the exact color of the bikeshed: it seems like the right > way to present this to users of CREATE AGGREGATE is in terms of "does > the final function modify the transition state?". So maybe the values > could be spelled > SMODIFY = READ_ONLY ffunc never touches state, ok

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-13 Thread Tom Lane
Heikki Linnakangas writes: > We've been doing that window agg thing for a long time, so I think > "works as window agg" should be the default for regular aggregates. For > ordered-set aggregates, "no merging, no more transfn() calls after > finalfn()" seems safest. > It's a

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-13 Thread Tom Lane
Heikki Linnakangas writes: > On 10/13/2017 02:08 AM, Tom Lane wrote: >> I started to look into fixing orderedsetaggs.c so that we could revert >> 52328727b, and soon found a rather nasty problem. Although the plain >> OSAs seem amenable to supporting multiple finalfn calls on

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-13 Thread Heikki Linnakangas
On 10/13/2017 02:41 AM, Tom Lane wrote: David Rowley writes: On 13 October 2017 at 12:08, Tom Lane wrote: Therefore, I think we need to bite the bullet and provide an aggregate property (CREATE AGGREGATE argument / pg_aggregate column) that

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-13 Thread Heikki Linnakangas
On 10/13/2017 02:08 AM, Tom Lane wrote: I started to look into fixing orderedsetaggs.c so that we could revert 52328727b, and soon found a rather nasty problem. Although the plain OSAs seem amenable to supporting multiple finalfn calls on the same transition state, the "hypothetical set"

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-12 Thread Tom Lane
David Rowley writes: > On 13 October 2017 at 12:41, Tom Lane wrote: >> Yeah, we would probably also want to check the flag in nodeWindowAgg. >> Not sure exactly how that should play out --- maybe we end up with >> a tri-valued property "works as

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-12 Thread David Rowley
On 13 October 2017 at 12:41, Tom Lane wrote: > David Rowley writes: >> If the user defines their normal aggregate as not safe for merging, >> then surely it'll not be suitable to be used as a window function >> either, since the final function

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-12 Thread Tom Lane
David Rowley writes: > On 13 October 2017 at 12:08, Tom Lane wrote: >> Therefore, I think we need to bite the bullet and provide an aggregate >> property (CREATE AGGREGATE argument / pg_aggregate column) that tells >> whether the aggregate

Re: [HACKERS] Aggregate transition state merging vs. hypothetical set functions

2017-10-12 Thread David Rowley
On 13 October 2017 at 12:08, Tom Lane wrote: > Therefore, I think we need to bite the bullet and provide an aggregate > property (CREATE AGGREGATE argument / pg_aggregate column) that tells > whether the aggregate supports transition state merging. Likely this > should have