mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +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:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.37 2008/12/28 18:53:54 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.38 2009/06/20 18:45:28 tgl Exp $ -->
|
||||
|
||||
<sect1 id="xaggr">
|
||||
<title>User-Defined Aggregates</title>
|
||||
@ -175,10 +175,14 @@ SELECT attrelid::regclass, array_accum(atttypid::regtype)
|
||||
(IsA(fcinfo->context, AggState) ||
|
||||
IsA(fcinfo->context, WindowAggState)))
|
||||
</programlisting>
|
||||
One reason for checking this is that when it is true, the first input
|
||||
One reason for checking this is that when it is true for a transition
|
||||
function, the first input
|
||||
must be a temporary transition value and can therefore safely be modified
|
||||
in-place rather than allocating a new copy. (This is the <emphasis>only</>
|
||||
case where it is safe for a function to modify a pass-by-reference input.)
|
||||
case where it is safe for a function to modify a pass-by-reference input.
|
||||
In particular, aggregate final functions should not modify their inputs in
|
||||
any case, because in some cases they will be re-executed on the same
|
||||
final transition value.)
|
||||
See <literal>int8inc()</> for an example.
|
||||
</para>
|
||||
|
||||
|
Reference in New Issue
Block a user