1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Fix things so that array_agg_finalfn does not modify or free its input

ArrayBuildState, per trouble report from Merlin Moncure.  By adopting
this fix, we are essentially deciding that aggregate final-functions
should not modify their inputs ever.  Adjust documentation and comments
to match that conclusion.
This commit is contained in:
Tom Lane
2009-06-20 18:45:28 +00:00
parent 87698ffa8e
commit 82480e28f5
4 changed files with 31 additions and 13 deletions

View File

@ -6,7 +6,7 @@
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.30 2009/06/11 14:49:03 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.31 2009/06/20 18:45:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -537,10 +537,13 @@ array_agg_finalfn(PG_FUNCTION_ARGS)
dims[0] = state->nelems;
lbs[0] = 1;
/* Release working state if regular aggregate, but not if window agg */
/*
* Make the result. We cannot release the ArrayBuildState because
* sometimes aggregate final functions are re-executed.
*/
result = makeMdArrayResult(state, 1, dims, lbs,
CurrentMemoryContext,
IsA(fcinfo->context, AggState));
false);
PG_RETURN_DATUM(result);
}