mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Create an official API function for C functions to use to check if they are
being called as aggregates, and to get the aggregate transition state memory context if needed. Use it instead of poking directly into AggState and WindowAggState in places that shouldn't know so much. We should have done this in 8.4, probably, but better late than never. Revised version of a patch by Hitoshi Harada.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.38 2009/06/20 18:45:28 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.39 2010/02/08 20:39:51 tgl Exp $ -->
|
||||
|
||||
<sect1 id="xaggr">
|
||||
<title>User-Defined Aggregates</title>
|
||||
@ -166,14 +166,10 @@ SELECT attrelid::regclass, array_accum(atttypid::regtype)
|
||||
|
||||
<para>
|
||||
A function written in C can detect that it is being called as an
|
||||
aggregate transition or final function by seeing if it was passed
|
||||
an <structname>AggState</> or <structname>WindowAggState</> node
|
||||
as the function call <quote>context</>,
|
||||
for example by:
|
||||
aggregate transition or final function by calling
|
||||
<function>AggCheckCallContext</>, for example:
|
||||
<programlisting>
|
||||
if (fcinfo->context &&
|
||||
(IsA(fcinfo->context, AggState) ||
|
||||
IsA(fcinfo->context, WindowAggState)))
|
||||
if (AggCheckCallContext(fcinfo, NULL))
|
||||
</programlisting>
|
||||
One reason for checking this is that when it is true for a transition
|
||||
function, the first input
|
||||
|
Reference in New Issue
Block a user