From 19a2bb88383228fc39ee860b990ec8ccc9363c89 Mon Sep 17 00:00:00 2001 From: reshke Date: Fri, 26 Sep 2025 09:31:40 +0000 Subject: [PATCH v2 6/6] Remove custom logic for ginxlogCreatePostingTree, replace with FPW --- src/backend/access/gin/gindatapage.c | 9 ++------- src/backend/access/gin/ginxlog.c | 24 ++++-------------------- src/include/access/ginxlog.h | 5 ----- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c index 6c2c6194720..2b9254d2850 100644 --- a/src/backend/access/gin/gindatapage.c +++ b/src/backend/access/gin/gindatapage.c @@ -1839,18 +1839,13 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems, if (RelationNeedsWAL(index) && !is_build) { XLogRecPtr recptr; - ginxlogCreatePostingTree data; - - data.size = rootsize; XLogBeginInsert(); - XLogRegisterData(&data, sizeof(ginxlogCreatePostingTree)); - XLogRegisterData(GinDataLeafPageGetPostingList(page), - rootsize); - XLogRegisterBuffer(0, buffer, REGBUF_WILL_INIT); + XLogRegisterBuffer(0, buffer, REGBUF_FORCE_IMAGE | REGBUF_STANDARD); recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_CREATE_PTREE); + PageSetLSN(page, recptr); } diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c index fa293ee79d5..a48557a62b1 100644 --- a/src/backend/access/gin/ginxlog.c +++ b/src/backend/access/gin/ginxlog.c @@ -43,28 +43,12 @@ ginRedoClearIncompleteSplit(XLogReaderState *record, uint8 block_id) static void ginRedoCreatePTree(XLogReaderState *record) { - XLogRecPtr lsn = record->EndRecPtr; - ginxlogCreatePostingTree *data = (ginxlogCreatePostingTree *) XLogRecGetData(record); - char *ptr; - Buffer buffer; - Page page; - - buffer = XLogInitBufferForRedo(record, 0); - page = BufferGetPage(buffer); - - GinInitBuffer(buffer, GIN_DATA | GIN_LEAF | GIN_COMPRESSED); + Buffer buf; - ptr = XLogRecGetData(record) + sizeof(ginxlogCreatePostingTree); + if (XLogReadBufferForRedo(record, 0, &buf) != BLK_RESTORED) + elog(ERROR, "GIN create posting tree record did not contain a full-page image"); - /* Place page data */ - memcpy(GinDataLeafPageGetPostingList(page), ptr, data->size); - - GinDataPageSetDataSize(page, data->size); - - PageSetLSN(page, lsn); - - MarkBufferDirty(buffer); - UnlockReleaseBuffer(buffer); + UnlockReleaseBuffer(buf); } static void diff --git a/src/include/access/ginxlog.h b/src/include/access/ginxlog.h index 56ba80b112c..9c98ba1f264 100644 --- a/src/include/access/ginxlog.h +++ b/src/include/access/ginxlog.h @@ -18,11 +18,6 @@ #define XLOG_GIN_CREATE_PTREE 0x10 -typedef struct ginxlogCreatePostingTree -{ - uint32 size; - /* A compressed posting list follows */ -} ginxlogCreatePostingTree; /* * The format of the insertion record varies depending on the page type. -- 2.43.0