pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add warning to pg_controldata on PG_CONTROL_VERSION mismatch
Date: Tue, 11 Nov 2025 17:08:25 +0000
Message-ID: <E1vIrqz-0066AU-19@gemulon.postgresql.org> (raw)

Add warning to pg_controldata on PG_CONTROL_VERSION mismatch

If you run pg_controldata on a cluster that has been initialized with
different PG_CONTROL_VERSION than what the pg_controldata program has
been compiled with, pg_controldata will still try to interpret the
control file, but the result is likely to be somewhat nonsensical. How
nonsensical it is depends on the differences between the versions. If
sizeof(ControlFileData) differs between the versions, the CRC will not
match and you get a warning of that, but otherwise you get no
warning.

Looking back at recent PG_CONTROL_VERSION updates, all changes that
would mess up the printed values have also changed
sizeof(ControlFileData), but there's no guarantee of that in future
versions.

Add an explicit check and warning for version number mismatch before
the CRC check. That way, you get a more clear warning if you use the
pg_controldata binary from wrong version, and if we change the control
file in the future in a way that doesn't change
sizeof(ControlFileData), this ensures that you get a warning in that
case too.

Discussion: https://www.postgresql.org/message-id/2afded89-f9f0-4191-84d8-8b8668e029a1@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6956bca515e2a07a16c6d68b208766e97b275ddc

Modified Files
--------------
src/bin/pg_controldata/pg_controldata.c        |  9 ++++++++-
src/bin/pg_controldata/t/001_pg_controldata.pl | 14 ++++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)



Message-ID: <E1vIrqz-0066AU-19@gemulon.postgresql.org>
Permalink:  ../E1vIrqz-0066AU-19@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vIrqz-0066AU-19@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add warning to pg_controldata on PG_CONTROL_VERSION mismatch
  In-Reply-To: <E1vIrqz-0066AU-19@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox