In a non-hashed Agg node, reset the "aggcontext" at group boundaries, instead
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Jul 2009 20:45:27 +0000 (20:45 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Jul 2009 20:45:27 +0000 (20:45 +0000)
commit6a0865e4bbf678516e7f2530a163857cd51ca676
tree5ec30fe190d706bcfc0f4f682a50021ac6ceba4a
parent1ca695db380063d73b0579ffb36a159f8af589bf
In a non-hashed Agg node, reset the "aggcontext" at group boundaries, instead
of individually pfree'ing pass-by-reference transition values.  This should
be at least as fast as the prior coding, and it has the major advantage of
clearing out any working data an aggregate function may have stored in or
underneath the aggcontext.  This avoids memory leakage when an aggregate
such as array_agg() is used in GROUP BY mode.  Per report from Chris Spotts.

Back-patch to 8.4.  In principle the problem could arise in prior versions,
but since they didn't have array_agg the issue seems not critical.
src/backend/executor/nodeAgg.c
src/backend/utils/adt/array_userfuncs.c