Re: Upper limit arguments of pg_logical_slot_xxx_changes functionsaccept invalid values - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Upper limit arguments of pg_logical_slot_xxx_changes functionsaccept invalid values
Date
Msg-id CA+TgmobS9r2a3uLq6_xUP-LjZXWqbsE=MGUR2pDCv+FSbc_8PQ@mail.gmail.com
Whole thread Raw
In response to Upper limit arguments of pg_logical_slot_xxx_changes functions acceptinvalid values  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Upper limit arguments of pg_logical_slot_xxx_changes functionsaccept invalid values
List pgsql-hackers
On Wed, Jul 11, 2018 at 8:58 PM, Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> While reading the replication slot codes, I found a wrong assignment
> in pg_logical_slot_get_changes_guts() function as follows.
>
>         if (PG_ARGISNULL(2))
>                upto_nchanges = InvalidXLogRecPtr;
>         else
>                 upto_nchanges = PG_GETARG_INT32(2);
>
> Since the upto_nchanges is an integer value we should set 0 meaning
> unlimited instead of InvalidXLogRecPtr. Since InvalidXLogRecPtr is
> actually 0 this function works fine so far.

If somebody changes InvalidXLogRecPtr to (uint64)-1, then it breaks as
the code is written.  On the other hand, if somebody reverted
0ab9d1c4b31622e9176472b4276f3e9831e3d6ba, it would keep working as
written but break under your proposal.

I am not prepared to spend much time arguing about it, but I think we
should just leave this the way it is.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Deprecating, and scheduling removal of, pg_dump's tar format.
Next
From: Andres Freund
Date:
Subject: Re: How can we submit code patches that implement our (pending)patents?