From fc0d0ce978752493868496be6558fa17b7c4c3cf Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 23 Feb 2025 14:16:26 -0500 Subject: [PATCH] Ignore hash's relallvisible when checking pg_upgrade from pre-v10. Our cross-version upgrade tests have been failing for some pre-v10 source versions since commit 1fd1bd871. This turns out to be because relallvisible may change for tables that have hash indexes, because the upgrade process forcibly reindexes such indexes to deal with the changes made in v10. Fortunately, the set of tables that have such indexes is small and won't change anymore in those branches. So just hack up AdjustUpgrade.pm to not compare the relallvisible values of those specific tables. While here, also tighten the regex that suppresses comparison of version fields. Discussion: https://postgr.es/m/812817.1740277228@sss.pgh.pa.us --- .../perl/PostgreSQL/Test/AdjustUpgrade.pm | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm index 64f1f910ebf..0a707c69c5c 100644 --- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm +++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm @@ -296,8 +296,8 @@ sub adjust_old_dumpfile # Same with version argument to pg_restore_relation_stats() or # pg_restore_attribute_stats(). - $dump =~ s ['version', '\d+'::integer,] - ['version', '000000'::integer,]mg; + $dump =~ s {(^\s+'version',) '\d+'::integer,$} + {$1 '000000'::integer,}mg; if ($old_version < 16) { @@ -338,6 +338,18 @@ sub adjust_old_dumpfile /$1 EXECUTE FUNCTION/mgx; } + # During pg_upgrade, we reindex hash indexes if the source is pre-v10. + # This may change their tables' relallvisible values, so don't compare + # those. + if ($old_version < 10) + { + $dump =~ s/ + (^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\( + \s+'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass, + [^;]*'relallvisible',)\s'\d+'::integer + /$1 ''::integer/mgx; + } + if ($old_version lt '9.6') { # adjust some places where we don't print so many parens anymore @@ -633,8 +645,8 @@ sub adjust_new_dumpfile # Same with version argument to pg_restore_relation_stats() or # pg_restore_attribute_stats(). - $dump =~ s ['version', '\d+'::integer,] - ['version', '000000'::integer,]mg; + $dump =~ s {(^\s+'version',) '\d+'::integer,$} + {$1 '000000'::integer,}mg; # pre-v16 dumps do not know about XMLSERIALIZE(NO INDENT). if ($old_version < 16) @@ -673,6 +685,18 @@ sub adjust_new_dumpfile $dump =~ s/^SET default_table_access_method = heap;\n//mg; } + # During pg_upgrade, we reindex hash indexes if the source is pre-v10. + # This may change their tables' relallvisible values, so don't compare + # those. + if ($old_version < 10) + { + $dump =~ s/ + (^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\( + \s+'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass, + [^;]*'relallvisible',)\s'\d+'::integer + /$1 ''::integer/mgx; + } + # dumps from pre-9.6 dblink may include redundant ACL settings if ($old_version lt '9.6') { -- 2.30.2