From 51daa71e7d3eb39c08894913a1401ad613747b4b Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Thu, 15 Oct 2026 00:11:11 -0400 Subject: [PATCH v3 3/3] pg_upgrade: Test a stored setting unknown to the new cluster Insert a role setting with a name no server knows, and verify that --check fails. --- src/bin/pg_upgrade/t/002_pg_upgrade.pl | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl index be57b2d838c..d12901d67e1 100644 --- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl +++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl @@ -597,6 +597,39 @@ SKIP: # And drop it, so we can continue $oldnode->start; $oldnode->safe_psql('postgres', 'DROP DATABASE regression_invalid'); + +# Store a role setting that the new cluster doesn't know, which would make +# the restore fail. The old cluster wouldn't accept it either, so insert it +# directly. +$oldnode->safe_psql( + 'postgres', qq( + CREATE ROLE regress_upgrade_setting; + INSERT INTO pg_db_role_setting + SELECT 0, oid, '{no_such_setting=on}' FROM pg_roles + WHERE rolname = 'regress_upgrade_setting'; +)); +$oldnode->stop; + +command_checks_all( + [ + 'pg_upgrade', '--no-sync', + '--old-datadir' => $oldnode->data_dir, + '--new-datadir' => $newnode->data_dir, + '--old-bindir' => $oldbindir, + '--new-bindir' => $newbindir, + '--socketdir' => $newnode->host, + '--old-port' => $oldnode->port, + '--new-port' => $newnode->port, + $mode, '--check', + ], + 1, + [qr/settings for some roles, databases, or functions/], + [qr/^$/], + 'stored setting unknown to the new cluster causes failure'); +rmtree($newnode->data_dir . "/pg_upgrade_output.d"); + +$oldnode->start; +$oldnode->safe_psql('postgres', 'DROP ROLE regress_upgrade_setting'); $oldnode->stop; # --check command works here, cleans up pg_upgrade_output.d. -- 2.37.1 (Apple Git-137.1)