gist_build_fix2.patch
text/x-patch
Filename: gist_build_fix2.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/access/gist/gistbuild.c | 24 | 0 |
*** a/src/backend/access/gist/gistbuild.c
--- b/src/backend/access/gist/gistbuild.c
***************
*** 668,677 **** gistbufferinginserttuples(GISTBuildState *buildstate, Buffer buffer,
if (is_split && BufferGetBlockNumber(buffer) == GIST_ROOT_BLKNO)
{
GISTBufferingInsertStack *oldroot = gfbb->rootitem;
! Page page = BufferGetPage(buffer);
! ItemId iid;
! IndexTuple idxtuple;
! BlockNumber leftmostchild;
gfbb->rootitem = (GISTBufferingInsertStack *) MemoryContextAlloc(
gfbb->context, sizeof(GISTBufferingInsertStack));
--- 668,678 ----
if (is_split && BufferGetBlockNumber(buffer) == GIST_ROOT_BLKNO)
{
GISTBufferingInsertStack *oldroot = gfbb->rootitem;
! Page page = BufferGetPage(buffer);
! ItemId iid;
! IndexTuple idxtuple;
! BlockNumber leftmostchild;
! OffsetNumber maxoff, i;
gfbb->rootitem = (GISTBufferingInsertStack *) MemoryContextAlloc(
gfbb->context, sizeof(GISTBufferingInsertStack));
***************
*** 694,699 **** gistbufferinginserttuples(GISTBuildState *buildstate, Buffer buffer,
--- 695,719 ----
oldroot->parent = gfbb->rootitem;
oldroot->blkno = leftmostchild;
oldroot->downlinkoffnum = InvalidOffsetNumber;
+
+ /*
+ * If root page split produce new pages on leven which have buffers
+ * then initialize empty buffers there.
+ */
+ if (LEVEL_HAS_BUFFERS(oldroot->level, gfbb))
+ {
+ maxoff = PageGetMaxOffsetNumber(page);
+ for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
+ {
+ iid = PageGetItemId(page, i);
+ idxtuple = (IndexTuple) PageGetItem(page, iid);
+ gistGetNodeBuffer(gfbb,
+ buildstate->giststate,
+ ItemPointerGetBlockNumber(&(idxtuple->t_tid)),
+ i,
+ gfbb->rootitem);
+ }
+ }
}
if (splitinfo)