From f20f95c393d01198fc7a36e4b566252bb24a96c0 Mon Sep 17 00:00:00 2001 From: Ants Aasma Date: Tue, 21 Nov 2017 11:41:33 +0200 Subject: [PATCH] Fix handling of SMGR create and truncate records and sequence create records --- src/include/wbpgtypes.h | 5 +++++ src/wbfilter.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/include/wbpgtypes.h b/src/include/wbpgtypes.h index 4975752..fd42728 100644 --- a/src/include/wbpgtypes.h +++ b/src/include/wbpgtypes.h @@ -254,6 +254,11 @@ typedef struct XLogRecord #define XLOG_SWITCH 0x40 #define XLOG_FPI 0xA0 +#define XLOG_SMGR_CREATE 0x10 +#define XLOG_SMGR_TRUNCATE 0x20 + +#define XLOG_SEQ_LOG 0x00 + #define REC_HEADER_LEN 24 #define XLR_MAX_BLOCK_ID 32 diff --git a/src/wbfilter.c b/src/wbfilter.c index bf85cf5..37e1ec6 100644 --- a/src/wbfilter.c +++ b/src/wbfilter.c @@ -170,6 +170,29 @@ WbFProcessWalDataBlock(ReplMessage* msg, FilterData* fl, XLogRecPtr *retryPos) parse_debug(" - Xlog switch, copying %d bytes ", fl->dataNeeded); break; } + else if (rec->xl_rmid == RM_SMGR_ID && (rec->xl_info & 0xF0) == XLOG_SMGR_CREATE) + { + fl->state = FS_BUFFER_FILENODE; + fl->dataNeeded = sizeof(RelFileNode); + parse_debug(" - SMGR record, buffering %d bytes for filenode", fl->dataNeeded); + break; + } + else if (rec->xl_rmid == RM_SMGR_ID && (rec->xl_info & 0xF0) == XLOG_SMGR_TRUNCATE) + { + fl->state = FS_BUFFER_FILENODE; + // Here we rely on the fact that FS_BUFFER_FILENODE will ignore any extra data + fl->recordRemaining -= sizeof(BlockNumber); + fl->dataNeeded = sizeof(BlockNumber) + sizeof(RelFileNode); + parse_debug(" - SMGR record, buffering %d bytes for filenode", fl->dataNeeded); + break; + } + else if (rec->xl_rmid == RM_SEQ_ID && (rec->xl_info & 0xF0) == XLOG_SEQ_LOG) + { + fl->state = FS_BUFFER_FILENODE; + fl->dataNeeded = sizeof(RelFileNode); + parse_debug(" - SMGR record, buffering %d bytes for filenode", fl->dataNeeded); + break; + } else if (fl->recordRemaining == 0) { fl->state = FS_COPY_NORMAL;