public inbox for [email protected]
help / color / mirror / Atom feedFrom: vignesh C <[email protected]>
To: Fujii Masao <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Use XLogRecPtrIsValid() instead of negated XLogRecPtrIsInvalid
Date: Thu, 16 Apr 2026 16:25:31 +0530
Message-ID: <CALDaNm0MO0qSwN2tbEyzogocdV4COwGQs9_OD7r+P4GaWnac=g@mail.gmail.com> (raw)
In-Reply-To: <CAHGQGwGFP1AEQ1+=95LrVpUUOOPeebi13aEXXebSZ7bvWVT=wA@mail.gmail.com>
References: <CALDaNm16knMFtcqyAG3XYSkyagmVXfhaR0T=hau8UTAU0+eLQQ@mail.gmail.com>
<CAHGQGwEuEd2StEYuP9vj+jCFT=hQbX8xcQeq8=Kj8r9xT3vmyg@mail.gmail.com>
<CALDaNm0zJuUon52OEx5SpMoP8LEGJh+=PyYqwmcD7Zh97_dnJg@mail.gmail.com>
<CAHGQGwGFP1AEQ1+=95LrVpUUOOPeebi13aEXXebSZ7bvWVT=wA@mail.gmail.com>
On Thu, 16 Apr 2026 at 09:42, Fujii Masao <[email protected]> wrote:
>
> On Mon, Apr 13, 2026 at 4:10 PM vignesh C <[email protected]> wrote:
> > I felt these also should be updated, the attached v2 version patch
> > includes the changes for the same.
>
> Thanks for updating the patch!
>
> - applyPtr = (latestApplyPtr == InvalidXLogRecPtr) ?
> + applyPtr = (XLogRecPtrIsInvalid(latestApplyPtr)) ?
>
> XLogRecPtrIsValid() should be used here, instead?
Yes, that seems better, the attached v3 version patch has the changes
for the same.
Regards,
Vignesh
Attachments:
[application/octet-stream] v3-0001-Use-XLogRecPtr-validity-helper-macros-consistentl.patch (2.8K, 2-v3-0001-Use-XLogRecPtr-validity-helper-macros-consistentl.patch)
download | inline diff:
From 4da2338268f0c7524a2ff96c12c598512b3e019c Mon Sep 17 00:00:00 2001
From: Vignesh C <[email protected]>
Date: Fri, 10 Apr 2026 10:12:38 +0530
Subject: [PATCH v3] Use XLogRecPtr validity helper macros consistently
Replace direct comparisons against InvalidXLogRecPtr and negated
XLogRecPtrIsInvalid() checks with the corresponding
XLogRecPtrIsValid()/XLogRecPtrIsInvalid() helper macros.
This improves readability and consistency by using the dedicated
XLogRecPtr validity helpers throughout the code, with no intended
behavioral change.
---
src/backend/commands/repack_worker.c | 2 +-
src/backend/replication/walreceiver.c | 4 ++--
src/bin/pg_waldump/archive_waldump.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/backend/commands/repack_worker.c b/src/backend/commands/repack_worker.c
index 5bd020e0184..362e0766c41 100644
--- a/src/backend/commands/repack_worker.c
+++ b/src/backend/commands/repack_worker.c
@@ -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
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 5ee6431091e..5eab87625db 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -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);
diff --git a/src/bin/pg_waldump/archive_waldump.c b/src/bin/pg_waldump/archive_waldump.c
index 78b03bc1f85..79915c0a0ce 100644
--- a/src/bin/pg_waldump/archive_waldump.c
+++ b/src/bin/pg_waldump/archive_waldump.c
@@ -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);
--
2.43.0
view thread (9+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Use XLogRecPtrIsValid() instead of negated XLogRecPtrIsInvalid
In-Reply-To: <CALDaNm0MO0qSwN2tbEyzogocdV4COwGQs9_OD7r+P4GaWnac=g@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox