mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Remove obsolete XLogRecPtr macros
This gets rid of XLByteLT, XLByteLE, XLByteEQ and XLByteAdvance. These were useful for brevity when XLogRecPtrs were split in xlogid/xrecoff; but now that they are simple uint64's, they are just clutter. The only downside to making this change would be ease of backporting patches, but that has been negated by other substantive changes to the involved code anyway. The clarity of simpler expressions makes the change worthwhile. Most of the changes are mechanical, but in a couple of places, the patch author chose to invert the operator sense, making the code flow more logical (and more in line with preceding comments). Author: Andres Freund Eyeballed by Dimitri Fontaine and Alvaro Herrera
This commit is contained in:
@ -120,7 +120,7 @@ SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
|
||||
* be a low cost check.
|
||||
*/
|
||||
if (!WalSndCtl->sync_standbys_defined ||
|
||||
XLByteLE(XactCommitLSN, WalSndCtl->lsn[mode]))
|
||||
XactCommitLSN <= WalSndCtl->lsn[mode])
|
||||
{
|
||||
LWLockRelease(SyncRepLock);
|
||||
return;
|
||||
@ -287,7 +287,7 @@ SyncRepQueueInsert(int mode)
|
||||
* Stop at the queue element that we should after to ensure the queue
|
||||
* is ordered by LSN.
|
||||
*/
|
||||
if (XLByteLT(proc->waitLSN, MyProc->waitLSN))
|
||||
if (proc->waitLSN < MyProc->waitLSN)
|
||||
break;
|
||||
|
||||
proc = (PGPROC *) SHMQueuePrev(&(WalSndCtl->SyncRepQueue[mode]),
|
||||
@ -428,12 +428,12 @@ SyncRepReleaseWaiters(void)
|
||||
* Set the lsn first so that when we wake backends they will release up to
|
||||
* this location.
|
||||
*/
|
||||
if (XLByteLT(walsndctl->lsn[SYNC_REP_WAIT_WRITE], MyWalSnd->write))
|
||||
if (walsndctl->lsn[SYNC_REP_WAIT_WRITE] < MyWalSnd->write)
|
||||
{
|
||||
walsndctl->lsn[SYNC_REP_WAIT_WRITE] = MyWalSnd->write;
|
||||
numwrite = SyncRepWakeQueue(false, SYNC_REP_WAIT_WRITE);
|
||||
}
|
||||
if (XLByteLT(walsndctl->lsn[SYNC_REP_WAIT_FLUSH], MyWalSnd->flush))
|
||||
if (walsndctl->lsn[SYNC_REP_WAIT_FLUSH] < MyWalSnd->flush)
|
||||
{
|
||||
walsndctl->lsn[SYNC_REP_WAIT_FLUSH] = MyWalSnd->flush;
|
||||
numflush = SyncRepWakeQueue(false, SYNC_REP_WAIT_FLUSH);
|
||||
@ -543,7 +543,7 @@ SyncRepWakeQueue(bool all, int mode)
|
||||
/*
|
||||
* Assume the queue is ordered by LSN
|
||||
*/
|
||||
if (!all && XLByteLT(walsndctl->lsn[mode], proc->waitLSN))
|
||||
if (!all && walsndctl->lsn[mode] < proc->waitLSN)
|
||||
return numprocs;
|
||||
|
||||
/*
|
||||
@ -640,7 +640,7 @@ SyncRepQueueIsOrderedByLSN(int mode)
|
||||
* Check the queue is ordered by LSN and that multiple procs don't
|
||||
* have matching LSNs
|
||||
*/
|
||||
if (XLByteLE(proc->waitLSN, lastLSN))
|
||||
if (proc->waitLSN <= lastLSN)
|
||||
return false;
|
||||
|
||||
lastLSN = proc->waitLSN;
|
||||
|
@ -914,7 +914,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
|
||||
}
|
||||
|
||||
/* Update state for write */
|
||||
XLByteAdvance(recptr, byteswritten);
|
||||
recptr += byteswritten;
|
||||
|
||||
recvOff += byteswritten;
|
||||
nbytes -= byteswritten;
|
||||
@ -933,7 +933,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
|
||||
static void
|
||||
XLogWalRcvFlush(bool dying)
|
||||
{
|
||||
if (XLByteLT(LogstreamResult.Flush, LogstreamResult.Write))
|
||||
if (LogstreamResult.Flush < LogstreamResult.Write)
|
||||
{
|
||||
/* use volatile pointer to prevent code rearrangement */
|
||||
volatile WalRcvData *walrcv = WalRcv;
|
||||
@ -944,7 +944,7 @@ XLogWalRcvFlush(bool dying)
|
||||
|
||||
/* Update shared-memory status */
|
||||
SpinLockAcquire(&walrcv->mutex);
|
||||
if (XLByteLT(walrcv->receivedUpto, LogstreamResult.Flush))
|
||||
if (walrcv->receivedUpto < LogstreamResult.Flush)
|
||||
{
|
||||
walrcv->latestChunkStart = walrcv->receivedUpto;
|
||||
walrcv->receivedUpto = LogstreamResult.Flush;
|
||||
@ -1016,8 +1016,8 @@ XLogWalRcvSendReply(bool force, bool requestReply)
|
||||
* probably OK.
|
||||
*/
|
||||
if (!force
|
||||
&& XLByteEQ(writePtr, LogstreamResult.Write)
|
||||
&& XLByteEQ(flushPtr, LogstreamResult.Flush)
|
||||
&& writePtr == LogstreamResult.Write
|
||||
&& flushPtr == LogstreamResult.Flush
|
||||
&& !TimestampDifferenceExceeds(sendTime, now,
|
||||
wal_receiver_status_interval * 1000))
|
||||
return;
|
||||
@ -1126,7 +1126,7 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
|
||||
|
||||
/* Update shared-memory status */
|
||||
SpinLockAcquire(&walrcv->mutex);
|
||||
if (XLByteLT(walrcv->latestWalEnd, walEnd))
|
||||
if (walrcv->latestWalEnd < walEnd)
|
||||
walrcv->latestWalEndTime = sendTime;
|
||||
walrcv->latestWalEnd = walEnd;
|
||||
walrcv->lastMsgSendTime = sendTime;
|
||||
|
@ -326,7 +326,7 @@ GetReplicationApplyDelay(void)
|
||||
|
||||
replayPtr = GetXLogReplayRecPtr(NULL);
|
||||
|
||||
if (XLByteEQ(receivePtr, replayPtr))
|
||||
if (receivePtr == replayPtr)
|
||||
return 0;
|
||||
|
||||
TimestampDifference(GetCurrentChunkReplayStartTime(),
|
||||
|
@ -471,7 +471,7 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
* WAL segment.
|
||||
*/
|
||||
if (!XLogRecPtrIsInvalid(switchpoint) &&
|
||||
XLByteLT(switchpoint, cmd->startpoint))
|
||||
switchpoint < cmd->startpoint)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errmsg("requested starting point %X/%X on timeline %u is not in this server's history",
|
||||
@ -497,7 +497,7 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
|
||||
/* If there is nothing to stream, don't even enter COPY mode */
|
||||
if (!sendTimeLineIsHistoric ||
|
||||
XLByteLT(cmd->startpoint, sendTimeLineValidUpto))
|
||||
cmd->startpoint < sendTimeLineValidUpto)
|
||||
{
|
||||
/*
|
||||
* When we first start replication the standby will be behind the primary.
|
||||
@ -520,7 +520,7 @@ StartReplication(StartReplicationCmd *cmd)
|
||||
* Don't allow a request to stream from a future point in WAL that
|
||||
* hasn't been flushed to disk in this server yet.
|
||||
*/
|
||||
if (XLByteLT(FlushPtr, cmd->startpoint))
|
||||
if (FlushPtr < cmd->startpoint)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errmsg("requested starting point %X/%X is ahead of the WAL flush position of this server %X/%X",
|
||||
@ -1249,7 +1249,7 @@ retry:
|
||||
}
|
||||
|
||||
/* Update state for read */
|
||||
XLByteAdvance(recptr, readbytes);
|
||||
recptr += readbytes;
|
||||
|
||||
sendOff += readbytes;
|
||||
nbytes -= readbytes;
|
||||
@ -1384,11 +1384,11 @@ XLogSend(bool *caughtup)
|
||||
|
||||
history = readTimeLineHistory(ThisTimeLineID);
|
||||
sendTimeLineValidUpto = tliSwitchPoint(sendTimeLine, history);
|
||||
Assert(XLByteLE(sentPtr, sendTimeLineValidUpto));
|
||||
Assert(sentPtr <= sendTimeLineValidUpto);
|
||||
list_free_deep(history);
|
||||
|
||||
/* the switchpoint should be >= current send pointer */
|
||||
if (!XLByteLE(sentPtr, sendTimeLineValidUpto))
|
||||
/* the current send pointer should be <= the switchpoint */
|
||||
if (!(sentPtr <= sendTimeLineValidUpto))
|
||||
elog(ERROR, "server switched off timeline %u at %X/%X, but walsender already streamed up to %X/%X",
|
||||
sendTimeLine,
|
||||
(uint32) (sendTimeLineValidUpto >> 32),
|
||||
@ -1420,7 +1420,7 @@ XLogSend(bool *caughtup)
|
||||
* If this is a historic timeline and we've reached the point where we
|
||||
* forked to the next timeline, stop streaming.
|
||||
*/
|
||||
if (sendTimeLineIsHistoric && XLByteLE(sendTimeLineValidUpto, sentPtr))
|
||||
if (sendTimeLineIsHistoric && sendTimeLineValidUpto <= sentPtr)
|
||||
{
|
||||
/* close the current file. */
|
||||
if (sendFile >= 0)
|
||||
@ -1436,8 +1436,8 @@ XLogSend(bool *caughtup)
|
||||
}
|
||||
|
||||
/* Do we have any work to do? */
|
||||
Assert(XLByteLE(sentPtr, SendRqstPtr));
|
||||
if (XLByteLE(SendRqstPtr, sentPtr))
|
||||
Assert(sentPtr <= SendRqstPtr);
|
||||
if (SendRqstPtr <= sentPtr)
|
||||
{
|
||||
*caughtup = true;
|
||||
return;
|
||||
@ -1456,10 +1456,10 @@ XLogSend(bool *caughtup)
|
||||
*/
|
||||
startptr = sentPtr;
|
||||
endptr = startptr;
|
||||
XLByteAdvance(endptr, MAX_SEND_SIZE);
|
||||
endptr += MAX_SEND_SIZE;
|
||||
|
||||
/* if we went beyond SendRqstPtr, back off */
|
||||
if (XLByteLE(SendRqstPtr, endptr))
|
||||
if (SendRqstPtr <= endptr)
|
||||
{
|
||||
endptr = SendRqstPtr;
|
||||
if (sendTimeLineIsHistoric)
|
||||
@ -1968,7 +1968,7 @@ GetOldestWALSendPointer(void)
|
||||
if (recptr.xlogid == 0 && recptr.xrecoff == 0)
|
||||
continue;
|
||||
|
||||
if (!found || XLByteLT(recptr, oldest))
|
||||
if (!found || recptr < oldest)
|
||||
oldest = recptr;
|
||||
found = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user