aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-08 20:39:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-08 20:39:52 +0000
commitd5768dce10576c2fb1254c03fb29475d4fac6bb4 (patch)
tree7b971cb06b6671d66df26027909e1d9355d65d14 /src/backend/utils/adt/int8.c
parent4d3d2e2b0325e3d6d524c6801b7439d3aaea4520 (diff)
downloadpostgresql-d5768dce10576c2fb1254c03fb29475d4fac6bb4.tar.gz
postgresql-d5768dce10576c2fb1254c03fb29475d4fac6bb4.zip
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.
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 6707b79e548..1482017561d 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.77 2010/01/07 04:53:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.78 2010/02/08 20:39:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,7 +19,6 @@
#include "funcapi.h"
#include "libpq/pqformat.h"
-#include "nodes/nodes.h"
#include "utils/int8.h"
@@ -654,15 +653,13 @@ int8inc(PG_FUNCTION_ARGS)
{
/*
* When int8 is pass-by-reference, we provide this special case to avoid
- * palloc overhead for COUNT(): when called from nodeAgg, we know that the
- * argument is modifiable local storage, so just update it in-place. (If
- * int8 is pass-by-value, then of course this is useless as well as
- * incorrect, so just ifdef it out.)
+ * palloc overhead for COUNT(): when called as an aggregate, we know that
+ * the argument is modifiable local storage, so just update it
+ * in-place. (If int8 is pass-by-value, then of course this is useless as
+ * well as incorrect, so just ifdef it out.)
*/
#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
- if (fcinfo->context &&
- (IsA(fcinfo->context, AggState) ||
- IsA(fcinfo->context, WindowAggState)))
+ if (AggCheckCallContext(fcinfo, NULL))
{
int64 *arg = (int64 *) PG_GETARG_POINTER(0);
int64 result;
@@ -680,7 +677,7 @@ int8inc(PG_FUNCTION_ARGS)
else
#endif
{
- /* Not called by nodeAgg, so just do it the dumb way */
+ /* Not called as an aggregate, so just do it the dumb way */
int64 arg = PG_GETARG_INT64(0);
int64 result;