diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-20 18:45:28 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-20 18:45:28 +0000 |
commit | 82480e28f5744582dba78320824e3569ed76e74a (patch) | |
tree | f3d6aea7799b512660fa16e3a41d4187125d20f7 /doc/src | |
parent | 87698ffa8e667f99a224420db97aa0306d71b3f4 (diff) |
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.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/xaggr.sgml | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/doc/src/sgml/xaggr.sgml b/doc/src/sgml/xaggr.sgml index b223888f9ed..1175b3640d7 100644 --- a/doc/src/sgml/xaggr.sgml +++ b/doc/src/sgml/xaggr.sgml @@ -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> |