From: Heikki Linnakangas Date: Mon, 12 Sep 2011 10:00:44 +0000 (+0300) Subject: In the final emptying phase of the new GiST buffering build, set the X-Git-Tag: REL9_2_BETA1~1096 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8caf6132c7498b2b9400a5496a29e48c1c0aa516;p=thirdparty%2Fpostgresql.git In the final emptying phase of the new GiST buffering build, set the queuedForEmptying flag correctly on buffer when adding it to the queue. Also, don't add buffer to the queue if it's there already. These were harmless oversights; failing to set the flag just means that a buffer might get added to the queue twice if more tuples are added to it (although that can't actually happen at this point because all the upper buffers have already been emptied), and having the same buffer twice in the emptying queue is harmless. But better be tidy. --- 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