Skip to content

Commit 56455eb

Browse files
committed
Skip invalid database pg_upgrade test on obsolete servers
When testing pg_upgrade against an old server, ignore failures on the check to upgrade invalid databases. This is necessary because old servers don't know to raise the appropriate error of the database being invalid. This change causes no reduction in coverage, because such old versions don't know to mark databases invalid when a drop is interrupted; but testing against such old servers is useful in some circumstances. Backpatch to 16, where it cherry-picks with minimal conflicts. On 16, perltidy 20230309 chooses to change an unrelated line. I let it do that because that's the version we document as preferred for that branch, even though it would make other changes to many other files in the tree. Discussion: https://postgr.es/m/202404181539.lh42llaesnv3@alvherre.pgsql
1 parent 2ea4b29 commit 56455eb

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/bin/pg_upgrade/t/002_pg_upgrade.pl

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,31 @@ sub filter_dump
404404
rmtree($newnode->data_dir . "/pg_upgrade_output.d");
405405

406406
# Check that pg_upgrade aborts when encountering an invalid database
407-
command_checks_all(
408-
[
409-
'pg_upgrade', '--no-sync', '-d', $oldnode->data_dir,
410-
'-D', $newnode->data_dir, '-b', $oldbindir,
411-
'-B', $newbindir, '-s', $newnode->host,
412-
'-p', $oldnode->port, '-P', $newnode->port,
413-
$mode, '--check',
414-
],
415-
1,
416-
[qr/invalid/], # pg_upgrade prints errors on stdout :(
417-
[qr/^$/],
418-
'invalid database causes failure');
419-
rmtree($newnode->data_dir . "/pg_upgrade_output.d");
407+
# (However, versions that were out of support by commit c66a7d75e652 don't
408+
# know how to do this, so skip this test there.)
409+
SKIP:
410+
{
411+
skip "database invalidation not implemented", 1
412+
if $oldnode->pg_version < 11;
413+
414+
command_checks_all(
415+
[
416+
'pg_upgrade', '--no-sync',
417+
'-d', $oldnode->data_dir,
418+
'-D', $newnode->data_dir,
419+
'-b', $oldbindir,
420+
'-B', $newbindir,
421+
'-s', $newnode->host,
422+
'-p', $oldnode->port,
423+
'-P', $newnode->port,
424+
$mode, '--check',
425+
],
426+
1,
427+
[qr/invalid/], # pg_upgrade prints errors on stdout :(
428+
[qr/^$/],
429+
'invalid database causes failure');
430+
rmtree($newnode->data_dir . "/pg_upgrade_output.d");
431+
}
420432

421433
# And drop it, so we can continue
422434
$oldnode->start;

0 commit comments

Comments
 (0)