Fix incorrect assignment of InvalidXLogRecPtr to a non-LSN variable.
authorFujii Masao <[email protected]>
Wed, 12 Nov 2025 23:44:33 +0000 (08:44 +0900)
committerFujii Masao <[email protected]>
Wed, 12 Nov 2025 23:44:33 +0000 (08:44 +0900)
pg_logical_slot_get_changes_guts() previously assigned InvalidXLogRecPtr to
the local variable upto_nchanges, which is of type int32, not XLogRecPtr.
While this caused no functional issue since InvalidXLogRecPtr is defined as 0,
it was semantically incorrect.

This commit fixes the issue by updating pg_logical_slot_get_changes_guts()
to set upto_nchanges to 0 instead of InvalidXLogRecPtr.

No backpatch is needed, as the previous behavior was harmless.

Author: Fujii Masao <[email protected]>
Reviewed-by: Steven Niu <[email protected]>
Reviewed-by: Xuneng Zhou <[email protected]>
Discussion: https://postgr.es/m/CAHGQGwHKHuR5NGnGxU3+ebz7cbC1ZAR=AgG4Bueq==Lj6iX8Sw@mail.gmail.com

src/backend/replication/logical/logicalfuncs.c

index 49b2aef3c743b9ce5bc6347474f256a983db2214..25b2b795925e6ee9ecb1ff65da7b66a6db2c92a4 100644 (file)
@@ -129,7 +129,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
                upto_lsn = PG_GETARG_LSN(1);
 
        if (PG_ARGISNULL(2))
-               upto_nchanges = InvalidXLogRecPtr;
+               upto_nchanges = 0;
        else
                upto_nchanges = PG_GETARG_INT32(2);