Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5f6f13

Browse files
committed
Be more consistent about masking xl_info with ~XLR_INFO_MASK.
Generally, WAL resource managers are only supposed to examine thetop 4 bits of a WAL record's xl_info; the rest are reserved forthe WAL mechanism itself. A few places were not consistent aboutdoing this with respect to XLOG_CHECKPOINT and XLOG_SWITCH records.There's no bug currently, since no additional bits ever get set inthese specific record types, but that might not be true forever.Let's follow the generic coding rule here too.Michael Paquier
1 parent367b99b commitd5f6f13

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,9 @@ XLogInsertRecord(XLogRecData *rdata, XLogRecPtr fpw_lsn)
903903
pg_crc32crdata_crc;
904904
boolinserted;
905905
XLogRecord*rechdr= (XLogRecord*)rdata->data;
906+
uint8info=rechdr->xl_info& ~XLR_INFO_MASK;
906907
boolisLogSwitch= (rechdr->xl_rmid==RM_XLOG_ID&&
907-
rechdr->xl_info==XLOG_SWITCH);
908+
info==XLOG_SWITCH);
908909
XLogRecPtrStartPos;
909910
XLogRecPtrEndPos;
910911

@@ -6170,7 +6171,7 @@ StartupXLOG(void)
61706171
if (record!=NULL)
61716172
{
61726173
memcpy(&checkPoint,XLogRecGetData(xlogreader),sizeof(CheckPoint));
6173-
wasShutdown= (record->xl_info==XLOG_CHECKPOINT_SHUTDOWN);
6174+
wasShutdown= ((record->xl_info& ~XLR_INFO_MASK)==XLOG_CHECKPOINT_SHUTDOWN);
61746175
ereport(DEBUG1,
61756176
(errmsg("checkpoint record is at %X/%X",
61766177
(uint32) (checkPointLoc >>32), (uint32)checkPointLoc)));
@@ -6328,7 +6329,7 @@ StartupXLOG(void)
63286329
(errmsg("could not locate a valid checkpoint record")));
63296330
}
63306331
memcpy(&checkPoint,XLogRecGetData(xlogreader),sizeof(CheckPoint));
6331-
wasShutdown= (record->xl_info==XLOG_CHECKPOINT_SHUTDOWN);
6332+
wasShutdown= ((record->xl_info& ~XLR_INFO_MASK)==XLOG_CHECKPOINT_SHUTDOWN);
63326333
}
63336334

63346335
/*
@@ -7785,6 +7786,7 @@ ReadCheckpointRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr,
77857786
intwhichChkpt,boolreport)
77867787
{
77877788
XLogRecord*record;
7789+
uint8info;
77887790

77897791
if (!XRecOffIsValid(RecPtr))
77907792
{
@@ -7810,6 +7812,7 @@ ReadCheckpointRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr,
78107812
}
78117813

78127814
record=ReadRecord(xlogreader,RecPtr,LOG, true);
7815+
info=record->xl_info& ~XLR_INFO_MASK;
78137816

78147817
if (record==NULL)
78157818
{
@@ -7852,8 +7855,8 @@ ReadCheckpointRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr,
78527855
}
78537856
returnNULL;
78547857
}
7855-
if (record->xl_info!=XLOG_CHECKPOINT_SHUTDOWN&&
7856-
record->xl_info!=XLOG_CHECKPOINT_ONLINE)
7858+
if (info!=XLOG_CHECKPOINT_SHUTDOWN&&
7859+
info!=XLOG_CHECKPOINT_ONLINE)
78577860
{
78587861
switch (whichChkpt)
78597862
{

‎src/backend/access/transam/xlogreader.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ XLogReadRecord(XLogReaderState *state, XLogRecPtr RecPtr, char **errormsg)
462462
/*
463463
* Special processing if it's an XLOG SWITCH record
464464
*/
465-
if (record->xl_rmid==RM_XLOG_ID&&record->xl_info==XLOG_SWITCH)
465+
if (record->xl_rmid==RM_XLOG_ID&&
466+
(record->xl_info& ~XLR_INFO_MASK)==XLOG_SWITCH)
466467
{
467468
/* Pretend it extends to end of segment */
468469
state->EndRecPtr+=XLogSegSize-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp