0001-Refuse-upgrades-from-pre-9.0-clusters.patch

application/octet-stream

Filename: 0001-Refuse-upgrades-from-pre-9.0-clusters.patch
Type: application/octet-stream
Part: 0
Message: Re: [UNVERIFIED SENDER] pg_upgrade can result in early wraparound on databases with high transaction load

Patch

Format: format-patch
Series: patch 0001
Subject: Refuse upgrades from pre-9.0 clusters
File+
doc/src/sgml/ref/pgupgrade.sgml 1 1
src/bin/pg_upgrade/check.c 7 2
From d0b747eb43980e4e639fd3844357e0ccbffbd705 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <dgustafsson@postgresql.org>
Date: Thu, 16 May 2024 07:43:50 +0200
Subject: [PATCH] Refuse upgrades from pre-9.0 clusters

Commit 695b4a113ab added a dependency on retrieving oldestxid from
pg_control, which only exists in 9.0 and onwards, but the check for
8.4 as the oldest version was retained. Since there has been few if
any complaints of 8.4 upgrades not working, fix by setting 9.0 as
the oldest version supported rather than resurrecting 8.4 support.

Backpatch to all supported versions.

Discussion: https://postgr.es/m/1973418.1657040382@sss.pgh.pa.us
Backpatch-through: v12
---
 doc/src/sgml/ref/pgupgrade.sgml | 2 +-
 src/bin/pg_upgrade/check.c      | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index d401053edf..8add90e8ed 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -67,7 +67,7 @@ PostgreSQL documentation
  </para>
 
   <para>
-   pg_upgrade supports upgrades from 8.4.X and later to the current
+   pg_upgrade supports upgrades from 9.0.X and later to the current
    major release of <productname>PostgreSQL</productname>, including snapshot and beta releases.
   </para>
  </refsect1>
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index dc060418e5..05a94087c5 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -316,8 +316,13 @@ check_cluster_versions(void)
 	 * upgrades
 	 */
 
-	if (GET_MAJOR_VERSION(old_cluster.major_version) < 804)
-		pg_fatal("This utility can only upgrade from PostgreSQL version 8.4 and later.\n");
+	/*
+	 * The minimum version supported then this code shipped in a major version
+	 * was 8.4. This has since been raised to 9.0, but the support code for
+	 * dealing with 8.4 remains to avoid refactoring in a backbranch.
+	 */
+	if (GET_MAJOR_VERSION(old_cluster.major_version) < 900)
+		pg_fatal("This utility can only upgrade from PostgreSQL version 9.0 and later.\n");
 
 	/* Only current PG version is supported as a target */
 	if (GET_MAJOR_VERSION(new_cluster.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
-- 
2.39.3 (Apple Git-146)