From 02b68eec1227dd24a0b09f6a0771a47851ff593e Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Tue, 28 Oct 2025 06:35:43 +0000
Subject: [PATCH v1 15/20] make use of XLogRecPtrIsInvalid in slot.c

---
 src/backend/replication/slot.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
 100.0% src/backend/replication/

diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 1e9f4602c69..a1df3740851 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -1270,15 +1270,15 @@ ReplicationSlotsComputeRequiredLSN(void)
 		 */
 		if (persistency == RS_PERSISTENT)
 		{
-			if (last_saved_restart_lsn != InvalidXLogRecPtr &&
+			if (!XLogRecPtrIsInvalid(last_saved_restart_lsn) &&
 				restart_lsn > last_saved_restart_lsn)
 			{
 				restart_lsn = last_saved_restart_lsn;
 			}
 		}
 
-		if (restart_lsn != InvalidXLogRecPtr &&
-			(min_required == InvalidXLogRecPtr ||
+		if (!XLogRecPtrIsInvalid(restart_lsn) &&
+			(XLogRecPtrIsInvalid(min_required) ||
 			 restart_lsn < min_required))
 			min_required = restart_lsn;
 	}
@@ -1350,17 +1350,17 @@ ReplicationSlotsComputeLogicalRestartLSN(void)
 		 */
 		if (persistency == RS_PERSISTENT)
 		{
-			if (last_saved_restart_lsn != InvalidXLogRecPtr &&
+			if (!XLogRecPtrIsInvalid(last_saved_restart_lsn) &&
 				restart_lsn > last_saved_restart_lsn)
 			{
 				restart_lsn = last_saved_restart_lsn;
 			}
 		}
 
-		if (restart_lsn == InvalidXLogRecPtr)
+		if (XLogRecPtrIsInvalid(restart_lsn))
 			continue;
 
-		if (result == InvalidXLogRecPtr ||
+		if (XLogRecPtrIsInvalid(result) ||
 			restart_lsn < result)
 			result = restart_lsn;
 	}
@@ -1573,8 +1573,8 @@ ReplicationSlotReserveWal(void)
 	ReplicationSlot *slot = MyReplicationSlot;
 
 	Assert(slot != NULL);
-	Assert(slot->data.restart_lsn == InvalidXLogRecPtr);
-	Assert(slot->last_saved_restart_lsn == InvalidXLogRecPtr);
+	Assert(XLogRecPtrIsInvalid(slot->data.restart_lsn));
+	Assert(XLogRecPtrIsInvalid(slot->last_saved_restart_lsn));
 
 	/*
 	 * The replication slot mechanism is used to prevent removal of required
@@ -1755,7 +1755,7 @@ DetermineSlotInvalidationCause(uint32 possible_causes, ReplicationSlot *s,
 
 	if (possible_causes & RS_INVAL_WAL_REMOVED)
 	{
-		if (initial_restart_lsn != InvalidXLogRecPtr &&
+		if (!XLogRecPtrIsInvalid(initial_restart_lsn) &&
 			initial_restart_lsn < oldestLSN)
 			return RS_INVAL_WAL_REMOVED;
 	}
-- 
2.34.1

