From d5768dce10576c2fb1254c03fb29475d4fac6bb4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 8 Feb 2010 20:39:52 +0000 Subject: 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. --- doc/src/sgml/xaggr.sgml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/xaggr.sgml b/doc/src/sgml/xaggr.sgml index 1175b3640d7..1c34957a166 100644 --- a/doc/src/sgml/xaggr.sgml +++ b/doc/src/sgml/xaggr.sgml @@ -1,4 +1,4 @@ - + User-Defined Aggregates @@ -166,14 +166,10 @@ SELECT attrelid::regclass, array_accum(atttypid::regtype) 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 AggState or WindowAggState node - as the function call context, - for example by: + aggregate transition or final function by calling + AggCheckCallContext, for example: - if (fcinfo->context && - (IsA(fcinfo->context, AggState) || - IsA(fcinfo->context, WindowAggState))) + if (AggCheckCallContext(fcinfo, NULL)) One reason for checking this is that when it is true for a transition function, the first input -- cgit v1.2.3