Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1601830

Browse files
committed
Make ginbuild's funcCtx be independent of its tmpCtx.
Previously the funcCtx was a child of the tmpCtx, but that was broken by commit eaa5808, which made MemoryContextReset() delete, not reset, child contexts. The behavior of having a tmpCtx reset also clear the other context seems rather dubious anyway, so let's just disentangle them. Per report from Erik Rijkers. In passing, fix badly-inaccurate comments about these contexts.
1 parent 9a8e233 commit 1601830

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/backend/access/gin/gininsert.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -370,16 +370,20 @@ ginbuild(PG_FUNCTION_ARGS)
370370
buildstate.buildStats.nEntryPages++;
371371

372372
/*
373-
* create a temporary memory context that is reset once for each tuple
374-
* inserted into the index
373+
* create a temporary memory context that is used to hold data not yet
374+
* dumped out to the index
375375
*/
376376
buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
377377
"Gin build temporary context",
378378
ALLOCSET_DEFAULT_MINSIZE,
379379
ALLOCSET_DEFAULT_INITSIZE,
380380
ALLOCSET_DEFAULT_MAXSIZE);
381381

382-
buildstate.funcCtx = AllocSetContextCreate(buildstate.tmpCtx,
382+
/*
383+
* create a temporary memory context that is used for calling
384+
* ginExtractEntries(), and can be reset after each tuple
385+
*/
386+
buildstate.funcCtx = AllocSetContextCreate(CurrentMemoryContext,
383387
"Gin build temporary context for user-defined function",
384388
ALLOCSET_DEFAULT_MINSIZE,
385389
ALLOCSET_DEFAULT_INITSIZE,
@@ -408,6 +412,7 @@ ginbuild(PG_FUNCTION_ARGS)
408412
}
409413
MemoryContextSwitchTo(oldCtx);
410414

415+
MemoryContextDelete(buildstate.funcCtx);
411416
MemoryContextDelete(buildstate.tmpCtx);
412417

413418
/*

0 commit comments

Comments
 (0)