Commit c3e4cbaa authored by Andrew Dunstan's avatar Andrew Dunstan

Msys2 tweaks for pg_validatebackup corruption test

1. Tell Msys2 not to mangle the tablespace map parameter
2. If rmdir doesn't work, fall back to trying unlink on the entry in
   pg_tblspc.

Discussion: https://postgr.es/m/7330a7c7-ce5f-9769-39a1-bdb0b32bb4a6@2ndQuadrant.com
parent f45b8e51
......@@ -16,6 +16,9 @@ $master->start;
# Include a user-defined tablespace in the hopes of detecting problems in that
# area.
my $source_ts_path = TestLib::perl2host(TestLib::tempdir_short());
my $source_ts_prefix = $source_ts_path;
$source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!;
$master->safe_psql('postgres', <<EOM);
CREATE TABLE x1 (a int);
INSERT INTO x1 VALUES (111);
......@@ -105,6 +108,10 @@ for my $scenario (@scenario)
# Take a backup and check that it validates OK.
my $backup_path = $master->backup_dir . '/' . $name;
my $backup_ts_path = TestLib::perl2host(TestLib::tempdir_short());
# The tablespace map parameter confuses Msys2, which tries to mangle
# it. Tell it not to.
# See https://www.msys2.org/wiki/Porting/#filesystem-namespaces
local $ENV{MSYS2_ARG_CONV_EXCL} = $source_ts_prefix;
$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync',
'-T', "${source_ts_path}=${backup_ts_path}"],
"base backup ok");
......@@ -179,7 +186,14 @@ sub mutilate_missing_tablespace
my $pathname = "$backup_path/pg_tblspc/$tsoid";
if ($windows_os)
{
rmdir($pathname) || die "$pathname: $!";
# rmdir works on some windows setups, unlink on others.
# Instead of trying to implement precise rules, just try one and then
# the other.
unless (rmdir($pathname))
{
my $err = $!;
unlink($pathname) || die "$pathname: rmdir: $err, unlink: $!";
}
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment