Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa19a08

Browse files
committed
Fix variable initialization when using buffering build with GiST
This can cause valgrind to complain, as the flag marking a buffer as a temporary copy was not getting initialized. While on it, fill in with zeros newly-created buffer pages. This does not matter when loading a block from a temporary file, but it makes the push of an index tuple into a new buffer page safer. This has been introduced by 1d27dcf, so backpatch all the way down to 9.4. Author: Alexander Lakhin Discussion: https://postgr.es/m/[email protected] Backpatch-through: 9.4
1 parent 5a7d697 commit fa19a08

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/access/gist/gistbuildbuffers.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
138138
nodeBuffer->pageBlocknum = InvalidBlockNumber;
139139
nodeBuffer->pageBuffer = NULL;
140140
nodeBuffer->queuedForEmptying = false;
141+
nodeBuffer->isTemp = false;
141142
nodeBuffer->level = level;
142143

143144
/*
@@ -186,8 +187,8 @@ gistAllocateNewPageBuffer(GISTBuildBuffers *gfbb)
186187
{
187188
GISTNodeBufferPage *pageBuffer;
188189

189-
pageBuffer = (GISTNodeBufferPage *) MemoryContextAlloc(gfbb->context,
190-
BLCKSZ);
190+
pageBuffer = (GISTNodeBufferPage *) MemoryContextAllocZero(gfbb->context,
191+
BLCKSZ);
191192
pageBuffer->prev = InvalidBlockNumber;
192193

193194
/* Set page free space */

0 commit comments

Comments
 (0)