From 288af0403e003ff858e812238245380480c44e57 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Mon, 10 Nov 2025 19:45:21 +0200
Subject: [PATCH 2/2] Add warning to pg_controldata on PG_CONTROL_VERSION
 mismatch

---
 src/bin/pg_controldata/pg_controldata.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 5c77f40313b..79f78d5fec9 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -167,7 +167,12 @@ main(int argc, char *argv[])
 
 	/* get a copy of the control file */
 	ControlFile = get_controlfile(DataDir, &crc_ok);
-	if (!crc_ok)
+	if (ControlFile->pg_control_version != PG_CONTROL_VERSION)
+	{
+		pg_log_warning("control file's version does not match the version understood by this program");
+		pg_log_warning_detail("Either the control file is corrupt, or it has been created with a different version "
+							  "of PostgreSQL.  The results below are untrustworthy.");
+	} else if (!crc_ok)
 	{
 		pg_log_warning("calculated CRC checksum does not match value stored in control file");
 		pg_log_warning_detail("Either the control file is corrupt, or it has a different layout than this program "
-- 
2.47.3

