mirror of
https://github.com/postgres/postgres.git
synced 2026-06-10 09:10:33 -04:00
Replace literal 0 with InvalidXLogRecPtr for XLogRecPtr assignments
Use the proper constant InvalidXLogRecPtr instead of literal 0 when assigning XLogRecPtr variables and struct fields. This improves code clarity by making it explicit that these are invalid LSN values rather than ambiguous zero literals. Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/aRtd2dw8FO1nNX7k@ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
parent
71c1136989
commit
ec31744071
10 changed files with 21 additions and 21 deletions
|
|
@ -291,7 +291,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
|
|||
SplitPageLayout *dist = NULL,
|
||||
*ptr;
|
||||
BlockNumber oldrlink = InvalidBlockNumber;
|
||||
GistNSN oldnsn = 0;
|
||||
GistNSN oldnsn = InvalidXLogRecPtr;
|
||||
SplitPageLayout rootpg;
|
||||
bool is_rootsplit;
|
||||
int npage;
|
||||
|
|
@ -654,7 +654,7 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace,
|
|||
|
||||
/* Start from the root */
|
||||
firststack.blkno = GIST_ROOT_BLKNO;
|
||||
firststack.lsn = 0;
|
||||
firststack.lsn = InvalidXLogRecPtr;
|
||||
firststack.retry_from_parent = false;
|
||||
firststack.parent = NULL;
|
||||
firststack.downlinkoffnum = InvalidOffsetNumber;
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
|||
fps->stmt_ts = GetCurrentStatementStartTimestamp();
|
||||
fps->serializable_xact_handle = ShareSerializableXact();
|
||||
SpinLockInit(&fps->mutex);
|
||||
fps->last_xlog_end = 0;
|
||||
fps->last_xlog_end = InvalidXLogRecPtr;
|
||||
shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
|
||||
|
||||
/* We can skip the rest of this if we're not budgeting for any workers. */
|
||||
|
|
@ -530,7 +530,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
|
|||
|
||||
/* Reset a few bits of fixed parallel state to a clean state. */
|
||||
fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
|
||||
fps->last_xlog_end = 0;
|
||||
fps->last_xlog_end = InvalidXLogRecPtr;
|
||||
|
||||
/* Recreate error queues (if they exist). */
|
||||
if (pcxt->nworkers > 0)
|
||||
|
|
|
|||
|
|
@ -2060,7 +2060,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic)
|
|||
/* Have to write it ourselves */
|
||||
TRACE_POSTGRESQL_WAL_BUFFER_WRITE_DIRTY_START();
|
||||
WriteRqst.Write = OldPageRqstPtr;
|
||||
WriteRqst.Flush = 0;
|
||||
WriteRqst.Flush = InvalidXLogRecPtr;
|
||||
XLogWrite(WriteRqst, tli, false);
|
||||
LWLockRelease(WALWriteLock);
|
||||
pgWalUsage.wal_buffers_full++;
|
||||
|
|
@ -3077,7 +3077,7 @@ XLogBackgroundFlush(void)
|
|||
else
|
||||
{
|
||||
/* no flushing, this time round */
|
||||
WriteRqst.Flush = 0;
|
||||
WriteRqst.Flush = InvalidXLogRecPtr;
|
||||
}
|
||||
|
||||
#ifdef WAL_DEBUG
|
||||
|
|
@ -5207,7 +5207,7 @@ BootStrapXLOG(uint32 data_checksum_version)
|
|||
/* Insert the initial checkpoint record */
|
||||
recptr = ((char *) page + SizeOfXLogLongPHD);
|
||||
record = (XLogRecord *) recptr;
|
||||
record->xl_prev = 0;
|
||||
record->xl_prev = InvalidXLogRecPtr;
|
||||
record->xl_xid = InvalidTransactionId;
|
||||
record->xl_tot_len = SizeOfXLogRecord + SizeOfXLogRecordDataHeaderShort + sizeof(checkPoint);
|
||||
record->xl_info = XLOG_CHECKPOINT_SHUTDOWN;
|
||||
|
|
|
|||
|
|
@ -967,7 +967,7 @@ XLogPrefetcherBeginRead(XLogPrefetcher *prefetcher, XLogRecPtr recPtr)
|
|||
/* Book-keeping to avoid readahead on first read. */
|
||||
prefetcher->begin_ptr = recPtr;
|
||||
|
||||
prefetcher->no_readahead_until = 0;
|
||||
prefetcher->no_readahead_until = InvalidXLogRecPtr;
|
||||
|
||||
/* This will forget about any queued up records in the decoder. */
|
||||
XLogBeginRead(prefetcher->reader, recPtr);
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ static TimestampTz XLogReceiptTime = 0;
|
|||
static XLogSource XLogReceiptSource = XLOG_FROM_ANY;
|
||||
|
||||
/* Local copy of WalRcv->flushedUpto */
|
||||
static XLogRecPtr flushedUpto = 0;
|
||||
static XLogRecPtr flushedUpto = InvalidXLogRecPtr;
|
||||
static TimeLineID receiveTLI = 0;
|
||||
|
||||
/*
|
||||
|
|
@ -3918,7 +3918,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||
RequestXLogStreaming(tli, ptr, PrimaryConnInfo,
|
||||
PrimarySlotName,
|
||||
wal_receiver_create_temp_slot);
|
||||
flushedUpto = 0;
|
||||
flushedUpto = InvalidXLogRecPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -4096,7 +4096,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||
static int
|
||||
emode_for_corrupt_record(int emode, XLogRecPtr RecPtr)
|
||||
{
|
||||
static XLogRecPtr lastComplaint = 0;
|
||||
static XLogRecPtr lastComplaint = InvalidXLogRecPtr;
|
||||
|
||||
if (readSource == XLOG_FROM_PG_WAL && emode == LOG)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
|
|||
pg_read_barrier();
|
||||
Assert(dlist_node_is_detached(&MyProc->syncRepLinks));
|
||||
MyProc->syncRepState = SYNC_REP_NOT_WAITING;
|
||||
MyProc->waitLSN = 0;
|
||||
MyProc->waitLSN = InvalidXLogRecPtr;
|
||||
|
||||
/* reset ps display to remove the suffix */
|
||||
if (update_process_title)
|
||||
|
|
@ -1027,7 +1027,7 @@ SyncRepQueueIsOrderedByLSN(int mode)
|
|||
|
||||
Assert(mode >= 0 && mode < NUM_SYNC_REP_WAIT_MODE);
|
||||
|
||||
lastLSN = 0;
|
||||
lastLSN = InvalidXLogRecPtr;
|
||||
|
||||
dlist_foreach(iter, &WalSndCtl->SyncRepQueue[mode])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1122,8 +1122,8 @@ XLogWalRcvClose(XLogRecPtr recptr, TimeLineID tli)
|
|||
static void
|
||||
XLogWalRcvSendReply(bool force, bool requestReply)
|
||||
{
|
||||
static XLogRecPtr writePtr = 0;
|
||||
static XLogRecPtr flushPtr = 0;
|
||||
static XLogRecPtr writePtr = InvalidXLogRecPtr;
|
||||
static XLogRecPtr flushPtr = InvalidXLogRecPtr;
|
||||
XLogRecPtr applyPtr;
|
||||
TimestampTz now;
|
||||
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ InitProcess(void)
|
|||
MyProc->recoveryConflictPending = false;
|
||||
|
||||
/* Initialize fields for sync rep */
|
||||
MyProc->waitLSN = 0;
|
||||
MyProc->waitLSN = InvalidXLogRecPtr;
|
||||
MyProc->syncRepState = SYNC_REP_NOT_WAITING;
|
||||
dlist_node_init(&MyProc->syncRepLinks);
|
||||
|
||||
|
|
|
|||
|
|
@ -913,10 +913,10 @@ RewriteControlFile(void)
|
|||
|
||||
ControlFile.state = DB_SHUTDOWNED;
|
||||
ControlFile.checkPoint = ControlFile.checkPointCopy.redo;
|
||||
ControlFile.minRecoveryPoint = 0;
|
||||
ControlFile.minRecoveryPoint = InvalidXLogRecPtr;
|
||||
ControlFile.minRecoveryPointTLI = 0;
|
||||
ControlFile.backupStartPoint = 0;
|
||||
ControlFile.backupEndPoint = 0;
|
||||
ControlFile.backupStartPoint = InvalidXLogRecPtr;
|
||||
ControlFile.backupEndPoint = InvalidXLogRecPtr;
|
||||
ControlFile.backupEndRequired = false;
|
||||
|
||||
/*
|
||||
|
|
@ -1147,7 +1147,7 @@ WriteEmptyXLOG(void)
|
|||
/* Insert the initial checkpoint record */
|
||||
recptr = (char *) page + SizeOfXLogLongPHD;
|
||||
record = (XLogRecord *) recptr;
|
||||
record->xl_prev = 0;
|
||||
record->xl_prev = InvalidXLogRecPtr;
|
||||
record->xl_xid = InvalidTransactionId;
|
||||
record->xl_tot_len = SizeOfXLogRecord + SizeOfXLogRecordDataHeaderShort + sizeof(CheckPoint);
|
||||
record->xl_info = XLOG_CHECKPOINT_SHUTDOWN;
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
pg_log_info("source and target cluster are on the same timeline");
|
||||
rewind_needed = false;
|
||||
target_wal_endrec = 0;
|
||||
target_wal_endrec = InvalidXLogRecPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue