Re: Use XLogRecPtrIsValid() instead of negated XLogRecPtrIsInvalid

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use XLogRecPtrIsValid() instead of negated XLogRecPtrIsInvalid
Date: 2026-04-10 14:46:39
Message-ID: CAHGQGwEuEd2StEYuP9vj+jCFT=hQbX8xcQeq8=Kj8r9xT3vmyg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Apr 10, 2026 at 3:11 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> Hi,
>
> This small cleanup patch updates src/bin/pg_waldump/archive_waldump.c
> to use the recently introduced XLogRecPtrIsValid() helper instead of
> negating XLogRecPtrIsInvalid(). The current code uses double-negative
> checks such as:
> Assert(!XLogRecPtrIsInvalid(privateInfo->startptr));
> if (!XLogRecPtrIsInvalid(privateInfo->endptr))
>
> This patch changes them to:
> Assert(XLogRecPtrIsValid(privateInfo->startptr));
> if (XLogRecPtrIsValid(privateInfo->endptr))
>
> This improves readability without changing behavior. The attached
> patch has the changes for the same.

Commit a2b02293bc6 switched various places to use XLogRecPtrIsValid(),
but it looks like later commits accidentally introduced uses of
XLogRecPtrIsInvalid() again. So +1 for this change.

Also, that commit replaced direct comparisons with InvalidXLogRecPtr with
XLogRecPtrIsValid(). I noticed two such comparisons [1]. Should these be
updated as well?

Regards,

[1]
$ git grep -E "[=\!]= InvalidXLogRecPtr"
src/backend/commands/repack_worker.c: Assert(ctx->reader->EndRecPtr
!= InvalidXLogRecPtr);
src/backend/replication/walreceiver.c: applyPtr = (latestApplyPtr ==
InvalidXLogRecPtr) ?

--
Fujii Masao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-04-10 14:49:42 Re: Documenting coding style
Previous Message Andrew Dunstan 2026-04-10 14:45:44 Re: Documenting coding style