aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/gin/gininsert.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index a7b7b5996e3..a65acd89104 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -1669,6 +1669,8 @@ _gin_parallel_merge(GinBuildState *state)
*/
while ((tup = tuplesort_getgintuple(state->bs_sortstate, &tuplen, true)) != NULL)
{
+ MemoryContext oldCtx;
+
CHECK_FOR_INTERRUPTS();
/*
@@ -1685,10 +1687,15 @@ _gin_parallel_merge(GinBuildState *state)
*/
AssertCheckItemPointers(buffer);
+ oldCtx = MemoryContextSwitchTo(state->tmpCtx);
+
ginEntryInsert(&state->ginstate,
buffer->attnum, buffer->key, buffer->category,
buffer->items, buffer->nitems, &state->buildStats);
+ MemoryContextSwitchTo(oldCtx);
+ MemoryContextReset(state->tmpCtx);
+
/* discard the existing data */
GinBufferReset(buffer);
}
@@ -1711,10 +1718,15 @@ _gin_parallel_merge(GinBuildState *state)
*/
AssertCheckItemPointers(buffer);
+ oldCtx = MemoryContextSwitchTo(state->tmpCtx);
+
ginEntryInsert(&state->ginstate,
buffer->attnum, buffer->key, buffer->category,
buffer->items, buffer->nfrozen, &state->buildStats);
+ MemoryContextSwitchTo(oldCtx);
+ MemoryContextReset(state->tmpCtx);
+
/* truncate the data we've just discarded */
GinBufferTrim(buffer);
}