Skip to content

Commit

Permalink
No pg_partman update from <5.X during major upgrade (#962)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hughcapet authored Jan 15, 2024
1 parent 4ff0bcb commit 91afafb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions postgres-appliance/major_upgrade/pg_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 91afafb

Please sign in to comment.