diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 91df184..ef86cac 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -4577,16 +4577,10 @@ accumArrayResult(ArrayBuildState *astate, { /* First time through --- initialize */ - /* Make a temporary context to hold all the junk */ - arr_context = AllocSetContextCreate(rcontext, - "accumArrayResult", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); - oldcontext = MemoryContextSwitchTo(arr_context); + oldcontext = MemoryContextSwitchTo(rcontext); astate = (ArrayBuildState *) palloc(sizeof(ArrayBuildState)); - astate->mcontext = arr_context; - astate->alen = 64; /* arbitrary starting array size */ + astate->mcontext = rcontext; + astate->alen = 4; /* arbitrary starting array size */ astate->dvalues = (Datum *) palloc(astate->alen * sizeof(Datum)); astate->dnulls = (bool *) palloc(astate->alen * sizeof(bool)); astate->nelems = 0; @@ -4603,7 +4597,7 @@ accumArrayResult(ArrayBuildState *astate, /* enlarge dvalues[]/dnulls[] if needed */ if (astate->nelems >= astate->alen) { - astate->alen *= 2; + astate->alen += 4; astate->dvalues = (Datum *) repalloc(astate->dvalues, astate->alen * sizeof(Datum)); astate->dnulls = (bool *) @@ -4691,10 +4685,6 @@ makeMdArrayResult(ArrayBuildState *astate, MemoryContextSwitchTo(oldcontext); - /* Clean up all the junk */ - if (release) - MemoryContextDelete(astate->mcontext); - return PointerGetDatum(result); }