Re: Fix incorrect assignment of InvalidXLogRecPtr to a non-LSN variable.

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix incorrect assignment of InvalidXLogRecPtr to a non-LSN variable.
Date: 2025-11-12 09:14:39
Message-ID: CABPTF7WgbD106zbHt=d0__gdr2Ue+HcbVKY=75iPAzuqjvVXPw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Nov 12, 2025 at 4:23 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> Hi,
>
> I noticed that pg_logical_slot_get_changes_guts() assigns InvalidXLogRecPtr
> to the local variable upto_nchanges, even though it's not LSN variable
> (i.e., its type is int32, not XLogRecPtr). While this causes no functional issue
> since InvalidXLogRecPtr is defined as 0, it's semantically incorrect.
>
> I propose fixing this by setting upto_nchanges to 0 instead of
> InvalidXLogRecPtr.
> Attached is a patch implementing this change.
>
> Regards,
>
> --
> Fujii Masao

Good catch! I checked that no other similar misuses of
InvalidXLogRecPtr assigned to non-LSN variables were found in
logicalfuncs.c.

--
Best,
Xuneng

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-11-12 09:31:53 Re: SQL:2011 Application Time Update & Delete
Previous Message Dilip Kumar 2025-11-12 09:10:28 Re: Proposal: Conflict log history table for Logical Replication