]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use XLogRecPtrIsValid() consistently for WAL position checks
authorFujii Masao <fujii@postgresql.org>
Thu, 16 Apr 2026 14:02:34 +0000 (23:02 +0900)
committerFujii Masao <fujii@postgresql.org>
Thu, 16 Apr 2026 14:02:34 +0000 (23:02 +0900)
Commit a2b02293bc6 switched various checks to use XLogRecPtrIsValid(),
but later changes reintroduced XLogRecPtrIsInvalid() and direct comparisons
with InvalidXLogRecPtr.

This commit replaces those uses with XLogRecPtrIsValid() for better
readability and consistency.

Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Xiaopeng Wang <wxp_728@163.com>
Reviewed-by: Amul Sul <sulamul@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CALDaNm16knMFtcqyAG3XYSkyagmVXfhaR0T=hau8UTAU0+eLQQ@mail.gmail.com

src/backend/commands/repack_worker.c
src/backend/replication/walreceiver.c
src/bin/pg_waldump/archive_waldump.c

index 5bd020e018439c9176f421dba13e48a20f9d5d75..362e0766c4125880fe4aebb04f8c27e3dc469aeb 100644 (file)
@@ -268,7 +268,7 @@ repack_setup_logical_decoding(Oid relid)
        ctx->reader->routine.page_read = read_local_xlog_page_no_wait;
 
        /* Some WAL records should have been read. */
-       Assert(ctx->reader->EndRecPtr != InvalidXLogRecPtr);
+       Assert(XLogRecPtrIsValid(ctx->reader->EndRecPtr));
 
        /*
         * Initialize repack_current_segment so that we can notice WAL segment
index 5ee6431091e1d12f731b5f23297eb1ef59b19b55..8185412a8103eb044aefea6788c576ba03a10981 100644 (file)
@@ -1169,8 +1169,8 @@ XLogWalRcvSendReply(bool force, bool requestReply, bool checkApply)
        /* Construct a new message */
        writePtr = LogstreamResult.Write;
        flushPtr = LogstreamResult.Flush;
-       applyPtr = (latestApplyPtr == InvalidXLogRecPtr) ?
-               GetXLogReplayRecPtr(NULL) : latestApplyPtr;
+       applyPtr = XLogRecPtrIsValid(latestApplyPtr) ?
+               latestApplyPtr : GetXLogReplayRecPtr(NULL);
 
        resetStringInfo(&reply_message);
        pq_sendbyte(&reply_message, PqReplMsg_StandbyStatusUpdate);
index 78b03bc1f85c09d3b518836adf5e9967803db86e..79915c0a0ce96083d4bad0b9a78c54c02406eb63 100644 (file)
@@ -216,11 +216,11 @@ init_archive_reader(XLogDumpPrivate *privateInfo,
         * With the WAL segment size available, we can now initialize the
         * dependent start and end segment numbers.
         */
-       Assert(!XLogRecPtrIsInvalid(privateInfo->startptr));
+       Assert(XLogRecPtrIsValid(privateInfo->startptr));
        XLByteToSeg(privateInfo->startptr, privateInfo->start_segno,
                                privateInfo->segsize);
 
-       if (!XLogRecPtrIsInvalid(privateInfo->endptr))
+       if (XLogRecPtrIsValid(privateInfo->endptr))
                XLByteToSeg(privateInfo->endptr, privateInfo->end_segno,
                                        privateInfo->segsize);