Re: Executing pg_createsubscriber with a non-compatible control file

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Euler Taveira <euler(at)eulerto(dot)com>
Subject: Re: Executing pg_createsubscriber with a non-compatible control file
Date: 2025-10-10 06:07:42
Message-ID: aOiirvWJzwdVCXph@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 09, 2025 at 11:22:47AM -0700, Masahiko Sawada wrote:
> +1, sounds like a good idea to improve user experience. I think we can
> use the API in pg_combinebackup.c too since it has a similar function,
> read_pg_version_file().

Please find attached what I am finishing with. At the end, I have
designed an API that can be reused across the board for the following
tools that do the same things in the tree, removing some duplicated
code:
- pg_resetwal
- pg_upgrade
- pg_combinebackup

The routine that retrieves the contents gets a uint32 number, and it
is optionally possible to get the contents of PG_VERSION (pg_upgrade
wants that for tablespace paths, but that's really for pg_resetwal to
be able to show back buggy data):
extern uint32 get_pg_version(const char *datadir, char **version_str);

This support both the pre-v10 and the post-v10 version formats, for
pg_upgrade.

To ease comparisons with PG_MAJORVERSION_NUM, I have added a small
helper macro (see GET_PG_MAJORVERSION_NUM).

I have also applied the same method to pg_createsubscriber, on top of
that, to take care of my original issue. I have not looked at other
places where the same concept could be applied, at least it's a start.

Thoughts or comments?
--
Michael

Attachment Content-Type Size
v1-0001-Introduce-API-able-to-retrieve-contents-of-PG_VER.patch text/x-diff 4.7 KB
v1-0002-pg_upgrade-Use-PG_VERSION-generic-routine.patch text/x-diff 3.4 KB
v1-0003-pg_createsubscriber-Use-PG_VERSION-generic-routin.patch text/x-diff 1.9 KB
v1-0004-pg_combinebackup-use-PG_VERSION-generic-routine.patch text/x-diff 3.5 KB
v1-0005-pg_resetwal-use-PG_VERSION-generic-routine.patch text/x-diff 2.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-10-10 06:21:25 Incorrect version number given to sync_pgdata() in pg_combinebackup.c
Previous Message Sadhuprasad Patro 2025-10-10 05:52:55 Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions