From 0eeb8b4ad8288c2000e6478b0121e17c8f7596a7 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Tue, 28 Oct 2025 06:14:38 +0000 Subject: [PATCH v1 11/20] make use of XLogRecPtrIsInvalid in origin.c --- src/backend/replication/logical/origin.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 100.0% src/backend/replication/logical/ diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index bcd5d9aad62..3573a0cedca 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -984,8 +984,8 @@ replorigin_advance(RepOriginId node, /* initialize new slot */ LWLockAcquire(&free_state->lock, LW_EXCLUSIVE); replication_state = free_state; - Assert(replication_state->remote_lsn == InvalidXLogRecPtr); - Assert(replication_state->local_lsn == InvalidXLogRecPtr); + Assert(XLogRecPtrIsInvalid(replication_state->remote_lsn)); + Assert(XLogRecPtrIsInvalid(replication_state->local_lsn)); replication_state->roident = node; } @@ -1020,7 +1020,7 @@ replorigin_advance(RepOriginId node, */ if (go_backward || replication_state->remote_lsn < remote_commit) replication_state->remote_lsn = remote_commit; - if (local_commit != InvalidXLogRecPtr && + if (!XLogRecPtrIsInvalid(local_commit) && (go_backward || replication_state->local_lsn < local_commit)) replication_state->local_lsn = local_commit; LWLockRelease(&replication_state->lock); @@ -1064,7 +1064,7 @@ replorigin_get_progress(RepOriginId node, bool flush) LWLockRelease(ReplicationOriginLock); - if (flush && local_lsn != InvalidXLogRecPtr) + if (flush && !XLogRecPtrIsInvalid(local_lsn)) XLogFlush(local_lsn); return remote_lsn; @@ -1197,8 +1197,8 @@ replorigin_session_setup(RepOriginId node, int acquired_by) /* initialize new slot */ session_replication_state = &replication_states[free_slot]; - Assert(session_replication_state->remote_lsn == InvalidXLogRecPtr); - Assert(session_replication_state->local_lsn == InvalidXLogRecPtr); + Assert(XLogRecPtrIsInvalid(session_replication_state->remote_lsn)); + Assert(XLogRecPtrIsInvalid(session_replication_state->local_lsn)); session_replication_state->roident = node; } @@ -1282,7 +1282,7 @@ replorigin_session_get_progress(bool flush) local_lsn = session_replication_state->local_lsn; LWLockRelease(&session_replication_state->lock); - if (flush && local_lsn != InvalidXLogRecPtr) + if (flush && !XLogRecPtrIsInvalid(local_lsn)) XLogFlush(local_lsn); return remote_lsn; @@ -1454,7 +1454,7 @@ pg_replication_origin_session_progress(PG_FUNCTION_ARGS) remote_lsn = replorigin_session_get_progress(flush); - if (remote_lsn == InvalidXLogRecPtr) + if (XLogRecPtrIsInvalid(remote_lsn)) PG_RETURN_NULL(); PG_RETURN_LSN(remote_lsn); @@ -1543,7 +1543,7 @@ pg_replication_origin_progress(PG_FUNCTION_ARGS) remote_lsn = replorigin_get_progress(roident, flush); - if (remote_lsn == InvalidXLogRecPtr) + if (XLogRecPtrIsInvalid(remote_lsn)) PG_RETURN_NULL(); PG_RETURN_LSN(remote_lsn); -- 2.34.1