mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Make ginbuild's funcCtx be independent of its tmpCtx.
Previously the funcCtx was a child of the tmpCtx, but that was broken
by commit eaa5808e8e
, 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.
This commit is contained in:
@ -370,8 +370,8 @@ ginbuild(PG_FUNCTION_ARGS)
|
|||||||
buildstate.buildStats.nEntryPages++;
|
buildstate.buildStats.nEntryPages++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a temporary memory context that is reset once for each tuple
|
* create a temporary memory context that is used to hold data not yet
|
||||||
* inserted into the index
|
* dumped out to the index
|
||||||
*/
|
*/
|
||||||
buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
|
buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"Gin build temporary context",
|
"Gin build temporary context",
|
||||||
@ -379,7 +379,11 @@ ginbuild(PG_FUNCTION_ARGS)
|
|||||||
ALLOCSET_DEFAULT_INITSIZE,
|
ALLOCSET_DEFAULT_INITSIZE,
|
||||||
ALLOCSET_DEFAULT_MAXSIZE);
|
ALLOCSET_DEFAULT_MAXSIZE);
|
||||||
|
|
||||||
buildstate.funcCtx = AllocSetContextCreate(buildstate.tmpCtx,
|
/*
|
||||||
|
* create a temporary memory context that is used for calling
|
||||||
|
* ginExtractEntries(), and can be reset after each tuple
|
||||||
|
*/
|
||||||
|
buildstate.funcCtx = AllocSetContextCreate(CurrentMemoryContext,
|
||||||
"Gin build temporary context for user-defined function",
|
"Gin build temporary context for user-defined function",
|
||||||
ALLOCSET_DEFAULT_MINSIZE,
|
ALLOCSET_DEFAULT_MINSIZE,
|
||||||
ALLOCSET_DEFAULT_INITSIZE,
|
ALLOCSET_DEFAULT_INITSIZE,
|
||||||
@ -408,6 +412,7 @@ ginbuild(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
MemoryContextSwitchTo(oldCtx);
|
MemoryContextSwitchTo(oldCtx);
|
||||||
|
|
||||||
|
MemoryContextDelete(buildstate.funcCtx);
|
||||||
MemoryContextDelete(buildstate.tmpCtx);
|
MemoryContextDelete(buildstate.tmpCtx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user