From 58f43ec0fbdc02a43f3f070b301ab0a264fa1013 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Thu, 6 Nov 2025 13:38:19 +0000
Subject: [PATCH v6 1/5] Introduce XLogRecPtrIsValid()

XLogRecPtrIsInvalid() is inconsistent with the affirmative form of other
*IsValid() macros and leads to awkward double negative.

This commit introduces XLogRecPtrIsValid() and adds a comment mentioning that
new code should use XLogRecPtrIsValid() instead of XLogRecPtrIsInvalid() and
that XLogRecPtrIsInvalid() could be deprecated in the future.
---
 src/include/access/xlogdefs.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
 100.0% src/include/access/

diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h
index 2397fb24115..b16b2a1c8a3 100644
--- a/src/include/access/xlogdefs.h
+++ b/src/include/access/xlogdefs.h
@@ -26,8 +26,16 @@ typedef uint64 XLogRecPtr;
  * record can begin at zero.
  */
 #define InvalidXLogRecPtr	0
-#define XLogRecPtrIsInvalid(r)	((r) == InvalidXLogRecPtr)
+#define XLogRecPtrIsValid(r) ((r) != InvalidXLogRecPtr)
 
+/*
+ * New code should use XLogRecPtrIsValid() instead of XLogRecPtrIsInvalid()
+ * for consistency with the affirmative form of other *IsValid() macros and to
+ * avoid awkward double negative.
+ * This macro is retained for convenience of third-party code but could
+ * be deprecated in the future.
+ */
+#define XLogRecPtrIsInvalid(r)	((r) == InvalidXLogRecPtr)
 /*
  * First LSN to use for "fake" LSNs.
  *
-- 
2.34.1

