Re: Two issues with version checks in CREATE SUBSCRIPTION - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Two issues with version checks in CREATE SUBSCRIPTION
Date
Msg-id CAHGQGwGjX+699ReemM7YY1XAskJfQeKPn2Mtb4cg8Z2O80x-4w@mail.gmail.com
Whole thread Raw
In response to RE: Two issues with version checks in CREATE SUBSCRIPTION  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
List pgsql-hackers
On Tue, Dec 23, 2025 at 2:55 PM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:
>
> Dear Fujii-san,
>
> Thanks for the patch! They basically look good to me.

Thanks to Amit and Hayato for the review! I'll commit the patches.


> > First, in subscriptioncmds.c this check rejects enabling retain_dead_tuples
> > when the publisher is running an older version. However, the comparison uses
> > 19000 as v19 value. Since server versions are encoded as 190000 for v19,
> > this appears to be a typo and allows the option to be enabled unexpectedly
> > on pre-v19 publishers. The attached 0001 patch fixes this by correcting
> > the version constant.
>
> One idea is to introduce a constant like RETAIN_DEAD_TUPLES_MIN_VERSION_NUM,
> which avoids similar typo. Is it overengineering?

I don't think this would be a sufficient guard against typos. Even with
this approach, we could still introduce a mistake like the following,
for example:

    #define RETAIN_DEAD_TUPLES_MIN_VERSION_NUM 19000

Also, there are many existing checks that compare against version constants
like 190000, so changing the code to use such a macro everywhere feels
like overkill to me.

Regards,

--
Fujii Masao



pgsql-hackers by date:

Previous
From: Alexander Pyhalov
Date:
Subject: Re: Asynchronous MergeAppend
Next
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: [Patch] add new parameter to pg_replication_origin_session_setup