[PATCH] Refactor: Extract XLogRecord info
Hi,
I refactored the code of extracting XLogRecord info.
In XLogRecord, the high 4 bits in xl_info is used by rmgr.
typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record */
/* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no padding */
} XLogRecord;
I found lots of the code to get the info as below
XLogRecGetInfo(record) & ~XLR_INFO_MASK
Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F), which is easier to understand.
Remove XLR_INFO_MASK as it is not used any more.
--
Best regards !
Xiaoran Wang
Attachments:
0001-Refactor-Extract-XLogRecord-info.patchapplication/octet-stream; name=0001-Refactor-Extract-XLogRecord-info.patchDownload
From a9345897bec3f248d8c2fa98b24a45fc4607acbd Mon Sep 17 00:00:00 2001
From: wangxiaoran <fanfuxiaoran@gmail.com>
Date: Wed, 4 Jun 2025 14:27:03 +0800
Subject: [PATCH] Refactor: Extract XLogRecord info
In XLogRecord, the high 4 bits in xl_info is used by rmgr.
To extract the info, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F)
Remove XLR_INFO_MASK as it is not used any more.
---
src/backend/access/brin/brin_xlog.c | 2 +-
src/backend/access/gin/ginxlog.c | 2 +-
src/backend/access/gist/gistxlog.c | 2 +-
src/backend/access/hash/hash_xlog.c | 2 +-
src/backend/access/heap/heapam_xlog.c | 4 ++--
src/backend/access/nbtree/nbtxlog.c | 2 +-
src/backend/access/rmgrdesc/brindesc.c | 4 ++--
src/backend/access/rmgrdesc/clogdesc.c | 4 ++--
src/backend/access/rmgrdesc/committsdesc.c | 2 +-
src/backend/access/rmgrdesc/dbasedesc.c | 4 ++--
src/backend/access/rmgrdesc/gindesc.c | 4 ++--
src/backend/access/rmgrdesc/gistdesc.c | 4 ++--
src/backend/access/rmgrdesc/hashdesc.c | 4 ++--
src/backend/access/rmgrdesc/heapdesc.c | 8 ++++----
src/backend/access/rmgrdesc/logicalmsgdesc.c | 4 ++--
src/backend/access/rmgrdesc/mxactdesc.c | 4 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 4 ++--
src/backend/access/rmgrdesc/relmapdesc.c | 4 ++--
src/backend/access/rmgrdesc/replorigindesc.c | 2 +-
src/backend/access/rmgrdesc/seqdesc.c | 4 ++--
src/backend/access/rmgrdesc/smgrdesc.c | 4 ++--
src/backend/access/rmgrdesc/spgdesc.c | 4 ++--
src/backend/access/rmgrdesc/standbydesc.c | 4 ++--
src/backend/access/rmgrdesc/tblspcdesc.c | 4 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 4 ++--
src/backend/access/spgist/spgxlog.c | 2 +-
src/backend/access/transam/clog.c | 2 +-
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 2 +-
src/backend/access/transam/xlog.c | 4 ++--
src/backend/access/transam/xlogprefetcher.c | 2 +-
src/backend/access/transam/xlogreader.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 18 +++++++++---------
src/backend/catalog/storage.c | 2 +-
src/backend/commands/dbcommands.c | 2 +-
src/backend/commands/sequence.c | 2 +-
src/backend/commands/tablespace.c | 2 +-
src/backend/postmaster/walsummarizer.c | 8 ++++----
src/backend/replication/logical/decode.c | 6 +++---
src/backend/replication/logical/message.c | 2 +-
src/backend/replication/logical/origin.c | 2 +-
src/backend/storage/ipc/standby.c | 2 +-
src/backend/utils/cache/relmapper.c | 2 +-
src/bin/pg_rewind/parsexlog.c | 4 ++--
src/bin/pg_waldump/pg_waldump.c | 2 +-
src/include/access/xlogrecord.h | 1 -
.../test_custom_rmgrs/test_custom_rmgrs.c | 6 +++---
47 files changed, 83 insertions(+), 84 deletions(-)
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c
index 85db2f0fd5a..c9b91a15b46 100644
--- a/src/backend/access/brin/brin_xlog.c
+++ b/src/backend/access/brin/brin_xlog.c
@@ -308,7 +308,7 @@ brin_xlog_desummarize_page(XLogReaderState *record)
void
brin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info & XLOG_BRIN_OPMASK)
{
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 55a1ec09776..7b2ec5a0429 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -725,7 +725,7 @@ ginRedoDeleteListPages(XLogReaderState *record)
void
gin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCtx;
/*
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
index b354e4ba5d1..1b382848a12 100644
--- a/src/backend/access/gist/gistxlog.c
+++ b/src/backend/access/gist/gistxlog.c
@@ -396,7 +396,7 @@ gistRedoPageReuse(XLogReaderState *record)
void
gist_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCxt;
/*
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index 8d97067fe54..9df486a564b 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -1066,7 +1066,7 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
void
hash_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
diff --git a/src/backend/access/heap/heapam_xlog.c b/src/backend/access/heap/heapam_xlog.c
index 30f4c2d3c67..29e87ccc8d8 100644
--- a/src/backend/access/heap/heapam_xlog.c
+++ b/src/backend/access/heap/heapam_xlog.c
@@ -1181,7 +1181,7 @@ heap_xlog_inplace(XLogReaderState *record)
void
heap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/*
* These operations don't overwrite MVCC data so no conflict processing is
@@ -1227,7 +1227,7 @@ heap_redo(XLogReaderState *record)
void
heap2_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info & XLOG_HEAP_OPMASK)
{
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index d31dd56732d..ccfc71954f9 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -1017,7 +1017,7 @@ btree_xlog_reuse_page(XLogReaderState *record)
void
btree_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCtx;
oldCtx = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/rmgrdesc/brindesc.c b/src/backend/access/rmgrdesc/brindesc.c
index 9fc0bfe2a52..1be7c6dc927 100644
--- a/src/backend/access/rmgrdesc/brindesc.c
+++ b/src/backend/access/rmgrdesc/brindesc.c
@@ -20,7 +20,7 @@ void
brin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
info &= XLOG_BRIN_OPMASK;
if (info == XLOG_BRIN_CREATE_INDEX)
@@ -75,7 +75,7 @@ brin_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_BRIN_CREATE_INDEX:
id = "CREATE_INDEX";
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 41bf28dcfd0..11a4c38ca96 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -21,7 +21,7 @@ void
clog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == CLOG_ZEROPAGE)
{
@@ -45,7 +45,7 @@ clog_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case CLOG_ZEROPAGE:
id = "ZEROPAGE";
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index a6ab9dd78de..9204a9aea6c 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -21,7 +21,7 @@ void
commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == COMMIT_TS_ZEROPAGE)
{
diff --git a/src/backend/access/rmgrdesc/dbasedesc.c b/src/backend/access/rmgrdesc/dbasedesc.c
index 4224c5673ff..9be3cd873e5 100644
--- a/src/backend/access/rmgrdesc/dbasedesc.c
+++ b/src/backend/access/rmgrdesc/dbasedesc.c
@@ -22,7 +22,7 @@ void
dbase_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_DBASE_CREATE_FILE_COPY)
{
@@ -58,7 +58,7 @@ dbase_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_DBASE_CREATE_FILE_COPY:
id = "CREATE_FILE_COPY";
diff --git a/src/backend/access/rmgrdesc/gindesc.c b/src/backend/access/rmgrdesc/gindesc.c
index 723ff9499cf..1a54956d96d 100644
--- a/src/backend/access/rmgrdesc/gindesc.c
+++ b/src/backend/access/rmgrdesc/gindesc.c
@@ -72,7 +72,7 @@ void
gin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -181,7 +181,7 @@ gin_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_GIN_CREATE_PTREE:
id = "CREATE_PTREE";
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index a2b84e898f9..be67717ffe3 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -61,7 +61,7 @@ void
gist_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -91,7 +91,7 @@ gist_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_GIST_PAGE_UPDATE:
id = "PAGE_UPDATE";
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index 75f43a91520..6547b4619e5 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -20,7 +20,7 @@ void
hash_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -127,7 +127,7 @@ hash_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_HASH_INIT_META_PAGE:
id = "INIT_META_PAGE";
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 82b62c95de5..12a30099d95 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -184,7 +184,7 @@ void
heap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP_INSERT)
@@ -264,7 +264,7 @@ void
heap2_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
@@ -390,7 +390,7 @@ heap_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_HEAP_INSERT:
id = "INSERT";
@@ -435,7 +435,7 @@ heap2_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_HEAP2_PRUNE_ON_ACCESS:
id = "PRUNE_ON_ACCESS";
diff --git a/src/backend/access/rmgrdesc/logicalmsgdesc.c b/src/backend/access/rmgrdesc/logicalmsgdesc.c
index 1c8c99f19f8..d2112e02d2b 100644
--- a/src/backend/access/rmgrdesc/logicalmsgdesc.c
+++ b/src/backend/access/rmgrdesc/logicalmsgdesc.c
@@ -19,7 +19,7 @@ void
logicalmsg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_LOGICAL_MESSAGE)
{
@@ -45,7 +45,7 @@ logicalmsg_desc(StringInfo buf, XLogReaderState *record)
const char *
logicalmsg_identify(uint8 info)
{
- if ((info & ~XLR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
+ if ((info & XLR_RMGR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
return "MESSAGE";
return NULL;
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 3ca0582db36..d5a5ec4534c 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -50,7 +50,7 @@ void
multixact_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
@@ -85,7 +85,7 @@ multixact_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_MULTIXACT_ZERO_OFF_PAGE:
id = "ZERO_OFF_PAGE";
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index c05d19ab007..5cbf9473d5a 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -24,7 +24,7 @@ void
btree_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -140,7 +140,7 @@ btree_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_BTREE_INSERT_LEAF:
id = "INSERT_LEAF";
diff --git a/src/backend/access/rmgrdesc/relmapdesc.c b/src/backend/access/rmgrdesc/relmapdesc.c
index caf18460321..0ad32eb90f1 100644
--- a/src/backend/access/rmgrdesc/relmapdesc.c
+++ b/src/backend/access/rmgrdesc/relmapdesc.c
@@ -20,7 +20,7 @@ void
relmap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_RELMAP_UPDATE)
{
@@ -36,7 +36,7 @@ relmap_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_RELMAP_UPDATE:
id = "UPDATE";
diff --git a/src/backend/access/rmgrdesc/replorigindesc.c b/src/backend/access/rmgrdesc/replorigindesc.c
index 5dd74233996..9cf67673fe0 100644
--- a/src/backend/access/rmgrdesc/replorigindesc.c
+++ b/src/backend/access/rmgrdesc/replorigindesc.c
@@ -19,7 +19,7 @@ void
replorigin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/seqdesc.c b/src/backend/access/rmgrdesc/seqdesc.c
index 0d289d77fcf..6ba16f94f46 100644
--- a/src/backend/access/rmgrdesc/seqdesc.c
+++ b/src/backend/access/rmgrdesc/seqdesc.c
@@ -21,7 +21,7 @@ void
seq_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
xl_seq_rec *xlrec = (xl_seq_rec *) rec;
if (info == XLOG_SEQ_LOG)
@@ -35,7 +35,7 @@ seq_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_SEQ_LOG:
id = "LOG";
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index 4bb7fc79bce..a66415b4cab 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -21,7 +21,7 @@ void
smgr_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_SMGR_CREATE)
{
@@ -45,7 +45,7 @@ smgr_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_SMGR_CREATE:
id = "CREATE";
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 72efedc5b40..21d7ba63a4f 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -20,7 +20,7 @@ void
spg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -133,7 +133,7 @@ spg_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_SPGIST_ADD_LEAF:
id = "ADD_LEAF";
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 81eff5f31c4..588b0dec7ab 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -47,7 +47,7 @@ void
standby_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_STANDBY_LOCK)
{
@@ -80,7 +80,7 @@ standby_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_STANDBY_LOCK:
id = "LOCK";
diff --git a/src/backend/access/rmgrdesc/tblspcdesc.c b/src/backend/access/rmgrdesc/tblspcdesc.c
index 5d612b4232e..2066d8588ca 100644
--- a/src/backend/access/rmgrdesc/tblspcdesc.c
+++ b/src/backend/access/rmgrdesc/tblspcdesc.c
@@ -21,7 +21,7 @@ void
tblspc_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_TBLSPC_CREATE)
{
@@ -42,7 +42,7 @@ tblspc_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_TBLSPC_CREATE:
id = "CREATE";
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 58040f28656..77cc7b0e644 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -58,7 +58,7 @@ void
xlog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_CHECKPOINT_SHUTDOWN ||
info == XLOG_CHECKPOINT_ONLINE)
@@ -174,7 +174,7 @@ xlog_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_CHECKPOINT_SHUTDOWN:
id = "CHECKPOINT_SHUTDOWN";
diff --git a/src/backend/access/spgist/spgxlog.c b/src/backend/access/spgist/spgxlog.c
index b7986e6f713..6767f7598d5 100644
--- a/src/backend/access/spgist/spgxlog.c
+++ b/src/backend/access/spgist/spgxlog.c
@@ -934,7 +934,7 @@ spgRedoVacuumRedirect(XLogReaderState *record)
void
spg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCxt;
oldCxt = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 48f10bec91e..680052d58e2 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -1106,7 +1106,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
void
clog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in clog records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 113fae1437a..a278d0a0b8b 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -1015,7 +1015,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
void
commit_ts_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in commit_ts records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 3c06ac45532..0560a414ff5 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -3393,7 +3393,7 @@ WriteMTruncateXlogRec(Oid oldestMultiDB,
void
multixact_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in multixact records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 1914859b2ee..3165845ae12 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -766,7 +766,7 @@ XLogInsertRecord(XLogRecData *rdata,
pg_crc32c rdata_crc;
bool inserted;
XLogRecord *rechdr = (XLogRecord *) rdata->data;
- uint8 info = rechdr->xl_info & ~XLR_INFO_MASK;
+ uint8 info = rechdr->xl_info & XLR_RMGR_INFO_MASK;
WalInsertClass class = WALINSERT_NORMAL;
XLogRecPtr StartPos;
XLogRecPtr EndPos;
@@ -8422,7 +8422,7 @@ UpdateFullPageWrites(void)
void
xlog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
XLogRecPtr lsn = record->EndRecPtr;
/*
diff --git a/src/backend/access/transam/xlogprefetcher.c b/src/backend/access/transam/xlogprefetcher.c
index 7735562db01..4d9e7eaa1c5 100644
--- a/src/backend/access/transam/xlogprefetcher.c
+++ b/src/backend/access/transam/xlogprefetcher.c
@@ -530,7 +530,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
if (replaying_lsn < record->lsn)
{
uint8 rmid = record->header.xl_rmid;
- uint8 record_type = record->header.xl_info & ~XLR_INFO_MASK;
+ uint8 record_type = record->header.xl_info & XLR_RMGR_INFO_MASK;
if (rmid == RM_XLOG_ID)
{
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index 2790ade1f91..c087295a714 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -864,7 +864,7 @@ restart:
* Special processing if it's an XLOG SWITCH record
*/
if (record->xl_rmid == RM_XLOG_ID &&
- (record->xl_info & ~XLR_INFO_MASK) == XLOG_SWITCH)
+ (record->xl_info & XLR_RMGR_INFO_MASK) == XLOG_SWITCH)
{
/* Pretend it extends to end of segment */
state->NextRecPtr += state->segcxt.ws_segsize - 1;
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 6ce979f2d8b..724e4704c76 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -634,7 +634,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
if (record != NULL)
{
memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
- wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
+ wasShutdown = ((record->xl_info & XLR_RMGR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
ereport(DEBUG1,
(errmsg_internal("checkpoint record is at %X/%X",
LSN_FORMAT_ARGS(CheckPointLoc))));
@@ -802,7 +802,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
LSN_FORMAT_ARGS(CheckPointLoc))));
}
memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
- wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
+ wasShutdown = ((record->xl_info & XLR_RMGR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
}
if (ArchiveRecoveryRequested)
@@ -1720,7 +1720,7 @@ PerformWalRecovery(void)
* record.
*/
if (record->xl_rmid != RM_XLOG_ID ||
- (record->xl_info & ~XLR_INFO_MASK) != XLOG_CHECKPOINT_REDO)
+ (record->xl_info & XLR_RMGR_INFO_MASK) != XLOG_CHECKPOINT_REDO)
ereport(FATAL,
(errmsg("unexpected record type found at redo point %X/%X",
LSN_FORMAT_ARGS(xlogreader->ReadRecPtr))));
@@ -1942,7 +1942,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
{
TimeLineID newReplayTLI = *replayTLI;
TimeLineID prevReplayTLI = *replayTLI;
- uint8 info = record->xl_info & ~XLR_INFO_MASK;
+ uint8 info = record->xl_info & XLR_RMGR_INFO_MASK;
if (info == XLOG_CHECKPOINT_SHUTDOWN)
{
@@ -2080,7 +2080,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
static void
xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
XLogRecPtr lsn = record->EndRecPtr;
Assert(XLogRecGetRmid(record) == RM_XLOG_ID);
@@ -2316,7 +2316,7 @@ xlog_outdesc(StringInfo buf, XLogReaderState *record)
id = rmgr.rm_identify(info);
if (id == NULL)
- appendStringInfo(buf, "UNKNOWN (%X): ", info & ~XLR_INFO_MASK);
+ appendStringInfo(buf, "UNKNOWN (%X): ", info & XLR_RMGR_INFO_MASK);
else
appendStringInfo(buf, "%s: ", id);
@@ -2436,7 +2436,7 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
static bool
getRecordTimestamp(XLogReaderState *record, TimestampTz *recordXtime)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
uint8 xact_info = info & XLOG_XACT_OPMASK;
uint8 rmid = XLogRecGetRmid(record);
@@ -2748,7 +2748,7 @@ recoveryStopsAfter(XLogReaderState *record)
if (!ArchiveRecoveryRequested)
return false;
- info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
rmid = XLogRecGetRmid(record);
/*
@@ -4098,7 +4098,7 @@ ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
(errmsg("invalid resource manager ID in checkpoint record")));
return NULL;
}
- info = record->xl_info & ~XLR_INFO_MASK;
+ info = record->xl_info & XLR_RMGR_INFO_MASK;
if (info != XLOG_CHECKPOINT_SHUTDOWN &&
info != XLOG_CHECKPOINT_ONLINE)
{
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index 227df90f89c..9ce4da7f32a 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -981,7 +981,7 @@ void
smgr_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in smgr records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 5fbbcdaabb1..02797ed87a5 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -3283,7 +3283,7 @@ recovery_create_dbdir(char *path, bool only_tblspc)
void
dbase_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in dbase records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 451ae6f7f69..c81a5c18cd0 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1890,7 +1890,7 @@ void
seq_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
Buffer buffer;
Page page;
Page localpage;
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index a9005cc7212..52600f155c9 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -1510,7 +1510,7 @@ get_tablespace_name(Oid spc_oid)
void
tblspc_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in tblspc records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c
index 0fec4f1f871..6dec1050a8a 100644
--- a/src/backend/postmaster/walsummarizer.c
+++ b/src/backend/postmaster/walsummarizer.c
@@ -1248,7 +1248,7 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact,
static void
SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
/*
* We use relfilenode zero for a given database OID and tablespace OID to
@@ -1317,7 +1317,7 @@ SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
if (info == XLOG_SMGR_CREATE)
{
@@ -1366,7 +1366,7 @@ SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
uint8 xact_info = info & XLOG_XACT_OPMASK;
if (xact_info == XLOG_XACT_COMMIT ||
@@ -1426,7 +1426,7 @@ SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static bool
SummarizeXlogRecord(XLogReaderState *xlogreader, bool *new_fast_forward)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
int record_wal_level;
if (info == XLOG_CHECKPOINT_REDO)
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index cc03f0706e9..c87fb8f8c97 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -129,7 +129,7 @@ void
xlog_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
- uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(buf->record) & XLR_RMGR_INFO_MASK;
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record),
buf->origptr);
@@ -360,7 +360,7 @@ standby_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
- uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr);
@@ -597,7 +597,7 @@ logicalmsg_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
TransactionId xid = XLogRecGetXid(r);
- uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
RepOriginId origin_id = XLogRecGetOrigin(r);
Snapshot snapshot = NULL;
xl_logical_message *message;
diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c
index ebc8454bad9..10d60880195 100644
--- a/src/backend/replication/logical/message.c
+++ b/src/backend/replication/logical/message.c
@@ -86,7 +86,7 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size,
void
logicalmsg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info != XLOG_LOGICAL_MESSAGE)
elog(PANIC, "logicalmsg_redo: unknown op code %u", info);
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index a17bacf88e7..4a8fa5abc3e 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -849,7 +849,7 @@ StartupReplicationOrigin(void)
void
replorigin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 7fa8d9247e0..5e4f914f4f0 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1162,7 +1162,7 @@ StandbyReleaseOldLocks(TransactionId oldxid)
void
standby_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in standby records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
index abf89f0776e..0e35ab8b57c 100644
--- a/src/backend/utils/cache/relmapper.c
+++ b/src/backend/utils/cache/relmapper.c
@@ -1095,7 +1095,7 @@ perform_relmap_update(bool shared, const RelMapFile *updates)
void
relmap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in relmap records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 2cd44625ca3..9bfd6ea325b 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -243,7 +243,7 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex,
* be the latest checkpoint before WAL forked and not the checkpoint
* where the primary has been stopped to be rewound.
*/
- info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
if (searchptr < forkptr &&
XLogRecGetRmid(xlogreader) == RM_XLOG_ID &&
(info == XLOG_CHECKPOINT_SHUTDOWN ||
@@ -391,7 +391,7 @@ extractPageInfo(XLogReaderState *record)
int block_id;
RmgrId rmid = XLogRecGetRmid(record);
uint8 info = XLogRecGetInfo(record);
- uint8 rminfo = info & ~XLR_INFO_MASK;
+ uint8 rminfo = info & XLR_RMGR_INFO_MASK;
/* Is this a special record type that I recognize? */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 51fb76efc48..e0c98380b47 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -564,7 +564,7 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
id = desc->rm_identify(info);
if (id == NULL)
- printf("desc: UNKNOWN (%x) ", info & ~XLR_INFO_MASK);
+ printf("desc: UNKNOWN (%x) ", info & XLR_RMGR_INFO_MASK);
else
printf("desc: %s ", id);
diff --git a/src/include/access/xlogrecord.h b/src/include/access/xlogrecord.h
index a06833ce0a3..366b622cc15 100644
--- a/src/include/access/xlogrecord.h
+++ b/src/include/access/xlogrecord.h
@@ -59,7 +59,6 @@ typedef struct XLogRecord
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
-#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0
/*
diff --git a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
index 1a424ad55a8..5ecb4970be7 100644
--- a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
+++ b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
@@ -81,7 +81,7 @@ _PG_init(void)
void
testcustomrmgrs_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info != XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
elog(PANIC, "testcustomrmgrs_redo: unknown op code %u", info);
@@ -91,7 +91,7 @@ void
testcustomrmgrs_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
{
@@ -105,7 +105,7 @@ testcustomrmgrs_desc(StringInfo buf, XLogReaderState *record)
const char *
testcustomrmgrs_identify(uint8 info)
{
- if ((info & ~XLR_INFO_MASK) == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
+ if ((info & XLR_RMGR_INFO_MASK) == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
return "TEST_CUSTOM_RMGRS_MESSAGE";
return NULL;
--
2.39.5 (Apple Git-154)
Hi,
I like the idea of your change as it saves me out of converting-in-my-mind.
And I suggest to create a macro to do this job.
#define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)
Then the code can become:
XLogRecGetInfo(record) & ~XLR_INFO_MASK;
-->
getRmgrInfo(XLogRecGetInfo(record));
Thanks,
Steven
在 2025/6/9 14:23, Xiaoran Wang 写道:
Show quoted text
Hi,
I refactored the code of extracting XLogRecord info.
In XLogRecord, the high 4 bits in xl_info is used by rmgr.typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record *//* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no
padding */} XLogRecord;
I found lots of the code to get the info as below
XLogRecGetInfo(record) & ~XLR_INFO_MASK
Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F), which is easier to understand.
Remove XLR_INFO_MASK as it is not used any more.--
Best regards !
Xiaoran Wang
HI
And I suggest to create a macro to do this job.
#define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)Then the code can become:
XLogRecGetInfo(record) & ~XLR_INFO_MASK;
-->
getRmgrInfo(XLogRecGetInfo(record))
+1 Agreed, this makes the code more readable.
Thanks
On Mon, Jun 9, 2025 at 2:46 PM Steven Niu <niushiji@gmail.com> wrote:
Show quoted text
Hi,
I like the idea of your change as it saves me out of converting-in-my-mind.
And I suggest to create a macro to do this job.
#define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)Then the code can become:
XLogRecGetInfo(record) & ~XLR_INFO_MASK;
-->
getRmgrInfo(XLogRecGetInfo(record));Thanks,
Steven在 2025/6/9 14:23, Xiaoran Wang 写道:
Hi,
I refactored the code of extracting XLogRecord info.
In XLogRecord, the high 4 bits in xl_info is used by rmgr.typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record *//* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no
padding */} XLogRecord;
I found lots of the code to get the info as below
XLogRecGetInfo(record) & ~XLR_INFO_MASK
Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F), which is easier to understand.
Remove XLR_INFO_MASK as it is not used any more.--
Best regards !
Xiaoran Wang
Steven Niu <niushiji@gmail.com> 于2025年6月9日周一 14:46写道:
Hi,
I like the idea of your change as it saves me out of converting-in-my-mind.
And I suggest to create a macro to do this job.
#define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)Then the code can become:
XLogRecGetInfo(record) & ~XLR_INFO_MASK;
-->
getRmgrInfo(XLogRecGetInfo(record));
Good idea, found lots of 'XLogRecGetInfo(record) & ~XLR_INFO_MASK;'
in the code.
I add a macro XLogRecRmgrGetInfo(record) in patch 0002.
Thanks,
Steven在 2025/6/9 14:23, Xiaoran Wang 写道:
Hi,
I refactored the code of extracting XLogRecord info.
In XLogRecord, the high 4 bits in xl_info is used by rmgr.typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record *//* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no
padding */} XLogRecord;
I found lots of the code to get the info as below
XLogRecGetInfo(record) & ~XLR_INFO_MASK
Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F), which is easier to understand.
Remove XLR_INFO_MASK as it is not used any more.--
Best regards !
Xiaoran Wang
--
Best regards !
Xiaoran Wang
Attachments:
0002-Add-a-macro-XLogRecGetRmgrInfo.patchapplication/octet-stream; name=0002-Add-a-macro-XLogRecGetRmgrInfo.patchDownload
From 4f9c95988f11c2876e87b3591ff044924ca5b626 Mon Sep 17 00:00:00 2001
From: wangxiaoran <fanfuxiaoran@gmail.com>
Date: Mon, 9 Jun 2025 17:35:33 +0800
Subject: [PATCH 2/2] Add a macro XLogRecGetRmgrInfo
Since there are many instances of code like
'(XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK)',
we should add the macro 'XLogRecGetRmgrInfo' to encapsulate this operation.
---
contrib/pg_walinspect/pg_walinspect.c | 4 ++--
src/backend/access/brin/brin_xlog.c | 2 +-
src/backend/access/gin/ginxlog.c | 2 +-
src/backend/access/gist/gistxlog.c | 2 +-
src/backend/access/hash/hash_xlog.c | 2 +-
src/backend/access/heap/heapam_xlog.c | 4 ++--
src/backend/access/nbtree/nbtxlog.c | 2 +-
src/backend/access/rmgrdesc/brindesc.c | 2 +-
src/backend/access/rmgrdesc/clogdesc.c | 2 +-
src/backend/access/rmgrdesc/committsdesc.c | 2 +-
src/backend/access/rmgrdesc/dbasedesc.c | 2 +-
src/backend/access/rmgrdesc/gindesc.c | 2 +-
src/backend/access/rmgrdesc/gistdesc.c | 2 +-
src/backend/access/rmgrdesc/hashdesc.c | 2 +-
src/backend/access/rmgrdesc/heapdesc.c | 4 ++--
src/backend/access/rmgrdesc/logicalmsgdesc.c | 2 +-
src/backend/access/rmgrdesc/mxactdesc.c | 2 +-
src/backend/access/rmgrdesc/nbtdesc.c | 2 +-
src/backend/access/rmgrdesc/relmapdesc.c | 2 +-
src/backend/access/rmgrdesc/replorigindesc.c | 2 +-
src/backend/access/rmgrdesc/seqdesc.c | 2 +-
src/backend/access/rmgrdesc/smgrdesc.c | 2 +-
src/backend/access/rmgrdesc/spgdesc.c | 2 +-
src/backend/access/rmgrdesc/standbydesc.c | 2 +-
src/backend/access/rmgrdesc/tblspcdesc.c | 2 +-
src/backend/access/rmgrdesc/xlogdesc.c | 2 +-
src/backend/access/spgist/spgxlog.c | 2 +-
src/backend/access/transam/clog.c | 2 +-
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 2 +-
src/backend/access/transam/xlog.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 6 +++---
src/backend/catalog/storage.c | 2 +-
src/backend/commands/dbcommands.c | 2 +-
src/backend/commands/sequence.c | 2 +-
src/backend/commands/tablespace.c | 2 +-
src/backend/postmaster/walsummarizer.c | 8 ++++----
src/backend/replication/logical/decode.c | 6 +++---
src/backend/replication/logical/message.c | 2 +-
src/backend/replication/logical/origin.c | 2 +-
src/backend/storage/ipc/standby.c | 2 +-
src/backend/utils/cache/relmapper.c | 2 +-
src/bin/pg_rewind/parsexlog.c | 2 +-
src/include/access/xlogreader.h | 2 ++
src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c | 4 ++--
45 files changed, 57 insertions(+), 55 deletions(-)
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c
index e07d0d6ce99..98930757827 100644
--- a/contrib/pg_walinspect/pg_walinspect.c
+++ b/contrib/pg_walinspect/pg_walinspect.c
@@ -203,7 +203,7 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values,
record_type = desc.rm_identify(XLogRecGetInfo(record));
if (record_type == NULL)
- record_type = psprintf("UNKNOWN (%x)", XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK);
+ record_type = psprintf("UNKNOWN (%x)", XLogRecGetRmgrInfo(record));
initStringInfo(&rec_desc);
desc.rm_desc(&rec_desc, record);
@@ -266,7 +266,7 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record,
if (record_type == NULL)
record_type = psprintf("UNKNOWN (%x)",
- XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK);
+ XLogRecGetRmgrInfo(record));
initStringInfo(&rec_desc);
desc.rm_desc(&rec_desc, record);
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c
index c9b91a15b46..5a2cc38e0e0 100644
--- a/src/backend/access/brin/brin_xlog.c
+++ b/src/backend/access/brin/brin_xlog.c
@@ -308,7 +308,7 @@ brin_xlog_desummarize_page(XLogReaderState *record)
void
brin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info & XLOG_BRIN_OPMASK)
{
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 7b2ec5a0429..1fd53a8679e 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -725,7 +725,7 @@ ginRedoDeleteListPages(XLogReaderState *record)
void
gin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCtx;
/*
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
index 1b382848a12..63f49fe887c 100644
--- a/src/backend/access/gist/gistxlog.c
+++ b/src/backend/access/gist/gistxlog.c
@@ -396,7 +396,7 @@ gistRedoPageReuse(XLogReaderState *record)
void
gist_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCxt;
/*
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index 9df486a564b..335f484a8b3 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -1066,7 +1066,7 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
void
hash_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/heap/heapam_xlog.c b/src/backend/access/heap/heapam_xlog.c
index 29e87ccc8d8..0b1751a39a8 100644
--- a/src/backend/access/heap/heapam_xlog.c
+++ b/src/backend/access/heap/heapam_xlog.c
@@ -1181,7 +1181,7 @@ heap_xlog_inplace(XLogReaderState *record)
void
heap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/*
* These operations don't overwrite MVCC data so no conflict processing is
@@ -1227,7 +1227,7 @@ heap_redo(XLogReaderState *record)
void
heap2_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info & XLOG_HEAP_OPMASK)
{
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index ccfc71954f9..441bf942f8b 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -1017,7 +1017,7 @@ btree_xlog_reuse_page(XLogReaderState *record)
void
btree_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCtx;
oldCtx = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/rmgrdesc/brindesc.c b/src/backend/access/rmgrdesc/brindesc.c
index 1be7c6dc927..27699e313b0 100644
--- a/src/backend/access/rmgrdesc/brindesc.c
+++ b/src/backend/access/rmgrdesc/brindesc.c
@@ -20,7 +20,7 @@ void
brin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
info &= XLOG_BRIN_OPMASK;
if (info == XLOG_BRIN_CREATE_INDEX)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 11a4c38ca96..26c8ce27a7e 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -21,7 +21,7 @@ void
clog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == CLOG_ZEROPAGE)
{
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 9204a9aea6c..329f4e3613f 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -21,7 +21,7 @@ void
commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == COMMIT_TS_ZEROPAGE)
{
diff --git a/src/backend/access/rmgrdesc/dbasedesc.c b/src/backend/access/rmgrdesc/dbasedesc.c
index 9be3cd873e5..2e0ad6478fe 100644
--- a/src/backend/access/rmgrdesc/dbasedesc.c
+++ b/src/backend/access/rmgrdesc/dbasedesc.c
@@ -22,7 +22,7 @@ void
dbase_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_DBASE_CREATE_FILE_COPY)
{
diff --git a/src/backend/access/rmgrdesc/gindesc.c b/src/backend/access/rmgrdesc/gindesc.c
index 1a54956d96d..e2095f231dd 100644
--- a/src/backend/access/rmgrdesc/gindesc.c
+++ b/src/backend/access/rmgrdesc/gindesc.c
@@ -72,7 +72,7 @@ void
gin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index be67717ffe3..ff463ffdbef 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -61,7 +61,7 @@ void
gist_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index 6547b4619e5..32b80a2fc5a 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -20,7 +20,7 @@ void
hash_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 12a30099d95..0e920e838af 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -184,7 +184,7 @@ void
heap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP_INSERT)
@@ -264,7 +264,7 @@ void
heap2_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
diff --git a/src/backend/access/rmgrdesc/logicalmsgdesc.c b/src/backend/access/rmgrdesc/logicalmsgdesc.c
index d2112e02d2b..527f02592e4 100644
--- a/src/backend/access/rmgrdesc/logicalmsgdesc.c
+++ b/src/backend/access/rmgrdesc/logicalmsgdesc.c
@@ -19,7 +19,7 @@ void
logicalmsg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_LOGICAL_MESSAGE)
{
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index d5a5ec4534c..fa3a4b0e737 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -50,7 +50,7 @@ void
multixact_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 5cbf9473d5a..1f5905f7e3c 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -24,7 +24,7 @@ void
btree_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/relmapdesc.c b/src/backend/access/rmgrdesc/relmapdesc.c
index 0ad32eb90f1..56f108ecd2d 100644
--- a/src/backend/access/rmgrdesc/relmapdesc.c
+++ b/src/backend/access/rmgrdesc/relmapdesc.c
@@ -20,7 +20,7 @@ void
relmap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_RELMAP_UPDATE)
{
diff --git a/src/backend/access/rmgrdesc/replorigindesc.c b/src/backend/access/rmgrdesc/replorigindesc.c
index 9cf67673fe0..2abea74849e 100644
--- a/src/backend/access/rmgrdesc/replorigindesc.c
+++ b/src/backend/access/rmgrdesc/replorigindesc.c
@@ -19,7 +19,7 @@ void
replorigin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/seqdesc.c b/src/backend/access/rmgrdesc/seqdesc.c
index 6ba16f94f46..dbf7559c04e 100644
--- a/src/backend/access/rmgrdesc/seqdesc.c
+++ b/src/backend/access/rmgrdesc/seqdesc.c
@@ -21,7 +21,7 @@ void
seq_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
xl_seq_rec *xlrec = (xl_seq_rec *) rec;
if (info == XLOG_SEQ_LOG)
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index a66415b4cab..9b6f58a592b 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -21,7 +21,7 @@ void
smgr_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_SMGR_CREATE)
{
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 21d7ba63a4f..3acbff6e2e8 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -20,7 +20,7 @@ void
spg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 588b0dec7ab..b30e66e003c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -47,7 +47,7 @@ void
standby_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_STANDBY_LOCK)
{
diff --git a/src/backend/access/rmgrdesc/tblspcdesc.c b/src/backend/access/rmgrdesc/tblspcdesc.c
index 2066d8588ca..9e86a8a7ce1 100644
--- a/src/backend/access/rmgrdesc/tblspcdesc.c
+++ b/src/backend/access/rmgrdesc/tblspcdesc.c
@@ -21,7 +21,7 @@ void
tblspc_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_TBLSPC_CREATE)
{
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 77cc7b0e644..6d2753d92ac 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -58,7 +58,7 @@ void
xlog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_CHECKPOINT_SHUTDOWN ||
info == XLOG_CHECKPOINT_ONLINE)
diff --git a/src/backend/access/spgist/spgxlog.c b/src/backend/access/spgist/spgxlog.c
index 6767f7598d5..8a4fdcf2a68 100644
--- a/src/backend/access/spgist/spgxlog.c
+++ b/src/backend/access/spgist/spgxlog.c
@@ -934,7 +934,7 @@ spgRedoVacuumRedirect(XLogReaderState *record)
void
spg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCxt;
oldCxt = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 680052d58e2..717c7885f53 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -1106,7 +1106,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
void
clog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in clog records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index a278d0a0b8b..26918d21337 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -1015,7 +1015,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
void
commit_ts_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in commit_ts records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 0560a414ff5..98f31a609ed 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -3393,7 +3393,7 @@ WriteMTruncateXlogRec(Oid oldestMultiDB,
void
multixact_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in multixact records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3165845ae12..5ae6fae49c4 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8422,7 +8422,7 @@ UpdateFullPageWrites(void)
void
xlog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
XLogRecPtr lsn = record->EndRecPtr;
/*
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 724e4704c76..c7be958dd55 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2080,7 +2080,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
static void
xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
XLogRecPtr lsn = record->EndRecPtr;
Assert(XLogRecGetRmid(record) == RM_XLOG_ID);
@@ -2436,7 +2436,7 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
static bool
getRecordTimestamp(XLogReaderState *record, TimestampTz *recordXtime)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
uint8 xact_info = info & XLOG_XACT_OPMASK;
uint8 rmid = XLogRecGetRmid(record);
@@ -2748,7 +2748,7 @@ recoveryStopsAfter(XLogReaderState *record)
if (!ArchiveRecoveryRequested)
return false;
- info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ info = XLogRecGetRmgrInfo(record);
rmid = XLogRecGetRmid(record);
/*
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index 9ce4da7f32a..0ba97b2ba31 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -981,7 +981,7 @@ void
smgr_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in smgr records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 02797ed87a5..e1313c01ab1 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -3283,7 +3283,7 @@ recovery_create_dbdir(char *path, bool only_tblspc)
void
dbase_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in dbase records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index c81a5c18cd0..80e952f15b1 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1890,7 +1890,7 @@ void
seq_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
Buffer buffer;
Page page;
Page localpage;
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 52600f155c9..56b226ad03e 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -1510,7 +1510,7 @@ get_tablespace_name(Oid spc_oid)
void
tblspc_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in tblspc records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c
index 6dec1050a8a..d8aff2b8db1 100644
--- a/src/backend/postmaster/walsummarizer.c
+++ b/src/backend/postmaster/walsummarizer.c
@@ -1248,7 +1248,7 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact,
static void
SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
/*
* We use relfilenode zero for a given database OID and tablespace OID to
@@ -1317,7 +1317,7 @@ SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
if (info == XLOG_SMGR_CREATE)
{
@@ -1366,7 +1366,7 @@ SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
uint8 xact_info = info & XLOG_XACT_OPMASK;
if (xact_info == XLOG_XACT_COMMIT ||
@@ -1426,7 +1426,7 @@ SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static bool
SummarizeXlogRecord(XLogReaderState *xlogreader, bool *new_fast_forward)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
int record_wal_level;
if (info == XLOG_CHECKPOINT_REDO)
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index c87fb8f8c97..93b69c3c530 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -129,7 +129,7 @@ void
xlog_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
- uint8 info = XLogRecGetInfo(buf->record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(buf->record);
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record),
buf->origptr);
@@ -360,7 +360,7 @@ standby_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
- uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(r);
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr);
@@ -597,7 +597,7 @@ logicalmsg_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
TransactionId xid = XLogRecGetXid(r);
- uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(r);
RepOriginId origin_id = XLogRecGetOrigin(r);
Snapshot snapshot = NULL;
xl_logical_message *message;
diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c
index 10d60880195..31f5bec0e3d 100644
--- a/src/backend/replication/logical/message.c
+++ b/src/backend/replication/logical/message.c
@@ -86,7 +86,7 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size,
void
logicalmsg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info != XLOG_LOGICAL_MESSAGE)
elog(PANIC, "logicalmsg_redo: unknown op code %u", info);
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 4a8fa5abc3e..2c61da04a52 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -849,7 +849,7 @@ StartupReplicationOrigin(void)
void
replorigin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 5e4f914f4f0..388f6882f2c 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1162,7 +1162,7 @@ StandbyReleaseOldLocks(TransactionId oldxid)
void
standby_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in standby records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
index 0e35ab8b57c..116d314eb9b 100644
--- a/src/backend/utils/cache/relmapper.c
+++ b/src/backend/utils/cache/relmapper.c
@@ -1095,7 +1095,7 @@ perform_relmap_update(bool shared, const RelMapFile *updates)
void
relmap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in relmap records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 9bfd6ea325b..b0b2fdfafdd 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -243,7 +243,7 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex,
* be the latest checkpoint before WAL forked and not the checkpoint
* where the primary has been stopped to be rewound.
*/
- info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ info = XLogRecGetRmgrInfo(xlogreader);
if (searchptr < forkptr &&
XLogRecGetRmid(xlogreader) == RM_XLOG_ID &&
(info == XLOG_CHECKPOINT_SHUTDOWN ||
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h
index 9738462d3c9..0522854f434 100644
--- a/src/include/access/xlogreader.h
+++ b/src/include/access/xlogreader.h
@@ -408,6 +408,8 @@ extern bool DecodeXLogRecord(XLogReaderState *state,
#define XLogRecGetTotalLen(decoder) ((decoder)->record->header.xl_tot_len)
#define XLogRecGetPrev(decoder) ((decoder)->record->header.xl_prev)
#define XLogRecGetInfo(decoder) ((decoder)->record->header.xl_info)
+#define XLogRecGetRmgrInfo(decoder) ((decoder)->record->header.xl_info \
+ & XLR_RMGR_INFO_MASK)
#define XLogRecGetRmid(decoder) ((decoder)->record->header.xl_rmid)
#define XLogRecGetXid(decoder) ((decoder)->record->header.xl_xid)
#define XLogRecGetOrigin(decoder) ((decoder)->record->record_origin)
diff --git a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
index 5ecb4970be7..6d8a3f88017 100644
--- a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
+++ b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
@@ -81,7 +81,7 @@ _PG_init(void)
void
testcustomrmgrs_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info != XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
elog(PANIC, "testcustomrmgrs_redo: unknown op code %u", info);
@@ -91,7 +91,7 @@ void
testcustomrmgrs_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
{
--
2.39.5 (Apple Git-154)
Just upload all the patches together.
Xiaoran Wang <fanfuxiaoran@gmail.com> 于2025年6月9日周一 18:25写道:
Steven Niu <niushiji@gmail.com> 于2025年6月9日周一 14:46写道:
Hi,
I like the idea of your change as it saves me out of
converting-in-my-mind.And I suggest to create a macro to do this job.
#define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)Then the code can become:
XLogRecGetInfo(record) & ~XLR_INFO_MASK;
-->
getRmgrInfo(XLogRecGetInfo(record));Good idea, found lots of 'XLogRecGetInfo(record) & ~XLR_INFO_MASK;'
in the code.I add a macro XLogRecRmgrGetInfo(record) in patch 0002.
Thanks,
Steven在 2025/6/9 14:23, Xiaoran Wang 写道:
Hi,
I refactored the code of extracting XLogRecord info.
In XLogRecord, the high 4 bits in xl_info is used by rmgr.typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record *//* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no
padding */} XLogRecord;
I found lots of the code to get the info as below
XLogRecGetInfo(record) & ~XLR_INFO_MASK
Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F), which is easier to understand.
Remove XLR_INFO_MASK as it is not used any more.--
Best regards !
Xiaoran Wang--
Best regards !
Xiaoran Wang
--
Best regards !
Xiaoran Wang
Attachments:
0001-Refactor-Extract-XLogRecord-info.patchapplication/octet-stream; name=0001-Refactor-Extract-XLogRecord-info.patchDownload
From aef095441a0c320855cb69b754af986a37a0b119 Mon Sep 17 00:00:00 2001
From: wangxiaoran <fanfuxiaoran@gmail.com>
Date: Wed, 4 Jun 2025 14:27:03 +0800
Subject: [PATCH] Refactor: Extract XLogRecord info
In XLogRecord, the high 4 bits in xl_info is used by rmgr.
To extract the info, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F)
Remove XLR_INFO_MASK as it is not used any more.
---
contrib/pg_walinspect/pg_walinspect.c | 4 ++--
src/backend/access/brin/brin_xlog.c | 2 +-
src/backend/access/gin/ginxlog.c | 2 +-
src/backend/access/gist/gistxlog.c | 2 +-
src/backend/access/hash/hash_xlog.c | 2 +-
src/backend/access/heap/heapam_xlog.c | 4 ++--
src/backend/access/nbtree/nbtxlog.c | 2 +-
src/backend/access/rmgrdesc/brindesc.c | 4 ++--
src/backend/access/rmgrdesc/clogdesc.c | 4 ++--
src/backend/access/rmgrdesc/committsdesc.c | 2 +-
src/backend/access/rmgrdesc/dbasedesc.c | 4 ++--
src/backend/access/rmgrdesc/gindesc.c | 4 ++--
src/backend/access/rmgrdesc/gistdesc.c | 4 ++--
src/backend/access/rmgrdesc/hashdesc.c | 4 ++--
src/backend/access/rmgrdesc/heapdesc.c | 8 ++++----
src/backend/access/rmgrdesc/logicalmsgdesc.c | 4 ++--
src/backend/access/rmgrdesc/mxactdesc.c | 4 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 4 ++--
src/backend/access/rmgrdesc/relmapdesc.c | 4 ++--
src/backend/access/rmgrdesc/replorigindesc.c | 2 +-
src/backend/access/rmgrdesc/seqdesc.c | 4 ++--
src/backend/access/rmgrdesc/smgrdesc.c | 4 ++--
src/backend/access/rmgrdesc/spgdesc.c | 4 ++--
src/backend/access/rmgrdesc/standbydesc.c | 4 ++--
src/backend/access/rmgrdesc/tblspcdesc.c | 4 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 4 ++--
src/backend/access/spgist/spgxlog.c | 2 +-
src/backend/access/transam/clog.c | 2 +-
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 2 +-
src/backend/access/transam/xlog.c | 4 ++--
src/backend/access/transam/xlogprefetcher.c | 2 +-
src/backend/access/transam/xlogreader.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 18 +++++++++---------
src/backend/catalog/storage.c | 2 +-
src/backend/commands/dbcommands.c | 2 +-
src/backend/commands/sequence.c | 2 +-
src/backend/commands/tablespace.c | 2 +-
src/backend/postmaster/walsummarizer.c | 8 ++++----
src/backend/replication/logical/decode.c | 6 +++---
src/backend/replication/logical/message.c | 2 +-
src/backend/replication/logical/origin.c | 2 +-
src/backend/storage/ipc/standby.c | 2 +-
src/backend/utils/cache/relmapper.c | 2 +-
src/bin/pg_rewind/parsexlog.c | 4 ++--
src/bin/pg_waldump/pg_waldump.c | 2 +-
src/include/access/xlogrecord.h | 1 -
.../test_custom_rmgrs/test_custom_rmgrs.c | 6 +++---
48 files changed, 85 insertions(+), 86 deletions(-)
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c
index 64745564cc2..e07d0d6ce99 100644
--- a/contrib/pg_walinspect/pg_walinspect.c
+++ b/contrib/pg_walinspect/pg_walinspect.c
@@ -203,7 +203,7 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values,
record_type = desc.rm_identify(XLogRecGetInfo(record));
if (record_type == NULL)
- record_type = psprintf("UNKNOWN (%x)", XLogRecGetInfo(record) & ~XLR_INFO_MASK);
+ record_type = psprintf("UNKNOWN (%x)", XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK);
initStringInfo(&rec_desc);
desc.rm_desc(&rec_desc, record);
@@ -266,7 +266,7 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record,
if (record_type == NULL)
record_type = psprintf("UNKNOWN (%x)",
- XLogRecGetInfo(record) & ~XLR_INFO_MASK);
+ XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK);
initStringInfo(&rec_desc);
desc.rm_desc(&rec_desc, record);
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c
index 85db2f0fd5a..c9b91a15b46 100644
--- a/src/backend/access/brin/brin_xlog.c
+++ b/src/backend/access/brin/brin_xlog.c
@@ -308,7 +308,7 @@ brin_xlog_desummarize_page(XLogReaderState *record)
void
brin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info & XLOG_BRIN_OPMASK)
{
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 55a1ec09776..7b2ec5a0429 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -725,7 +725,7 @@ ginRedoDeleteListPages(XLogReaderState *record)
void
gin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCtx;
/*
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
index b354e4ba5d1..1b382848a12 100644
--- a/src/backend/access/gist/gistxlog.c
+++ b/src/backend/access/gist/gistxlog.c
@@ -396,7 +396,7 @@ gistRedoPageReuse(XLogReaderState *record)
void
gist_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCxt;
/*
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index 8d97067fe54..9df486a564b 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -1066,7 +1066,7 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
void
hash_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
diff --git a/src/backend/access/heap/heapam_xlog.c b/src/backend/access/heap/heapam_xlog.c
index 30f4c2d3c67..29e87ccc8d8 100644
--- a/src/backend/access/heap/heapam_xlog.c
+++ b/src/backend/access/heap/heapam_xlog.c
@@ -1181,7 +1181,7 @@ heap_xlog_inplace(XLogReaderState *record)
void
heap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/*
* These operations don't overwrite MVCC data so no conflict processing is
@@ -1227,7 +1227,7 @@ heap_redo(XLogReaderState *record)
void
heap2_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info & XLOG_HEAP_OPMASK)
{
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index d31dd56732d..ccfc71954f9 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -1017,7 +1017,7 @@ btree_xlog_reuse_page(XLogReaderState *record)
void
btree_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCtx;
oldCtx = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/rmgrdesc/brindesc.c b/src/backend/access/rmgrdesc/brindesc.c
index 9fc0bfe2a52..1be7c6dc927 100644
--- a/src/backend/access/rmgrdesc/brindesc.c
+++ b/src/backend/access/rmgrdesc/brindesc.c
@@ -20,7 +20,7 @@ void
brin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
info &= XLOG_BRIN_OPMASK;
if (info == XLOG_BRIN_CREATE_INDEX)
@@ -75,7 +75,7 @@ brin_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_BRIN_CREATE_INDEX:
id = "CREATE_INDEX";
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 41bf28dcfd0..11a4c38ca96 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -21,7 +21,7 @@ void
clog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == CLOG_ZEROPAGE)
{
@@ -45,7 +45,7 @@ clog_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case CLOG_ZEROPAGE:
id = "ZEROPAGE";
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index a6ab9dd78de..9204a9aea6c 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -21,7 +21,7 @@ void
commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == COMMIT_TS_ZEROPAGE)
{
diff --git a/src/backend/access/rmgrdesc/dbasedesc.c b/src/backend/access/rmgrdesc/dbasedesc.c
index 4224c5673ff..9be3cd873e5 100644
--- a/src/backend/access/rmgrdesc/dbasedesc.c
+++ b/src/backend/access/rmgrdesc/dbasedesc.c
@@ -22,7 +22,7 @@ void
dbase_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_DBASE_CREATE_FILE_COPY)
{
@@ -58,7 +58,7 @@ dbase_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_DBASE_CREATE_FILE_COPY:
id = "CREATE_FILE_COPY";
diff --git a/src/backend/access/rmgrdesc/gindesc.c b/src/backend/access/rmgrdesc/gindesc.c
index 723ff9499cf..1a54956d96d 100644
--- a/src/backend/access/rmgrdesc/gindesc.c
+++ b/src/backend/access/rmgrdesc/gindesc.c
@@ -72,7 +72,7 @@ void
gin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -181,7 +181,7 @@ gin_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_GIN_CREATE_PTREE:
id = "CREATE_PTREE";
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index a2b84e898f9..be67717ffe3 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -61,7 +61,7 @@ void
gist_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -91,7 +91,7 @@ gist_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_GIST_PAGE_UPDATE:
id = "PAGE_UPDATE";
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index 75f43a91520..6547b4619e5 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -20,7 +20,7 @@ void
hash_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -127,7 +127,7 @@ hash_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_HASH_INIT_META_PAGE:
id = "INIT_META_PAGE";
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 82b62c95de5..12a30099d95 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -184,7 +184,7 @@ void
heap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP_INSERT)
@@ -264,7 +264,7 @@ void
heap2_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
@@ -390,7 +390,7 @@ heap_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_HEAP_INSERT:
id = "INSERT";
@@ -435,7 +435,7 @@ heap2_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_HEAP2_PRUNE_ON_ACCESS:
id = "PRUNE_ON_ACCESS";
diff --git a/src/backend/access/rmgrdesc/logicalmsgdesc.c b/src/backend/access/rmgrdesc/logicalmsgdesc.c
index 1c8c99f19f8..d2112e02d2b 100644
--- a/src/backend/access/rmgrdesc/logicalmsgdesc.c
+++ b/src/backend/access/rmgrdesc/logicalmsgdesc.c
@@ -19,7 +19,7 @@ void
logicalmsg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_LOGICAL_MESSAGE)
{
@@ -45,7 +45,7 @@ logicalmsg_desc(StringInfo buf, XLogReaderState *record)
const char *
logicalmsg_identify(uint8 info)
{
- if ((info & ~XLR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
+ if ((info & XLR_RMGR_INFO_MASK) == XLOG_LOGICAL_MESSAGE)
return "MESSAGE";
return NULL;
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 3ca0582db36..d5a5ec4534c 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -50,7 +50,7 @@ void
multixact_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
@@ -85,7 +85,7 @@ multixact_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_MULTIXACT_ZERO_OFF_PAGE:
id = "ZERO_OFF_PAGE";
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index c05d19ab007..5cbf9473d5a 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -24,7 +24,7 @@ void
btree_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -140,7 +140,7 @@ btree_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_BTREE_INSERT_LEAF:
id = "INSERT_LEAF";
diff --git a/src/backend/access/rmgrdesc/relmapdesc.c b/src/backend/access/rmgrdesc/relmapdesc.c
index caf18460321..0ad32eb90f1 100644
--- a/src/backend/access/rmgrdesc/relmapdesc.c
+++ b/src/backend/access/rmgrdesc/relmapdesc.c
@@ -20,7 +20,7 @@ void
relmap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_RELMAP_UPDATE)
{
@@ -36,7 +36,7 @@ relmap_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_RELMAP_UPDATE:
id = "UPDATE";
diff --git a/src/backend/access/rmgrdesc/replorigindesc.c b/src/backend/access/rmgrdesc/replorigindesc.c
index 5dd74233996..9cf67673fe0 100644
--- a/src/backend/access/rmgrdesc/replorigindesc.c
+++ b/src/backend/access/rmgrdesc/replorigindesc.c
@@ -19,7 +19,7 @@ void
replorigin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/seqdesc.c b/src/backend/access/rmgrdesc/seqdesc.c
index 0d289d77fcf..6ba16f94f46 100644
--- a/src/backend/access/rmgrdesc/seqdesc.c
+++ b/src/backend/access/rmgrdesc/seqdesc.c
@@ -21,7 +21,7 @@ void
seq_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
xl_seq_rec *xlrec = (xl_seq_rec *) rec;
if (info == XLOG_SEQ_LOG)
@@ -35,7 +35,7 @@ seq_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_SEQ_LOG:
id = "LOG";
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index 4bb7fc79bce..a66415b4cab 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -21,7 +21,7 @@ void
smgr_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_SMGR_CREATE)
{
@@ -45,7 +45,7 @@ smgr_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_SMGR_CREATE:
id = "CREATE";
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 72efedc5b40..21d7ba63a4f 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -20,7 +20,7 @@ void
spg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
@@ -133,7 +133,7 @@ spg_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_SPGIST_ADD_LEAF:
id = "ADD_LEAF";
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 81eff5f31c4..588b0dec7ab 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -47,7 +47,7 @@ void
standby_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_STANDBY_LOCK)
{
@@ -80,7 +80,7 @@ standby_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_STANDBY_LOCK:
id = "LOCK";
diff --git a/src/backend/access/rmgrdesc/tblspcdesc.c b/src/backend/access/rmgrdesc/tblspcdesc.c
index 5d612b4232e..2066d8588ca 100644
--- a/src/backend/access/rmgrdesc/tblspcdesc.c
+++ b/src/backend/access/rmgrdesc/tblspcdesc.c
@@ -21,7 +21,7 @@ void
tblspc_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_TBLSPC_CREATE)
{
@@ -42,7 +42,7 @@ tblspc_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_TBLSPC_CREATE:
id = "CREATE";
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 58040f28656..77cc7b0e644 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -58,7 +58,7 @@ void
xlog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_CHECKPOINT_SHUTDOWN ||
info == XLOG_CHECKPOINT_ONLINE)
@@ -174,7 +174,7 @@ xlog_identify(uint8 info)
{
const char *id = NULL;
- switch (info & ~XLR_INFO_MASK)
+ switch (info & XLR_RMGR_INFO_MASK)
{
case XLOG_CHECKPOINT_SHUTDOWN:
id = "CHECKPOINT_SHUTDOWN";
diff --git a/src/backend/access/spgist/spgxlog.c b/src/backend/access/spgist/spgxlog.c
index b7986e6f713..6767f7598d5 100644
--- a/src/backend/access/spgist/spgxlog.c
+++ b/src/backend/access/spgist/spgxlog.c
@@ -934,7 +934,7 @@ spgRedoVacuumRedirect(XLogReaderState *record)
void
spg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
MemoryContext oldCxt;
oldCxt = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 48f10bec91e..680052d58e2 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -1106,7 +1106,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
void
clog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in clog records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 113fae1437a..a278d0a0b8b 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -1015,7 +1015,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
void
commit_ts_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in commit_ts records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 3c06ac45532..0560a414ff5 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -3393,7 +3393,7 @@ WriteMTruncateXlogRec(Oid oldestMultiDB,
void
multixact_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in multixact records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 1914859b2ee..3165845ae12 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -766,7 +766,7 @@ XLogInsertRecord(XLogRecData *rdata,
pg_crc32c rdata_crc;
bool inserted;
XLogRecord *rechdr = (XLogRecord *) rdata->data;
- uint8 info = rechdr->xl_info & ~XLR_INFO_MASK;
+ uint8 info = rechdr->xl_info & XLR_RMGR_INFO_MASK;
WalInsertClass class = WALINSERT_NORMAL;
XLogRecPtr StartPos;
XLogRecPtr EndPos;
@@ -8422,7 +8422,7 @@ UpdateFullPageWrites(void)
void
xlog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
XLogRecPtr lsn = record->EndRecPtr;
/*
diff --git a/src/backend/access/transam/xlogprefetcher.c b/src/backend/access/transam/xlogprefetcher.c
index 7735562db01..4d9e7eaa1c5 100644
--- a/src/backend/access/transam/xlogprefetcher.c
+++ b/src/backend/access/transam/xlogprefetcher.c
@@ -530,7 +530,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
if (replaying_lsn < record->lsn)
{
uint8 rmid = record->header.xl_rmid;
- uint8 record_type = record->header.xl_info & ~XLR_INFO_MASK;
+ uint8 record_type = record->header.xl_info & XLR_RMGR_INFO_MASK;
if (rmid == RM_XLOG_ID)
{
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index 2790ade1f91..c087295a714 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -864,7 +864,7 @@ restart:
* Special processing if it's an XLOG SWITCH record
*/
if (record->xl_rmid == RM_XLOG_ID &&
- (record->xl_info & ~XLR_INFO_MASK) == XLOG_SWITCH)
+ (record->xl_info & XLR_RMGR_INFO_MASK) == XLOG_SWITCH)
{
/* Pretend it extends to end of segment */
state->NextRecPtr += state->segcxt.ws_segsize - 1;
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 6ce979f2d8b..724e4704c76 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -634,7 +634,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
if (record != NULL)
{
memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
- wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
+ wasShutdown = ((record->xl_info & XLR_RMGR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
ereport(DEBUG1,
(errmsg_internal("checkpoint record is at %X/%X",
LSN_FORMAT_ARGS(CheckPointLoc))));
@@ -802,7 +802,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
LSN_FORMAT_ARGS(CheckPointLoc))));
}
memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint));
- wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
+ wasShutdown = ((record->xl_info & XLR_RMGR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN);
}
if (ArchiveRecoveryRequested)
@@ -1720,7 +1720,7 @@ PerformWalRecovery(void)
* record.
*/
if (record->xl_rmid != RM_XLOG_ID ||
- (record->xl_info & ~XLR_INFO_MASK) != XLOG_CHECKPOINT_REDO)
+ (record->xl_info & XLR_RMGR_INFO_MASK) != XLOG_CHECKPOINT_REDO)
ereport(FATAL,
(errmsg("unexpected record type found at redo point %X/%X",
LSN_FORMAT_ARGS(xlogreader->ReadRecPtr))));
@@ -1942,7 +1942,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
{
TimeLineID newReplayTLI = *replayTLI;
TimeLineID prevReplayTLI = *replayTLI;
- uint8 info = record->xl_info & ~XLR_INFO_MASK;
+ uint8 info = record->xl_info & XLR_RMGR_INFO_MASK;
if (info == XLOG_CHECKPOINT_SHUTDOWN)
{
@@ -2080,7 +2080,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
static void
xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
XLogRecPtr lsn = record->EndRecPtr;
Assert(XLogRecGetRmid(record) == RM_XLOG_ID);
@@ -2316,7 +2316,7 @@ xlog_outdesc(StringInfo buf, XLogReaderState *record)
id = rmgr.rm_identify(info);
if (id == NULL)
- appendStringInfo(buf, "UNKNOWN (%X): ", info & ~XLR_INFO_MASK);
+ appendStringInfo(buf, "UNKNOWN (%X): ", info & XLR_RMGR_INFO_MASK);
else
appendStringInfo(buf, "%s: ", id);
@@ -2436,7 +2436,7 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
static bool
getRecordTimestamp(XLogReaderState *record, TimestampTz *recordXtime)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
uint8 xact_info = info & XLOG_XACT_OPMASK;
uint8 rmid = XLogRecGetRmid(record);
@@ -2748,7 +2748,7 @@ recoveryStopsAfter(XLogReaderState *record)
if (!ArchiveRecoveryRequested)
return false;
- info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
rmid = XLogRecGetRmid(record);
/*
@@ -4098,7 +4098,7 @@ ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
(errmsg("invalid resource manager ID in checkpoint record")));
return NULL;
}
- info = record->xl_info & ~XLR_INFO_MASK;
+ info = record->xl_info & XLR_RMGR_INFO_MASK;
if (info != XLOG_CHECKPOINT_SHUTDOWN &&
info != XLOG_CHECKPOINT_ONLINE)
{
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index 227df90f89c..9ce4da7f32a 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -981,7 +981,7 @@ void
smgr_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in smgr records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 5fbbcdaabb1..02797ed87a5 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -3283,7 +3283,7 @@ recovery_create_dbdir(char *path, bool only_tblspc)
void
dbase_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in dbase records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 451ae6f7f69..c81a5c18cd0 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1890,7 +1890,7 @@ void
seq_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
Buffer buffer;
Page page;
Page localpage;
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index a9005cc7212..52600f155c9 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -1510,7 +1510,7 @@ get_tablespace_name(Oid spc_oid)
void
tblspc_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in tblspc records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c
index 0fec4f1f871..6dec1050a8a 100644
--- a/src/backend/postmaster/walsummarizer.c
+++ b/src/backend/postmaster/walsummarizer.c
@@ -1248,7 +1248,7 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact,
static void
SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
/*
* We use relfilenode zero for a given database OID and tablespace OID to
@@ -1317,7 +1317,7 @@ SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
if (info == XLOG_SMGR_CREATE)
{
@@ -1366,7 +1366,7 @@ SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
uint8 xact_info = info & XLOG_XACT_OPMASK;
if (xact_info == XLOG_XACT_COMMIT ||
@@ -1426,7 +1426,7 @@ SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static bool
SummarizeXlogRecord(XLogReaderState *xlogreader, bool *new_fast_forward)
{
- uint8 info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
int record_wal_level;
if (info == XLOG_CHECKPOINT_REDO)
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index cc03f0706e9..c87fb8f8c97 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -129,7 +129,7 @@ void
xlog_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
- uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(buf->record) & XLR_RMGR_INFO_MASK;
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record),
buf->origptr);
@@ -360,7 +360,7 @@ standby_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
- uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr);
@@ -597,7 +597,7 @@ logicalmsg_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
TransactionId xid = XLogRecGetXid(r);
- uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
RepOriginId origin_id = XLogRecGetOrigin(r);
Snapshot snapshot = NULL;
xl_logical_message *message;
diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c
index ebc8454bad9..10d60880195 100644
--- a/src/backend/replication/logical/message.c
+++ b/src/backend/replication/logical/message.c
@@ -86,7 +86,7 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size,
void
logicalmsg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info != XLOG_LOGICAL_MESSAGE)
elog(PANIC, "logicalmsg_redo: unknown op code %u", info);
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index a17bacf88e7..4a8fa5abc3e 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -849,7 +849,7 @@ StartupReplicationOrigin(void)
void
replorigin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
switch (info)
{
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 7fa8d9247e0..5e4f914f4f0 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1162,7 +1162,7 @@ StandbyReleaseOldLocks(TransactionId oldxid)
void
standby_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in standby records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
index abf89f0776e..0e35ab8b57c 100644
--- a/src/backend/utils/cache/relmapper.c
+++ b/src/backend/utils/cache/relmapper.c
@@ -1095,7 +1095,7 @@ perform_relmap_update(bool shared, const RelMapFile *updates)
void
relmap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
/* Backup blocks are not used in relmap records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 2cd44625ca3..9bfd6ea325b 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -243,7 +243,7 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex,
* be the latest checkpoint before WAL forked and not the checkpoint
* where the primary has been stopped to be rewound.
*/
- info = XLogRecGetInfo(xlogreader) & ~XLR_INFO_MASK;
+ info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
if (searchptr < forkptr &&
XLogRecGetRmid(xlogreader) == RM_XLOG_ID &&
(info == XLOG_CHECKPOINT_SHUTDOWN ||
@@ -391,7 +391,7 @@ extractPageInfo(XLogReaderState *record)
int block_id;
RmgrId rmid = XLogRecGetRmid(record);
uint8 info = XLogRecGetInfo(record);
- uint8 rminfo = info & ~XLR_INFO_MASK;
+ uint8 rminfo = info & XLR_RMGR_INFO_MASK;
/* Is this a special record type that I recognize? */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 51fb76efc48..e0c98380b47 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -564,7 +564,7 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
id = desc->rm_identify(info);
if (id == NULL)
- printf("desc: UNKNOWN (%x) ", info & ~XLR_INFO_MASK);
+ printf("desc: UNKNOWN (%x) ", info & XLR_RMGR_INFO_MASK);
else
printf("desc: %s ", id);
diff --git a/src/include/access/xlogrecord.h b/src/include/access/xlogrecord.h
index a06833ce0a3..366b622cc15 100644
--- a/src/include/access/xlogrecord.h
+++ b/src/include/access/xlogrecord.h
@@ -59,7 +59,6 @@ typedef struct XLogRecord
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
-#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0
/*
diff --git a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
index 1a424ad55a8..5ecb4970be7 100644
--- a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
+++ b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
@@ -81,7 +81,7 @@ _PG_init(void)
void
testcustomrmgrs_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info != XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
elog(PANIC, "testcustomrmgrs_redo: unknown op code %u", info);
@@ -91,7 +91,7 @@ void
testcustomrmgrs_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+ uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
if (info == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
{
@@ -105,7 +105,7 @@ testcustomrmgrs_desc(StringInfo buf, XLogReaderState *record)
const char *
testcustomrmgrs_identify(uint8 info)
{
- if ((info & ~XLR_INFO_MASK) == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
+ if ((info & XLR_RMGR_INFO_MASK) == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
return "TEST_CUSTOM_RMGRS_MESSAGE";
return NULL;
--
2.39.5 (Apple Git-154)
0002-Add-a-macro-XLogRecGetRmgrInfo.patchapplication/octet-stream; name=0002-Add-a-macro-XLogRecGetRmgrInfo.patchDownload
From 4f9c95988f11c2876e87b3591ff044924ca5b626 Mon Sep 17 00:00:00 2001
From: wangxiaoran <fanfuxiaoran@gmail.com>
Date: Mon, 9 Jun 2025 17:35:33 +0800
Subject: [PATCH 2/2] Add a macro XLogRecGetRmgrInfo
Since there are many instances of code like
'(XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK)',
we should add the macro 'XLogRecGetRmgrInfo' to encapsulate this operation.
---
contrib/pg_walinspect/pg_walinspect.c | 4 ++--
src/backend/access/brin/brin_xlog.c | 2 +-
src/backend/access/gin/ginxlog.c | 2 +-
src/backend/access/gist/gistxlog.c | 2 +-
src/backend/access/hash/hash_xlog.c | 2 +-
src/backend/access/heap/heapam_xlog.c | 4 ++--
src/backend/access/nbtree/nbtxlog.c | 2 +-
src/backend/access/rmgrdesc/brindesc.c | 2 +-
src/backend/access/rmgrdesc/clogdesc.c | 2 +-
src/backend/access/rmgrdesc/committsdesc.c | 2 +-
src/backend/access/rmgrdesc/dbasedesc.c | 2 +-
src/backend/access/rmgrdesc/gindesc.c | 2 +-
src/backend/access/rmgrdesc/gistdesc.c | 2 +-
src/backend/access/rmgrdesc/hashdesc.c | 2 +-
src/backend/access/rmgrdesc/heapdesc.c | 4 ++--
src/backend/access/rmgrdesc/logicalmsgdesc.c | 2 +-
src/backend/access/rmgrdesc/mxactdesc.c | 2 +-
src/backend/access/rmgrdesc/nbtdesc.c | 2 +-
src/backend/access/rmgrdesc/relmapdesc.c | 2 +-
src/backend/access/rmgrdesc/replorigindesc.c | 2 +-
src/backend/access/rmgrdesc/seqdesc.c | 2 +-
src/backend/access/rmgrdesc/smgrdesc.c | 2 +-
src/backend/access/rmgrdesc/spgdesc.c | 2 +-
src/backend/access/rmgrdesc/standbydesc.c | 2 +-
src/backend/access/rmgrdesc/tblspcdesc.c | 2 +-
src/backend/access/rmgrdesc/xlogdesc.c | 2 +-
src/backend/access/spgist/spgxlog.c | 2 +-
src/backend/access/transam/clog.c | 2 +-
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 2 +-
src/backend/access/transam/xlog.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 6 +++---
src/backend/catalog/storage.c | 2 +-
src/backend/commands/dbcommands.c | 2 +-
src/backend/commands/sequence.c | 2 +-
src/backend/commands/tablespace.c | 2 +-
src/backend/postmaster/walsummarizer.c | 8 ++++----
src/backend/replication/logical/decode.c | 6 +++---
src/backend/replication/logical/message.c | 2 +-
src/backend/replication/logical/origin.c | 2 +-
src/backend/storage/ipc/standby.c | 2 +-
src/backend/utils/cache/relmapper.c | 2 +-
src/bin/pg_rewind/parsexlog.c | 2 +-
src/include/access/xlogreader.h | 2 ++
src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c | 4 ++--
45 files changed, 57 insertions(+), 55 deletions(-)
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c
index e07d0d6ce99..98930757827 100644
--- a/contrib/pg_walinspect/pg_walinspect.c
+++ b/contrib/pg_walinspect/pg_walinspect.c
@@ -203,7 +203,7 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values,
record_type = desc.rm_identify(XLogRecGetInfo(record));
if (record_type == NULL)
- record_type = psprintf("UNKNOWN (%x)", XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK);
+ record_type = psprintf("UNKNOWN (%x)", XLogRecGetRmgrInfo(record));
initStringInfo(&rec_desc);
desc.rm_desc(&rec_desc, record);
@@ -266,7 +266,7 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record,
if (record_type == NULL)
record_type = psprintf("UNKNOWN (%x)",
- XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK);
+ XLogRecGetRmgrInfo(record));
initStringInfo(&rec_desc);
desc.rm_desc(&rec_desc, record);
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c
index c9b91a15b46..5a2cc38e0e0 100644
--- a/src/backend/access/brin/brin_xlog.c
+++ b/src/backend/access/brin/brin_xlog.c
@@ -308,7 +308,7 @@ brin_xlog_desummarize_page(XLogReaderState *record)
void
brin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info & XLOG_BRIN_OPMASK)
{
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 7b2ec5a0429..1fd53a8679e 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -725,7 +725,7 @@ ginRedoDeleteListPages(XLogReaderState *record)
void
gin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCtx;
/*
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
index 1b382848a12..63f49fe887c 100644
--- a/src/backend/access/gist/gistxlog.c
+++ b/src/backend/access/gist/gistxlog.c
@@ -396,7 +396,7 @@ gistRedoPageReuse(XLogReaderState *record)
void
gist_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCxt;
/*
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index 9df486a564b..335f484a8b3 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -1066,7 +1066,7 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
void
hash_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/heap/heapam_xlog.c b/src/backend/access/heap/heapam_xlog.c
index 29e87ccc8d8..0b1751a39a8 100644
--- a/src/backend/access/heap/heapam_xlog.c
+++ b/src/backend/access/heap/heapam_xlog.c
@@ -1181,7 +1181,7 @@ heap_xlog_inplace(XLogReaderState *record)
void
heap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/*
* These operations don't overwrite MVCC data so no conflict processing is
@@ -1227,7 +1227,7 @@ heap_redo(XLogReaderState *record)
void
heap2_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info & XLOG_HEAP_OPMASK)
{
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index ccfc71954f9..441bf942f8b 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -1017,7 +1017,7 @@ btree_xlog_reuse_page(XLogReaderState *record)
void
btree_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCtx;
oldCtx = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/rmgrdesc/brindesc.c b/src/backend/access/rmgrdesc/brindesc.c
index 1be7c6dc927..27699e313b0 100644
--- a/src/backend/access/rmgrdesc/brindesc.c
+++ b/src/backend/access/rmgrdesc/brindesc.c
@@ -20,7 +20,7 @@ void
brin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
info &= XLOG_BRIN_OPMASK;
if (info == XLOG_BRIN_CREATE_INDEX)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 11a4c38ca96..26c8ce27a7e 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -21,7 +21,7 @@ void
clog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == CLOG_ZEROPAGE)
{
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 9204a9aea6c..329f4e3613f 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -21,7 +21,7 @@ void
commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == COMMIT_TS_ZEROPAGE)
{
diff --git a/src/backend/access/rmgrdesc/dbasedesc.c b/src/backend/access/rmgrdesc/dbasedesc.c
index 9be3cd873e5..2e0ad6478fe 100644
--- a/src/backend/access/rmgrdesc/dbasedesc.c
+++ b/src/backend/access/rmgrdesc/dbasedesc.c
@@ -22,7 +22,7 @@ void
dbase_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_DBASE_CREATE_FILE_COPY)
{
diff --git a/src/backend/access/rmgrdesc/gindesc.c b/src/backend/access/rmgrdesc/gindesc.c
index 1a54956d96d..e2095f231dd 100644
--- a/src/backend/access/rmgrdesc/gindesc.c
+++ b/src/backend/access/rmgrdesc/gindesc.c
@@ -72,7 +72,7 @@ void
gin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index be67717ffe3..ff463ffdbef 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -61,7 +61,7 @@ void
gist_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index 6547b4619e5..32b80a2fc5a 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -20,7 +20,7 @@ void
hash_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 12a30099d95..0e920e838af 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -184,7 +184,7 @@ void
heap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP_INSERT)
@@ -264,7 +264,7 @@ void
heap2_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
info &= XLOG_HEAP_OPMASK;
if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
diff --git a/src/backend/access/rmgrdesc/logicalmsgdesc.c b/src/backend/access/rmgrdesc/logicalmsgdesc.c
index d2112e02d2b..527f02592e4 100644
--- a/src/backend/access/rmgrdesc/logicalmsgdesc.c
+++ b/src/backend/access/rmgrdesc/logicalmsgdesc.c
@@ -19,7 +19,7 @@ void
logicalmsg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_LOGICAL_MESSAGE)
{
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index d5a5ec4534c..fa3a4b0e737 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -50,7 +50,7 @@ void
multixact_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 5cbf9473d5a..1f5905f7e3c 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -24,7 +24,7 @@ void
btree_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/relmapdesc.c b/src/backend/access/rmgrdesc/relmapdesc.c
index 0ad32eb90f1..56f108ecd2d 100644
--- a/src/backend/access/rmgrdesc/relmapdesc.c
+++ b/src/backend/access/rmgrdesc/relmapdesc.c
@@ -20,7 +20,7 @@ void
relmap_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_RELMAP_UPDATE)
{
diff --git a/src/backend/access/rmgrdesc/replorigindesc.c b/src/backend/access/rmgrdesc/replorigindesc.c
index 9cf67673fe0..2abea74849e 100644
--- a/src/backend/access/rmgrdesc/replorigindesc.c
+++ b/src/backend/access/rmgrdesc/replorigindesc.c
@@ -19,7 +19,7 @@ void
replorigin_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/seqdesc.c b/src/backend/access/rmgrdesc/seqdesc.c
index 6ba16f94f46..dbf7559c04e 100644
--- a/src/backend/access/rmgrdesc/seqdesc.c
+++ b/src/backend/access/rmgrdesc/seqdesc.c
@@ -21,7 +21,7 @@ void
seq_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
xl_seq_rec *xlrec = (xl_seq_rec *) rec;
if (info == XLOG_SEQ_LOG)
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index a66415b4cab..9b6f58a592b 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -21,7 +21,7 @@ void
smgr_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_SMGR_CREATE)
{
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 21d7ba63a4f..3acbff6e2e8 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -20,7 +20,7 @@ void
spg_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 588b0dec7ab..b30e66e003c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -47,7 +47,7 @@ void
standby_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_STANDBY_LOCK)
{
diff --git a/src/backend/access/rmgrdesc/tblspcdesc.c b/src/backend/access/rmgrdesc/tblspcdesc.c
index 2066d8588ca..9e86a8a7ce1 100644
--- a/src/backend/access/rmgrdesc/tblspcdesc.c
+++ b/src/backend/access/rmgrdesc/tblspcdesc.c
@@ -21,7 +21,7 @@ void
tblspc_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_TBLSPC_CREATE)
{
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 77cc7b0e644..6d2753d92ac 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -58,7 +58,7 @@ void
xlog_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_CHECKPOINT_SHUTDOWN ||
info == XLOG_CHECKPOINT_ONLINE)
diff --git a/src/backend/access/spgist/spgxlog.c b/src/backend/access/spgist/spgxlog.c
index 6767f7598d5..8a4fdcf2a68 100644
--- a/src/backend/access/spgist/spgxlog.c
+++ b/src/backend/access/spgist/spgxlog.c
@@ -934,7 +934,7 @@ spgRedoVacuumRedirect(XLogReaderState *record)
void
spg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
MemoryContext oldCxt;
oldCxt = MemoryContextSwitchTo(opCtx);
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 680052d58e2..717c7885f53 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -1106,7 +1106,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
void
clog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in clog records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index a278d0a0b8b..26918d21337 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -1015,7 +1015,7 @@ WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
void
commit_ts_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in commit_ts records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 0560a414ff5..98f31a609ed 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -3393,7 +3393,7 @@ WriteMTruncateXlogRec(Oid oldestMultiDB,
void
multixact_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in multixact records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3165845ae12..5ae6fae49c4 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8422,7 +8422,7 @@ UpdateFullPageWrites(void)
void
xlog_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
XLogRecPtr lsn = record->EndRecPtr;
/*
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 724e4704c76..c7be958dd55 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2080,7 +2080,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
static void
xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
XLogRecPtr lsn = record->EndRecPtr;
Assert(XLogRecGetRmid(record) == RM_XLOG_ID);
@@ -2436,7 +2436,7 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
static bool
getRecordTimestamp(XLogReaderState *record, TimestampTz *recordXtime)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
uint8 xact_info = info & XLOG_XACT_OPMASK;
uint8 rmid = XLogRecGetRmid(record);
@@ -2748,7 +2748,7 @@ recoveryStopsAfter(XLogReaderState *record)
if (!ArchiveRecoveryRequested)
return false;
- info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ info = XLogRecGetRmgrInfo(record);
rmid = XLogRecGetRmid(record);
/*
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index 9ce4da7f32a..0ba97b2ba31 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -981,7 +981,7 @@ void
smgr_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in smgr records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 02797ed87a5..e1313c01ab1 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -3283,7 +3283,7 @@ recovery_create_dbdir(char *path, bool only_tblspc)
void
dbase_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in dbase records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index c81a5c18cd0..80e952f15b1 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1890,7 +1890,7 @@ void
seq_redo(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
Buffer buffer;
Page page;
Page localpage;
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 52600f155c9..56b226ad03e 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -1510,7 +1510,7 @@ get_tablespace_name(Oid spc_oid)
void
tblspc_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in tblspc records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c
index 6dec1050a8a..d8aff2b8db1 100644
--- a/src/backend/postmaster/walsummarizer.c
+++ b/src/backend/postmaster/walsummarizer.c
@@ -1248,7 +1248,7 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact,
static void
SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
/*
* We use relfilenode zero for a given database OID and tablespace OID to
@@ -1317,7 +1317,7 @@ SummarizeDbaseRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
if (info == XLOG_SMGR_CREATE)
{
@@ -1366,7 +1366,7 @@ SummarizeSmgrRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static void
SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
uint8 xact_info = info & XLOG_XACT_OPMASK;
if (xact_info == XLOG_XACT_COMMIT ||
@@ -1426,7 +1426,7 @@ SummarizeXactRecord(XLogReaderState *xlogreader, BlockRefTable *brtab)
static bool
SummarizeXlogRecord(XLogReaderState *xlogreader, bool *new_fast_forward)
{
- uint8 info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(xlogreader);
int record_wal_level;
if (info == XLOG_CHECKPOINT_REDO)
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index c87fb8f8c97..93b69c3c530 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -129,7 +129,7 @@ void
xlog_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
- uint8 info = XLogRecGetInfo(buf->record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(buf->record);
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record),
buf->origptr);
@@ -360,7 +360,7 @@ standby_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
{
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
- uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(r);
ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr);
@@ -597,7 +597,7 @@ logicalmsg_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
SnapBuild *builder = ctx->snapshot_builder;
XLogReaderState *r = buf->record;
TransactionId xid = XLogRecGetXid(r);
- uint8 info = XLogRecGetInfo(r) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(r);
RepOriginId origin_id = XLogRecGetOrigin(r);
Snapshot snapshot = NULL;
xl_logical_message *message;
diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c
index 10d60880195..31f5bec0e3d 100644
--- a/src/backend/replication/logical/message.c
+++ b/src/backend/replication/logical/message.c
@@ -86,7 +86,7 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size,
void
logicalmsg_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info != XLOG_LOGICAL_MESSAGE)
elog(PANIC, "logicalmsg_redo: unknown op code %u", info);
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 4a8fa5abc3e..2c61da04a52 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -849,7 +849,7 @@ StartupReplicationOrigin(void)
void
replorigin_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
switch (info)
{
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 5e4f914f4f0..388f6882f2c 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1162,7 +1162,7 @@ StandbyReleaseOldLocks(TransactionId oldxid)
void
standby_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in standby records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/backend/utils/cache/relmapper.c b/src/backend/utils/cache/relmapper.c
index 0e35ab8b57c..116d314eb9b 100644
--- a/src/backend/utils/cache/relmapper.c
+++ b/src/backend/utils/cache/relmapper.c
@@ -1095,7 +1095,7 @@ perform_relmap_update(bool shared, const RelMapFile *updates)
void
relmap_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
/* Backup blocks are not used in relmap records */
Assert(!XLogRecHasAnyBlockRefs(record));
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 9bfd6ea325b..b0b2fdfafdd 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -243,7 +243,7 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex,
* be the latest checkpoint before WAL forked and not the checkpoint
* where the primary has been stopped to be rewound.
*/
- info = XLogRecGetInfo(xlogreader) & XLR_RMGR_INFO_MASK;
+ info = XLogRecGetRmgrInfo(xlogreader);
if (searchptr < forkptr &&
XLogRecGetRmid(xlogreader) == RM_XLOG_ID &&
(info == XLOG_CHECKPOINT_SHUTDOWN ||
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h
index 9738462d3c9..0522854f434 100644
--- a/src/include/access/xlogreader.h
+++ b/src/include/access/xlogreader.h
@@ -408,6 +408,8 @@ extern bool DecodeXLogRecord(XLogReaderState *state,
#define XLogRecGetTotalLen(decoder) ((decoder)->record->header.xl_tot_len)
#define XLogRecGetPrev(decoder) ((decoder)->record->header.xl_prev)
#define XLogRecGetInfo(decoder) ((decoder)->record->header.xl_info)
+#define XLogRecGetRmgrInfo(decoder) ((decoder)->record->header.xl_info \
+ & XLR_RMGR_INFO_MASK)
#define XLogRecGetRmid(decoder) ((decoder)->record->header.xl_rmid)
#define XLogRecGetXid(decoder) ((decoder)->record->header.xl_xid)
#define XLogRecGetOrigin(decoder) ((decoder)->record->record_origin)
diff --git a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
index 5ecb4970be7..6d8a3f88017 100644
--- a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
+++ b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c
@@ -81,7 +81,7 @@ _PG_init(void)
void
testcustomrmgrs_redo(XLogReaderState *record)
{
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info != XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
elog(PANIC, "testcustomrmgrs_redo: unknown op code %u", info);
@@ -91,7 +91,7 @@ void
testcustomrmgrs_desc(StringInfo buf, XLogReaderState *record)
{
char *rec = XLogRecGetData(record);
- uint8 info = XLogRecGetInfo(record) & XLR_RMGR_INFO_MASK;
+ uint8 info = XLogRecGetRmgrInfo(record);
if (info == XLOG_TEST_CUSTOM_RMGRS_MESSAGE)
{
--
2.39.5 (Apple Git-154)
LGTM. I have no more comments.
Regards,
Steven
Xiaoran Wang <fanfuxiaoran@gmail.com> 于2025年6月9日周一 18:31写道:
Show quoted text
Just upload all the patches together.
Xiaoran Wang <fanfuxiaoran@gmail.com> 于2025年6月9日周一 18:25写道:
Steven Niu <niushiji@gmail.com> 于2025年6月9日周一 14:46写道:
Hi,
I like the idea of your change as it saves me out of
converting-in-my-mind.And I suggest to create a macro to do this job.
#define getRmgrInfo(info) (info & XLR_RMGR_INFO_MASK)Then the code can become:
XLogRecGetInfo(record) & ~XLR_INFO_MASK;
-->
getRmgrInfo(XLogRecGetInfo(record));Good idea, found lots of 'XLogRecGetInfo(record) & ~XLR_INFO_MASK;'
in the code.I add a macro XLogRecRmgrGetInfo(record) in patch 0002.
Thanks,
Steven在 2025/6/9 14:23, Xiaoran Wang 写道:
Hi,
I refactored the code of extracting XLogRecord info.
In XLogRecord, the high 4 bits in xl_info is used by rmgr.typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record *//* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no
padding */} XLogRecord;
I found lots of the code to get the info as below
XLogRecGetInfo(record) & ~XLR_INFO_MASK
Actually, we can directly use XLR_RMGR_INFO_MASK(0xF0)
instead of XLR_INFO_MASK(0x0F), which is easier to understand.
Remove XLR_INFO_MASK as it is not used any more.--
Best regards !
Xiaoran Wang--
Best regards !
Xiaoran Wang--
Best regards !
Xiaoran Wang
On Mon, 9 Jun 2025 at 22:40 Steven Niu <niushiji@gmail.com> wrote:
LGTM. I have no more comments.
The refactoring LGTM but do we really need two patches? IMHO you can just
merge everything into a single patch.
Fabrízio de Royes Mello
On Mon, Jun 09, 2025 at 10:54:43PM -0300, Fabrízio de Royes Mello wrote:
The refactoring LGTM but do we really need two patches? IMHO you can just
merge everything into a single patch.
FWIW, I'm not sure what's the benefit of the proposal which comes down
to the removal of a bitwise NOT, except more code conflicts with back
branches.
--
Michael
HI
FWIW, I'm not sure what's the benefit of the proposal which comes down
to the removal of a bitwise NOT, except more code conflicts with back
branches.
Agree
On Tue, Jun 10, 2025 at 3:37 PM Michael Paquier <michael@paquier.xyz> wrote:
Show quoted text
On Mon, Jun 09, 2025 at 10:54:43PM -0300, Fabrízio de Royes Mello wrote:
The refactoring LGTM but do we really need two patches? IMHO you can just
merge everything into a single patch.FWIW, I'm not sure what's the benefit of the proposal which comes down
to the removal of a bitwise NOT, except more code conflicts with back
branches.
--
Michael
I'm confused by the code of XLR_RMGR_INFO_MASK and XLR_INFO_MASK.
According to the definition of masks, the high 4 bits are for rmgr.
/*
* The high 4 bits in xl_info may be used freely by rmgr. The
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0
However, in function XLogInsert(), there is code:
/*
* The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
* XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
*/
if ((info & ~(XLR_RMGR_INFO_MASK |
XLR_SPECIAL_REL_UPDATE |
XLR_CHECK_CONSISTENCY)) != 0)
elog(PANIC, "invalid xlog info mask %02X", info);
#define XLR_SPECIAL_REL_UPDATE 0x01
#define XLR_CHECK_CONSISTENCY 0x02
As the XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are of the low 4
bits,
the above code is indicating the low 4 bits are for rmgr too?
Did I misunderstand something?
Thanks,
Steven
wenhui qiu <qiuwenhuifx@gmail.com> 于2025年6月10日周二 16:00写道:
Show quoted text
HI
FWIW, I'm not sure what's the benefit of the proposal which comes down
to the removal of a bitwise NOT, except more code conflicts with back
branches.Agree
On Tue, Jun 10, 2025 at 3:37 PM Michael Paquier <michael@paquier.xyz>
wrote:On Mon, Jun 09, 2025 at 10:54:43PM -0300, Fabrízio de Royes Mello wrote:
The refactoring LGTM but do we really need two patches? IMHO you can
just
merge everything into a single patch.
FWIW, I'm not sure what's the benefit of the proposal which comes down
to the removal of a bitwise NOT, except more code conflicts with back
branches.
--
Michael
Steven Niu <niushiji@gmail.com> 于2025年6月10日周二 17:56写道:
I'm confused by the code of XLR_RMGR_INFO_MASK and XLR_INFO_MASK.
According to the definition of masks, the high 4 bits are for rmgr.
/*
* The high 4 bits in xl_info may be used freely by rmgr. The
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0However, in function XLogInsert(), there is code:
/*
* The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
* XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
*/
if ((info & ~(XLR_RMGR_INFO_MASK |
XLR_SPECIAL_REL_UPDATE |
XLR_CHECK_CONSISTENCY)) != 0)
elog(PANIC, "invalid xlog info mask %02X", info);XLogInsert only allows the rmgr ,XLR_SPECIAL_REL_UPDATE and
XLR_CHECK_CONSISTENCY
set in the info.
#define XLR_SPECIAL_REL_UPDATE 0x01
#define XLR_CHECK_CONSISTENCY 0x02As the XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are of the low 4
bits,
the above code is indicating the low 4 bits are for rmgr too?
No, only the high 4 bits are used for RMGR, see the code under directory
'src/backend/access/rmgrdesc'
'XLR_SPECIAL_REL_UPDATE' and 'XLR_CHECK_CONSISTENCY' are not RMGR info,
but they
can be passed by XLogInsert caller.
Did I misunderstand something?
Thanks,
Steven
--
Best regards !
Xiaoran Wang
Hi, Xiaoran,
I see. The code is checking if the bits other than rmgr bits,
XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are used.
Thanks for the explanation.
Steven
Xiaoran Wang <fanfuxiaoran@gmail.com> 于2025年6月11日周三 10:13写道:
Show quoted text
Steven Niu <niushiji@gmail.com> 于2025年6月10日周二 17:56写道:
I'm confused by the code of XLR_RMGR_INFO_MASK and XLR_INFO_MASK.
According to the definition of masks, the high 4 bits are for rmgr.
/*
* The high 4 bits in xl_info may be used freely by rmgr. The
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0However, in function XLogInsert(), there is code:
/*
* The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
* XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
*/
if ((info & ~(XLR_RMGR_INFO_MASK |
XLR_SPECIAL_REL_UPDATE |
XLR_CHECK_CONSISTENCY)) != 0)
elog(PANIC, "invalid xlog info mask %02X", info);XLogInsert only allows the rmgr ,XLR_SPECIAL_REL_UPDATE and
XLR_CHECK_CONSISTENCY
set in the info.#define XLR_SPECIAL_REL_UPDATE 0x01
#define XLR_CHECK_CONSISTENCY 0x02As the XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are of the low 4
bits,
the above code is indicating the low 4 bits are for rmgr too?No, only the high 4 bits are used for RMGR, see the code under directory
'src/backend/access/rmgrdesc''XLR_SPECIAL_REL_UPDATE' and 'XLR_CHECK_CONSISTENCY' are not RMGR info,
but they
can be passed by XLogInsert caller.Did I misunderstand something?
Thanks,
Steven--
Best regards !
Xiaoran Wang
Hi, Xiaoran,
I see. The code is checking if the bits other than rmgr bits,
XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are used.
Thanks for explanation.
Steven
在 2025/6/11 10:13, Xiaoran Wang 写道:
Show quoted text
Steven Niu <niushiji@gmail.com <mailto:niushiji@gmail.com>> 于2025年6月
10日周二 17:56写道:I'm confused by the code of XLR_RMGR_INFO_MASK and XLR_INFO_MASK.
According to the definition of masks, the high 4 bits are for rmgr.
/*
* The high 4 bits in xl_info may be used freely by rmgr. The
* XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY bits can be
passed by
* XLogInsert caller. The rest are set internally by XLogInsert.
*/
#define XLR_INFO_MASK 0x0F
#define XLR_RMGR_INFO_MASK 0xF0However, in function XLogInsert(), there is code:
/*
* The caller can set rmgr bits, XLR_SPECIAL_REL_UPDATE and
* XLR_CHECK_CONSISTENCY; the rest are reserved for use by me.
*/
if ((info & ~(XLR_RMGR_INFO_MASK |
XLR_SPECIAL_REL_UPDATE |
XLR_CHECK_CONSISTENCY)) != 0)
elog(PANIC, "invalid xlog info mask %02X", info);XLogInsert only allows the rmgr ,XLR_SPECIAL_REL_UPDATE and
XLR_CHECK_CONSISTENCY
set in the info.#define XLR_SPECIAL_REL_UPDATE 0x01
#define XLR_CHECK_CONSISTENCY 0x02As the XLR_SPECIAL_REL_UPDATE and XLR_CHECK_CONSISTENCY are of the
low 4 bits,
the above code is indicating the low 4 bits are for rmgr too?No, only the high 4 bits are used for RMGR, see the code under directory
'src/backend/access/rmgrdesc''XLR_SPECIAL_REL_UPDATE' and 'XLR_CHECK_CONSISTENCY' are not RMGR
info, but they
can be passed by XLogInsert caller.Did I misunderstand something?
Thanks,
Steven--
Best regards !
Xiaoran Wang