From c12c1d6c66514ae66fbe5436fcbb435e310bfda5 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Sun, 20 Sep 2026 13:01:15 +0300
Subject: [PATCH 1/1] Fix pg_upgrade from version 9.2

Commit 7f25eccf41 added a cross-check between pg_database.datminmxid
and oldestMulti, but because PostgreSQL 9.2 doesn't have datminmxid,
it broke upgrade from version 9.2.  Disable the check when upgrading
from 9.2 to fix.

This is for REL_19_STABLE only.  Earlier versions don't have the check,
and on 'master' we no longer support upgrading from version 9.2.

Reported-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://www.postgresql.org/message-id/baef33d6-0416-48db-8e4d-0529a10a101a@dunslane.net
---
 src/bin/pg_upgrade/check.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 5b8c6ee145f..affc9e3c6cf 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -2758,6 +2758,15 @@ check_for_oldestxid_consistency(ClusterInfo *cluster)
 	int			i_datfrozenxid;
 	int			i_datminmxid;
 
+	/*
+	 * Version 9.2 didn't have datminmxid.  We could still cross-check
+	 * datfrozenxid, but doesn't seem worth it since we're primarily worried
+	 * about the rewriting of the multixact SLRUs losing data if the
+	 * oldestMulti is set incorrectly.
+	 */
+	if (GET_MAJOR_VERSION(old_cluster.major_version) < 903)
+		return;
+
 	prep_status("Checking oldestXID and oldestMultiXid consistency");
 
 	conn_template1 = connectToServer(cluster, "template1");
-- 
2.47.3

