aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gin/gininsert.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-03-29 14:02:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-03-29 14:02:58 -0400
commit1601830ec20d56dc7bf6b60a34f69841429e4825 (patch)
tree5cb926ad9e522d7bc554d6d7f0e366c206deeaf4 /src/backend/access/gin/gininsert.c
parent9a8e23311cac14168df6644e03d533a4b07f933e (diff)
downloadpostgresql-1601830ec20d56dc7bf6b60a34f69841429e4825.tar.gz
postgresql-1601830ec20d56dc7bf6b60a34f69841429e4825.zip
Make ginbuild's funcCtx be independent of its tmpCtx.
Previously the funcCtx was a child of the tmpCtx, but that was broken by commit eaa5808e8ec4e82ce1a87103a6b6f687666e4e4c, 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.
Diffstat (limited to 'src/backend/access/gin/gininsert.c')
-rw-r--r--src/backend/access/gin/gininsert.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index cc8d9d92ee9..fc44f0205d0 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -370,8 +370,8 @@ ginbuild(PG_FUNCTION_ARGS)
buildstate.buildStats.nEntryPages++;
/*
- * create a temporary memory context that is reset once for each tuple
- * inserted into the index
+ * create a temporary memory context that is used to hold data not yet
+ * dumped out to the index
*/
buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
"Gin build temporary context",
@@ -379,7 +379,11 @@ ginbuild(PG_FUNCTION_ARGS)
ALLOCSET_DEFAULT_INITSIZE,
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",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
@@ -408,6 +412,7 @@ ginbuild(PG_FUNCTION_ARGS)
}
MemoryContextSwitchTo(oldCtx);
+ MemoryContextDelete(buildstate.funcCtx);
MemoryContextDelete(buildstate.tmpCtx);
/*