Re: Combination of ordered-set aggregate function terminates JDBC connection on PostgreSQL 9.6.5
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: David Rowley <david.rowley@2ndquadrant.com>,
Lukas Eder <lukas.eder@gmail.com>,
PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Date: 2017-10-12T14:55:50Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Treat aggregate direct arguments as per-agg data not per-trans data.
- cf5ba7c30c04 11.0 landed
-
Allow the built-in ordered-set aggregates to share transition state.
- be0ebb65f512 11.0 landed
-
Fix AggGetAggref() so it won't lie to aggregate final functions.
- 305cf1fd7239 11.0 landed
- d48bf6a94d29 10.1 landed
- aa1e9b3a4661 9.6.6 landed
-
Prevent sharing transition states between ordered-set aggregates.
- 52328727bea4 11.0 landed
- 96cfc7e19ae1 9.6.6 landed
- 604723d29a86 10.1 landed
Heikki Linnakangas <hlinnaka@iki.fi> writes: > On 10/12/2017 05:27 AM, Tom Lane wrote: >> Speaking of AggGetAggref, there's another thing that I think 804163bc2 >> did wrong for ordered-set aggregates: it can return the wrong Aggref >> when two aggregates' intermediate states have been merged. > Conceivably we could have another function like AggGetAggref() that > returns all of the Aggrefs. But I don't think it's worth the > complication. If the transition function needs to do something different > depending on the aggregate it's for, well, don't do that. Define a > different transition function for both aggregates. Thinking about it more clearly, if a transition function is being run on behalf of several different Aggrefs (with identical input states), then no, the transition function should not care which Aggref it looks at. As you say it mustn't do anything different on the basis of the finalfn-related fields. The problem occurs when a finalfn calls AggGetAggref --- then, I think that the finalfn is entirely entitled to expect that it will see its own Aggref, not some other one that happens to share input+transition. So the issue is that we need some different behavior during finalize_aggregate than during the transition function calls. I'm inclined to put back the curperagg field we had before, and populate that during finalize_aggregate. Then, AggGetAggref would look at either curperagg or curpertrans, whichever is set. regards, tom lane