1
0
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:
Tom Lane
2010-02-08 20:39:52 +00:00
parent 4d3d2e2b03
commit d5768dce10
9 changed files with 124 additions and 110 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.11 2010/01/02 16:57:32 momjian Exp $
* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.c,v 1.12 2010/02/08 20:39:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -422,15 +422,8 @@ tsa_rewrite_accum(PG_FUNCTION_ARGS)
MemoryContext aggcontext;
MemoryContext oldcontext;
if (fcinfo->context && IsA(fcinfo->context, AggState))
aggcontext = ((AggState *) fcinfo->context)->aggcontext;
else if (fcinfo->context && IsA(fcinfo->context, WindowAggState))
aggcontext = ((WindowAggState *) fcinfo->context)->wincontext;
else
{
if (!AggCheckCallContext(fcinfo, &aggcontext))
elog(ERROR, "tsa_rewrite_accum called in non-aggregate context");
aggcontext = NULL; /* keep compiler quiet */
}
if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
{