Skip to content

Commit f7ab5b3

Browse files
tglsfdchari90
authored andcommitted
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 1fd1bd8. 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 (cherry picked from commit fc0d0ce)
1 parent bf57083 commit f7ab5b3

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ sub adjust_old_dumpfile
257257

258258
# Same with version argument to pg_restore_relation_stats() or
259259
# pg_restore_attribute_stats().
260-
$dump =~ s ['version', '\d+'::integer,]
261-
['version', '000000'::integer,]mg;
260+
$dump =~ s {(^\s+'version',) '\d+'::integer,$}
261+
{$1 '000000'::integer,}mg;
262262

263263
if ($old_version < 14)
264264
{
@@ -282,6 +282,18 @@ sub adjust_old_dumpfile
282282
/$1 EXECUTE FUNCTION/mgx;
283283
}
284284

285+
# During pg_upgrade, we reindex hash indexes if the source is pre-v10.
286+
# This may change their tables' relallvisible values, so don't compare
287+
# those.
288+
if ($old_version < 10)
289+
{
290+
$dump =~ s/
291+
(^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
292+
\s+'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
293+
[^;]*'relallvisible',)\s'\d+'::integer
294+
/$1 ''::integer/mgx;
295+
}
296+
285297
if ($old_version lt '9.6')
286298
{
287299
# adjust some places where we don't print so many parens anymore
@@ -444,8 +456,8 @@ sub adjust_new_dumpfile
444456

445457
# Same with version argument to pg_restore_relation_stats() or
446458
# pg_restore_attribute_stats().
447-
$dump =~ s ['version', '\d+'::integer,]
448-
['version', '000000'::integer,]mg;
459+
$dump =~ s {(^\s+'version',) '\d+'::integer,$}
460+
{$1 '000000'::integer,}mg;
449461

450462
if ($old_version < 14)
451463
{
@@ -478,6 +490,18 @@ sub adjust_new_dumpfile
478490
$dump =~ s/^SET default_table_access_method = heap;\n//mg;
479491
}
480492

493+
# During pg_upgrade, we reindex hash indexes if the source is pre-v10.
494+
# This may change their tables' relallvisible values, so don't compare
495+
# those.
496+
if ($old_version < 10)
497+
{
498+
$dump =~ s/
499+
(^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
500+
\s+'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
501+
[^;]*'relallvisible',)\s'\d+'::integer
502+
/$1 ''::integer/mgx;
503+
}
504+
481505
# dumps from pre-9.6 dblink may include redundant ACL settings
482506
if ($old_version lt '9.6')
483507
{

0 commit comments

Comments
 (0)