Re: Parallel Aggregates for string_agg and array_agg
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Stephen Frost <sfrost@snowman.net>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>,
Andres Freund <andres@anarazel.de>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-03-26T09:37:37Z
Lists: pgsql-hackers
On 26 March 2018 at 15:26, Stephen Frost <sfrost@snowman.net> wrote: > The header at the top of datumCopy() pretty clearly says that it's for > "non-NULL" datums, yet this function seems to be happily ignoring that > and just trying to use it to copy everything. Perhaps I'm missing > something, but I don't see anything obvious that would lead me to > conclude that what's being done here (or in other similar cases in this > patch) is acceptable. Thanks for looking at this. You're right. I've overlooked this. The code should be checking for NULL value Datums there. I've fixed this locally, but on testing, I discovered another bug around string_agg. At the moment string_agg's transfn only allocates the state when it gets a non-NULL string to aggregate, whereas it seems other trans functions which return an internal state allocate their state on the first call. e.g. int8_avg_accum(). This NULL state is causing the serial function segfault on a null pointer dereference. I think the fix is to always allocate the state in the transfn, but I just wanted to point this out before I go and do that. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Commits
-
Fix unstable aggregate regression test
- f5d0e866404a 16.3 landed
- d6a6957d53e3 17.0 landed
-
Allow parallel aggregate on string_agg and array_agg
- 16fd03e95654 16.0 landed
-
Improve performance of ORDER BY / DISTINCT aggregates
- 1349d2790bf4 16.0 cited
-
Support ORDER BY within aggregate function calls, at long last providing a
- 34d26872ed81 9.0.0 cited
-
Fix broken markup.
- 6a6efb964092 9.0.0 cited