Re: Upper limit arguments of pg_logical_slot_xxx_changes functions accept invalid values

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Upper limit arguments of pg_logical_slot_xxx_changes functions accept invalid values
Date: 2018-08-14 01:00:49
Message-ID: CAD21AoDLKjC_dBh1UR6808oqm0kBNbTC9Jz_fM4jp0VZPuYrfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 28, 2018 at 2:00 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, Jul 11, 2018 at 8:58 PM, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)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 might be missing something but I think the setting either 0 or
negative values to it solves this problem. Since the upto_nchanges is
int32 we cannot build if somebody reverted
0ab9d1c4b31622e9176472b4276f3e9831e3d6ba.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2018-08-14 04:38:23 Re: Copy function for logical replication slots
Previous Message Masahiko Sawada 2018-08-14 00:31:23 Re: [HACKERS] Block level parallel vacuum