mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Simplify printing of LSNs
Add a macro LSN_FORMAT_ARGS for use in printf-style printing of LSNs. Convert all applicable code to use it. Reviewed-by: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/CAExHW5ub5NaTELZ3hJUCE6amuvqAtsSxc7O+uK7y4t9Rrk23cw@mail.gmail.com
This commit is contained in:
@@ -402,7 +402,7 @@ IdentifySystem(void)
|
||||
else
|
||||
logptr = GetFlushRecPtr();
|
||||
|
||||
snprintf(xloc, sizeof(xloc), "%X/%X", (uint32) (logptr >> 32), (uint32) logptr);
|
||||
snprintf(xloc, sizeof(xloc), "%X/%X", LSN_FORMAT_ARGS(logptr));
|
||||
|
||||
if (MyDatabaseId != InvalidOid)
|
||||
{
|
||||
@@ -674,13 +674,11 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errmsg("requested starting point %X/%X on timeline %u is not in this server's history",
|
||||
(uint32) (cmd->startpoint >> 32),
|
||||
(uint32) (cmd->startpoint),
|
||||
LSN_FORMAT_ARGS(cmd->startpoint),
|
||||
cmd->timeline),
|
||||
errdetail("This server's history forked from timeline %u at %X/%X.",
|
||||
cmd->timeline,
|
||||
(uint32) (switchpoint >> 32),
|
||||
(uint32) (switchpoint))));
|
||||
LSN_FORMAT_ARGS(switchpoint))));
|
||||
}
|
||||
sendTimeLineValidUpto = switchpoint;
|
||||
}
|
||||
@@ -723,10 +721,8 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errmsg("requested starting point %X/%X is ahead of the WAL flush position of this server %X/%X",
|
||||
(uint32) (cmd->startpoint >> 32),
|
||||
(uint32) (cmd->startpoint),
|
||||
(uint32) (FlushPtr >> 32),
|
||||
(uint32) (FlushPtr))));
|
||||
LSN_FORMAT_ARGS(cmd->startpoint),
|
||||
LSN_FORMAT_ARGS(FlushPtr))));
|
||||
}
|
||||
|
||||
/* Start streaming from the requested point */
|
||||
@@ -769,8 +765,7 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
bool nulls[2];
|
||||
|
||||
snprintf(startpos_str, sizeof(startpos_str), "%X/%X",
|
||||
(uint32) (sendTimeLineValidUpto >> 32),
|
||||
(uint32) sendTimeLineValidUpto);
|
||||
LSN_FORMAT_ARGS(sendTimeLineValidUpto));
|
||||
|
||||
dest = CreateDestReceiver(DestRemoteSimple);
|
||||
MemSet(nulls, false, sizeof(nulls));
|
||||
@@ -1063,8 +1058,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
|
||||
}
|
||||
|
||||
snprintf(xloc, sizeof(xloc), "%X/%X",
|
||||
(uint32) (MyReplicationSlot->data.confirmed_flush >> 32),
|
||||
(uint32) MyReplicationSlot->data.confirmed_flush);
|
||||
LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush));
|
||||
|
||||
dest = CreateDestReceiver(DestRemoteSimple);
|
||||
MemSet(nulls, false, sizeof(nulls));
|
||||
@@ -1900,9 +1894,9 @@ ProcessStandbyReplyMessage(void)
|
||||
replyTimeStr = pstrdup(timestamptz_to_str(replyTime));
|
||||
|
||||
elog(DEBUG2, "write %X/%X flush %X/%X apply %X/%X%s reply_time %s",
|
||||
(uint32) (writePtr >> 32), (uint32) writePtr,
|
||||
(uint32) (flushPtr >> 32), (uint32) flushPtr,
|
||||
(uint32) (applyPtr >> 32), (uint32) applyPtr,
|
||||
LSN_FORMAT_ARGS(writePtr),
|
||||
LSN_FORMAT_ARGS(flushPtr),
|
||||
LSN_FORMAT_ARGS(applyPtr),
|
||||
replyRequested ? " (reply requested)" : "",
|
||||
replyTimeStr);
|
||||
|
||||
@@ -2694,8 +2688,8 @@ XLogSendPhysical(void)
|
||||
WalSndCaughtUp = true;
|
||||
|
||||
elog(DEBUG1, "walsender reached end of timeline at %X/%X (sent up to %X/%X)",
|
||||
(uint32) (sendTimeLineValidUpto >> 32), (uint32) sendTimeLineValidUpto,
|
||||
(uint32) (sentPtr >> 32), (uint32) sentPtr);
|
||||
LSN_FORMAT_ARGS(sendTimeLineValidUpto),
|
||||
LSN_FORMAT_ARGS(sentPtr));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2826,7 +2820,7 @@ retry:
|
||||
char activitymsg[50];
|
||||
|
||||
snprintf(activitymsg, sizeof(activitymsg), "streaming %X/%X",
|
||||
(uint32) (sentPtr >> 32), (uint32) sentPtr);
|
||||
LSN_FORMAT_ARGS(sentPtr));
|
||||
set_ps_display(activitymsg);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user