From 91afafb7cf873239e421be9645b309549ed34c95 Mon Sep 17 00:00:00 2001 From: Polina Bungina <27892524+hughcapet@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:58:43 +0100 Subject: [PATCH] No pg_partman update from <5.X during major upgrade (#962) Due to the noticeable number of backward-incompatible changes in pg_parman 5.0, we better force users to prepare and check everything before actually upgrading the extension. So if performing major upgrade with pg_partman pre 5.X installed, we skip automatic update of it --- postgres-appliance/major_upgrade/pg_upgrade.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/postgres-appliance/major_upgrade/pg_upgrade.py b/postgres-appliance/major_upgrade/pg_upgrade.py index dee894b99..240c537e0 100644 --- a/postgres-appliance/major_upgrade/pg_upgrade.py +++ b/postgres-appliance/major_upgrade/pg_upgrade.py @@ -117,9 +117,15 @@ def update_extensions(self): for d in self._get_all_databases(): conn_kwargs['dbname'] = d with get_connection_cursor(**conn_kwargs) as cur: - cur.execute('SELECT quote_ident(extname) FROM pg_catalog.pg_extension') - for extname in cur.fetchall(): - query = 'ALTER EXTENSION {0} UPDATE'.format(extname[0]) + cur.execute('SELECT quote_ident(extname), extversion FROM pg_catalog.pg_extension') + for extname, version in cur.fetchall(): + # require manual update to 5.X+ + if extname == 'pg_partman' and int(version[0]) < 5: + logger.warning("Skipping update of '%s' in database=%s. " + "Extension version: %s. Consider manual update", + extname, d, version) + continue + query = 'ALTER EXTENSION {0} UPDATE'.format(extname) logger.info("Executing '%s' in the database=%s", query, d) try: cur.execute(query)