pg_upgrade --check doesn't check pg_pltemplate modifications

From: Tomas Barton <barton(dot)tomas(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: pg_upgrade --check doesn't check pg_pltemplate modifications
Date: 2022-01-16 13:05:23
Message-ID: CAPV2KRg3752VbyjTtkEeACNbqRtT82TqsMfioo4nVgY8U+Cs=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

when upgrading postgresql 12 -> 13 the pg_upgrade --check doesn't
sufficiently check for pg_pltemplate modifications (at least in version
13.5-1.pgdg110+1).

There's been a discussion on the mailing list
https://postgrespro.com/list/thread-id/2521269 regarding this topic. But it
doesn't seem to be implemented in the upgrade process.

Here's a simple bash script that checks for pg_pltemplate modifications on
each database:

for db in $(psql -tc "SELECT datname FROM pg_database;")
do
if [[ "${db}" != "template0" ]]; then
dump=$(pg_dump --schema-only --quote-all-identifiers ${db} | grep
pg_pltemplate)
if [ ! -z "$dump" ]; then
echo "ERROR: ${db} contains pg_pltemplate modifications. pg_upgrade
will fail"
exit 1
fi
fi
done
echo "OK"

Any non-default GRANT/REVOKE like these:

REVOKE SELECT ON TABLE "pg_catalog"."pg_pltemplate" FROM PUBLIC;
GRANT SELECT ON TABLE "pg_catalog"."pg_pltemplate" TO "reader";

would break the upgrade process, even though the pg_upgrade --check says:

*Clusters are compatible*

then upgrade (at least with --link) fails

pg_restore: error: could not execute query: ERROR: relation
"pg_catalog.pg_pltemplate" does not exist

Including such checks in the upgrade process might make the upgrade path
much easier.

Tomas Barton

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mario Emmenlauer 2022-01-16 15:06:45 Re: BUG #17365: Error: redefinition of 'stat' in win32_port.h when including postgres.h
Previous Message Alexander Lakhin 2022-01-16 06:00:01 Re: BUG #17116: Assert failed in SerialSetActiveSerXmin() on commit of parallelized serializable transaction