From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Upper limit arguments of pg_logical_slot_xxx_changes functions accept invalid values |
Date: | 2018-07-12 00:58:16 |
Message-ID: | CAD21AoByngb7O=_zdDG_HjZDHtE1W6Ka0mRZJmQLkpzWoFoCkQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
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. Also I surprised that
these functions accept to set negative values to upto_nchanges. The
upto_lsn argument is also the same; it also accepts an invalid lsn.
For safety maybe it's better to reject non-NULL invalid values.That
way, the behavior of these functions are consistent with what the
documentation says;
If upto_lsn is non-NULL, decoding will include only those
transactions which commit prior to the specified LSN. If upto_nchanges
is non-NULL, decoding will stop when the number of rows produced by
decoding exceeds the specified value.
Attached patch fixes them. Feedback is very welcome.
Regards,
--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
Attachment | Content-Type | Size |
---|---|---|
fix_logical_slot_changes_funcs.patch | application/octet-stream | 2.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tsunakawa, Takayuki | 2018-07-12 01:10:33 | RE: How can we submit code patches that implement our (pending) patents? |
Previous Message | Nico Williams | 2018-07-12 00:55:37 | Re: [HACKERS] [PATCH] WIP Add ALWAYS DEFERRED option for constraints |