aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistbuild.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/gist/gistbuild.c')
-rw-r--r--src/backend/access/gist/gistbuild.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/access/gist/gistbuild.c b/src/backend/access/gist/gistbuild.c
index 58f1ef221e1..0046c7b3ab3 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -964,10 +964,14 @@ gistEmptyAllBuffers(GISTBuildState *buildstate)
* Add this buffer to the emptying queue, and proceed to empty
* the queue.
*/
- MemoryContextSwitchTo(gfbb->context);
- gfbb->bufferEmptyingQueue =
- lcons(nodeBuffer, gfbb->bufferEmptyingQueue);
- MemoryContextSwitchTo(buildstate->tmpCtx);
+ if (!nodeBuffer->queuedForEmptying)
+ {
+ MemoryContextSwitchTo(gfbb->context);
+ nodeBuffer->queuedForEmptying = true;
+ gfbb->bufferEmptyingQueue =
+ lcons(nodeBuffer, gfbb->bufferEmptyingQueue);
+ MemoryContextSwitchTo(buildstate->tmpCtx);
+ }
gistProcessEmptyingQueue(buildstate);
}
else