diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-02-08 20:39:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-02-08 20:39:52 +0000 |
commit | d5768dce10576c2fb1254c03fb29475d4fac6bb4 (patch) | |
tree | 7b971cb06b6671d66df26027909e1d9355d65d14 /src/backend/utils/adt/float.c | |
parent | 4d3d2e2b0325e3d6d524c6801b7439d3aaea4520 (diff) | |
download | postgresql-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/float.c')
-rw-r--r-- | src/backend/utils/adt/float.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 9f194f2785f..82e95704fb1 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.164 2010/01/02 16:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.165 2010/02/08 20:39:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1765,13 +1765,11 @@ float8_accum(PG_FUNCTION_ARGS) CHECKFLOATVAL(sumX2, isinf(transvalues[2]) || isinf(newval), true); /* - * If we're invoked by nodeAgg, we can cheat and modify our first + * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we construct a * new array with the updated transition data and return it. */ - if (fcinfo->context && - (IsA(fcinfo->context, AggState) || - IsA(fcinfo->context, WindowAggState))) + if (AggCheckCallContext(fcinfo, NULL)) { transvalues[0] = N; transvalues[1] = sumX; @@ -1820,13 +1818,11 @@ float4_accum(PG_FUNCTION_ARGS) CHECKFLOATVAL(sumX2, isinf(transvalues[2]) || isinf(newval), true); /* - * If we're invoked by nodeAgg, we can cheat and modify our first + * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we construct a * new array with the updated transition data and return it. */ - if (fcinfo->context && - (IsA(fcinfo->context, AggState) || - IsA(fcinfo->context, WindowAggState))) + if (AggCheckCallContext(fcinfo, NULL)) { transvalues[0] = N; transvalues[1] = sumX; @@ -2039,13 +2035,11 @@ float8_regr_accum(PG_FUNCTION_ARGS) isinf(newvalY), true); /* - * If we're invoked by nodeAgg, we can cheat and modify our first + * If we're invoked as an aggregate, we can cheat and modify our first * parameter in-place to reduce palloc overhead. Otherwise we construct a * new array with the updated transition data and return it. */ - if (fcinfo->context && - (IsA(fcinfo->context, AggState) || - IsA(fcinfo->context, WindowAggState))) + if (AggCheckCallContext(fcinfo, NULL)) { transvalues[0] = N; transvalues[1] = sumX; |