int_array_enum function should be using fcinfo->flinfo->fn_extra for
authorTom Lane
Mon, 15 Aug 2005 19:05:16 +0000 (19:05 +0000)
committerTom Lane
Mon, 15 Aug 2005 19:05:16 +0000 (19:05 +0000)
working state, not fcinfo->context.  Silly oversight on my part in last
go-round of fixes.

contrib/intagg/int_aggregate.c

index df2bd1e0336872f0d63a5ab436308f2b39087acf..f4391b46996cc3784b900d69b9aa4d667cdbcb68 100644 (file)
@@ -220,9 +220,9 @@ int_enum(PG_FUNCTION_ARGS)
        PG_RETURN_NULL();
    }
 
-   if (!fcinfo->context)
+   if (!fcinfo->flinfo->fn_extra)
    {
-       /* Allocate a working context */
+       /* Allocate working state */
        MemoryContext   oldcontext;
 
        oldcontext = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
@@ -247,19 +247,20 @@ int_enum(PG_FUNCTION_ARGS)
        if (pc->p->a.ndim > 1)
            elog(ERROR, "int_enum only accepts 1-D arrays");
        pc->num = 0;
-       fcinfo->context = (Node *) pc;
+       fcinfo->flinfo->fn_extra = (void *) pc;
        MemoryContextSwitchTo(oldcontext);
    }
-   else    /* use an existing one */
-       pc = (CTX *) fcinfo->context;
+   else    /* use existing working state */
+       pc = (CTX *) fcinfo->flinfo->fn_extra;
+
    /* Are we done yet? */
    if (pc->p->a.ndim < 1 || pc->num >= pc->p->items)
    {
        /* We are done */
        if (pc->flags & TOASTED)
            pfree(pc->p);
-       pfree(fcinfo->context);
-       fcinfo->context = NULL;
+       pfree(pc);
+       fcinfo->flinfo->fn_extra = NULL;
        rsi->isDone = ExprEndResult;
    }
    else