Ignore hash's relallvisible when checking pg_upgrade from pre-v10.
authorTom Lane <[email protected]>
Sun, 23 Feb 2025 19:16:26 +0000 (14:16 -0500)
committerTom Lane <[email protected]>
Sun, 23 Feb 2025 19:16:26 +0000 (14:16 -0500)
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

src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm

index 64f1f910ebf20d3c6667b2efcfaf234639ee38fa..0a707c69c5c5b5bad14fcfb409561a47af4e2ea4 100644 (file)
@@ -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')
    {