aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/array_userfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-07-23 20:45:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-07-23 20:45:27 +0000
commit6a0865e4bbf678516e7f2530a163857cd51ca676 (patch)
tree5ec30fe190d706bcfc0f4f682a50021ac6ceba4a /src/backend/utils/adt/array_userfuncs.c
parent1ca695db380063d73b0579ffb36a159f8af589bf (diff)
downloadpostgresql-6a0865e4bbf678516e7f2530a163857cd51ca676.tar.gz
postgresql-6a0865e4bbf678516e7f2530a163857cd51ca676.zip
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.
Diffstat (limited to 'src/backend/utils/adt/array_userfuncs.c')
-rw-r--r--src/backend/utils/adt/array_userfuncs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c
index a1f48d8784c..5b1cdd877b0 100644
--- a/src/backend/utils/adt/array_userfuncs.c
+++ b/src/backend/utils/adt/array_userfuncs.c
@@ -6,7 +6,7 @@
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.31 2009/06/20 18:45:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.32 2009/07/23 20:45:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -539,7 +539,9 @@ array_agg_finalfn(PG_FUNCTION_ARGS)
/*
* Make the result. We cannot release the ArrayBuildState because
- * sometimes aggregate final functions are re-executed.
+ * sometimes aggregate final functions are re-executed. Rather, it
+ * is nodeAgg.c's responsibility to reset the aggcontext when it's
+ * safe to do so.
*/
result = makeMdArrayResult(state, 1, dims, lbs,
CurrentMemoryContext,