Remove PostgreSQL::Test::Utils::perl2host completely

Commit f1ac4a74de disabled this processing, and as nothing has broken (as
expected) here we proceed to remove the routine and adjust all the call
sites.

Backpatch to release 10

Discussion: https://postgr.es/m/0ba775a2-8aa0-0d56-d780-69427cf6f33d@dunslane.net
Discussion: https://postgr.es/m/20220125023609.5ohu3nslxgoygihl@alap3.anarazel.de
This commit is contained in:
Andrew Dunstan 2022-02-18 17:00:03 -05:00
parent cf12541f2b
commit 95d981338b
No known key found for this signature in database
GPG Key ID: 99FA7FCB59FC3B81
17 changed files with 25 additions and 94 deletions

View File

@ -261,13 +261,11 @@ $node->start;
# for the tablespace directories, which hopefully won't run afoul of # for the tablespace directories, which hopefully won't run afoul of
# the 99 character length limit. # the 99 character length limit.
my $sys_tempdir = PostgreSQL::Test::Utils::tempdir_short; my $sys_tempdir = PostgreSQL::Test::Utils::tempdir_short;
my $real_sys_tempdir = PostgreSQL::Test::Utils::perl2host($sys_tempdir) . "/tempdir"; my $real_sys_tempdir = "$sys_tempdir/tempdir";
my $shorter_tempdir = $sys_tempdir . "/tempdir"; dir_symlink "$tempdir", $real_sys_tempdir;
dir_symlink "$tempdir", $shorter_tempdir;
mkdir "$tempdir/tblspc1"; mkdir "$tempdir/tblspc1";
my $realTsDir = "$real_sys_tempdir/tblspc1"; my $realTsDir = "$real_sys_tempdir/tblspc1";
my $real_tempdir = PostgreSQL::Test::Utils::perl2host($tempdir);
$node->safe_psql('postgres', $node->safe_psql('postgres',
"CREATE TABLESPACE tblspc1 LOCATION '$realTsDir';"); "CREATE TABLESPACE tblspc1 LOCATION '$realTsDir';");
$node->safe_psql('postgres', $node->safe_psql('postgres',
@ -346,7 +344,7 @@ my $tblSpc1Id = basename(
foreach my $filename (@tempRelationFiles) foreach my $filename (@tempRelationFiles)
{ {
append_to_file( append_to_file(
"$shorter_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename", "$real_sys_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename",
'TEMP_RELATION'); 'TEMP_RELATION');
} }
@ -358,7 +356,7 @@ $node->command_ok(
[ [
@pg_basebackup_defs, '-D', @pg_basebackup_defs, '-D',
"$tempdir/backup1", '-Fp', "$tempdir/backup1", '-Fp',
"-T$realTsDir=$real_tempdir/tbackup/tblspc1", "-T$realTsDir=$tempdir/tbackup/tblspc1",
], ],
'plain format with tablespaces succeeds with tablespace mapping'); 'plain format with tablespaces succeeds with tablespace mapping');
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated'); ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
@ -406,7 +404,7 @@ foreach my $filename (@tempRelationFiles)
# Also remove temp relation files or tablespace drop will fail. # Also remove temp relation files or tablespace drop will fail.
my $filepath = my $filepath =
"$shorter_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename"; "$real_sys_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename";
unlink($filepath) unlink($filepath)
or BAIL_OUT("unable to unlink $filepath"); or BAIL_OUT("unable to unlink $filepath");
@ -428,7 +426,7 @@ $node->command_ok(
[ [
@pg_basebackup_defs, '-D', @pg_basebackup_defs, '-D',
"$tempdir/backup3", '-Fp', "$tempdir/backup3", '-Fp',
"-T$realTsDir=$real_tempdir/tbackup/tbl\\=spc2", "-T$realTsDir=$tempdir/tbackup/tbl\\=spc2",
], ],
'mapping tablespace with = sign in path'); 'mapping tablespace with = sign in path');
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated'); ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
@ -517,7 +515,7 @@ $node->command_ok(
[ @pg_basebackup_defs, '--target', 'blackhole', '-X', 'none' ], [ @pg_basebackup_defs, '--target', 'blackhole', '-X', 'none' ],
'backup target blackhole'); 'backup target blackhole');
$node->command_ok( $node->command_ok(
[ @pg_basebackup_defs, '--target', "server:$real_tempdir/backuponserver", '-X', 'none' ], [ @pg_basebackup_defs, '--target', "server:$tempdir/backuponserver", '-X', 'none' ],
'backup target server'); 'backup target server');
ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created'); ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created');
rmtree("$tempdir/backuponserver"); rmtree("$tempdir/backuponserver");
@ -526,7 +524,7 @@ $node->command_ok(
[qw(createuser --replication --role=pg_write_server_files backupuser)], [qw(createuser --replication --role=pg_write_server_files backupuser)],
'create backup user'); 'create backup user');
$node->command_ok( $node->command_ok(
[ @pg_basebackup_defs, '-U', 'backupuser', '--target', "server:$real_tempdir/backuponserver", '-X', 'none' ], [ @pg_basebackup_defs, '-U', 'backupuser', '--target', "server:$tempdir/backuponserver", '-X', 'none' ],
'backup target server'); 'backup target server');
ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created as non-superuser'); ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created as non-superuser');
rmtree("$tempdir/backuponserver"); rmtree("$tempdir/backuponserver");

View File

@ -207,7 +207,6 @@ check_relation_corruption($node, 'corrupt1', 'pg_default');
my $basedir = $node->basedir; my $basedir = $node->basedir;
my $tablespace_dir = "$basedir/ts_corrupt_dir"; my $tablespace_dir = "$basedir/ts_corrupt_dir";
mkdir($tablespace_dir); mkdir($tablespace_dir);
$tablespace_dir = PostgreSQL::Test::Utils::perl2host($tablespace_dir);
$node->safe_psql('postgres', $node->safe_psql('postgres',
"CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';"); "CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';");
check_relation_corruption($node, 'corrupt2', 'ts_corrupt'); check_relation_corruption($node, 'corrupt2', 'ts_corrupt');

View File

@ -18,7 +18,7 @@ $primary->start;
# Include a user-defined tablespace in the hopes of detecting problems in that # Include a user-defined tablespace in the hopes of detecting problems in that
# area. # area.
my $source_ts_path = PostgreSQL::Test::Utils::perl2host(PostgreSQL::Test::Utils::tempdir_short()); my $source_ts_path =PostgreSQL::Test::Utils::tempdir_short();
my $source_ts_prefix = $source_ts_path; my $source_ts_prefix = $source_ts_path;
$source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!; $source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!;
@ -107,7 +107,7 @@ for my $scenario (@scenario)
# Take a backup and check that it verifies OK. # Take a backup and check that it verifies OK.
my $backup_path = $primary->backup_dir . '/' . $name; my $backup_path = $primary->backup_dir . '/' . $name;
my $backup_ts_path = PostgreSQL::Test::Utils::perl2host(PostgreSQL::Test::Utils::tempdir_short()); my $backup_ts_path = PostgreSQL::Test::Utils::tempdir_short();
# The tablespace map parameter confuses Msys2, which tries to mangle # The tablespace map parameter confuses Msys2, which tries to mangle
# it. Tell it not to. # it. Tell it not to.
# See https://www.msys2.org/wiki/Porting/#filesystem-namespaces # See https://www.msys2.org/wiki/Porting/#filesystem-namespaces

View File

@ -18,7 +18,6 @@ $primary->init(allows_streaming => 1);
$primary->start; $primary->start;
my $backup_path = $primary->backup_dir . '/server-backup'; my $backup_path = $primary->backup_dir . '/server-backup';
my $real_backup_path = PostgreSQL::Test::Utils::perl2host($backup_path);
my $extract_path = $primary->backup_dir . '/extracted-backup'; my $extract_path = $primary->backup_dir . '/extracted-backup';
my @test_configuration = ( my @test_configuration = (
@ -61,7 +60,7 @@ for my $tc (@test_configuration)
# Take a server-side backup. # Take a server-side backup.
my @backup = ( my @backup = (
'pg_basebackup', '--no-sync', '-cfast', '--target', 'pg_basebackup', '--no-sync', '-cfast', '--target',
"server:$real_backup_path", '-Xfetch' "server:$backup_path", '-Xfetch'
); );
push @backup, @{$tc->{'backup_flags'}}; push @backup, @{$tc->{'backup_flags'}};
$primary->command_ok(\@backup, $primary->command_ok(\@backup,

View File

@ -19,12 +19,10 @@ $node->start;
# for partitioned tables. # for partitioned tables.
my $ts = $node->basedir . '/regress_pgbench_tap_1_ts_dir'; my $ts = $node->basedir . '/regress_pgbench_tap_1_ts_dir';
mkdir $ts or die "cannot create directory $ts"; mkdir $ts or die "cannot create directory $ts";
# this takes care of WIN-specific path issues
my $ets = PostgreSQL::Test::Utils::perl2host($ts);
# the next commands will issue a syntax error if the path contains a "'" # the next commands will issue a syntax error if the path contains a "'"
$node->safe_psql('postgres', $node->safe_psql('postgres',
"CREATE TABLESPACE regress_pgbench_tap_1_ts LOCATION '$ets';"); "CREATE TABLESPACE regress_pgbench_tap_1_ts LOCATION '$ts';");
# Test concurrent OID generation via pg_enum_oid_index. This indirectly # Test concurrent OID generation via pg_enum_oid_index. This indirectly
# exercises LWLock and spinlock concurrency. # exercises LWLock and spinlock concurrency.

View File

@ -21,7 +21,6 @@ $ENV{PGOPTIONS} = '--client-min-messages=WARNING';
# Create a tablespace for testing. # Create a tablespace for testing.
my $tbspace_path = $node->basedir . '/regress_reindex_tbspace'; my $tbspace_path = $node->basedir . '/regress_reindex_tbspace';
mkdir $tbspace_path or die "cannot create directory $tbspace_path"; mkdir $tbspace_path or die "cannot create directory $tbspace_path";
$tbspace_path = PostgreSQL::Test::Utils::perl2host($tbspace_path);
my $tbspace_name = 'reindex_tbspace'; my $tbspace_name = 'reindex_tbspace';
$node->safe_psql('postgres', $node->safe_psql('postgres',
"CREATE TABLESPACE $tbspace_name LOCATION '$tbspace_path';"); "CREATE TABLESPACE $tbspace_name LOCATION '$tbspace_path';");

View File

@ -14,10 +14,10 @@ $node->start;
# Create a couple of directories to use as tablespaces. # Create a couple of directories to use as tablespaces.
my $basedir = $node->basedir(); my $basedir = $node->basedir();
my $TS1_LOCATION = PostgreSQL::Test::Utils::perl2host("$basedir/ts1"); my $TS1_LOCATION = "$basedir/ts1";
$TS1_LOCATION =~ s/\/\.\//\//g; # collapse foo/./bar to foo/bar $TS1_LOCATION =~ s/\/\.\//\//g; # collapse foo/./bar to foo/bar
mkdir($TS1_LOCATION); mkdir($TS1_LOCATION);
my $TS2_LOCATION = PostgreSQL::Test::Utils::perl2host("$basedir/ts2"); my $TS2_LOCATION = "$basedir/ts2";
$TS2_LOCATION =~ s/\/\.\//\//g; $TS2_LOCATION =~ s/\/\.\//\//g;
mkdir($TS2_LOCATION); mkdir($TS2_LOCATION);

View File

@ -1076,7 +1076,7 @@ primary_conninfo='$root_connstr'
sub enable_restoring sub enable_restoring
{ {
my ($self, $root_node, $standby) = @_; my ($self, $root_node, $standby) = @_;
my $path = PostgreSQL::Test::Utils::perl2host($root_node->archive_dir); my $path = $root_node->archive_dir;
my $name = $self->name; my $name = $self->name;
print "### Enabling WAL restore for node \"$name\"\n"; print "### Enabling WAL restore for node \"$name\"\n";
@ -1144,7 +1144,7 @@ sub set_standby_mode
sub enable_archiving sub enable_archiving
{ {
my ($self) = @_; my ($self) = @_;
my $path = PostgreSQL::Test::Utils::perl2host($self->archive_dir); my $path = $self->archive_dir;
my $name = $self->name; my $name = $self->name;
print "### Enabling WAL archiving for node \"$name\"\n"; print "### Enabling WAL archiving for node \"$name\"\n";

View File

@ -24,7 +24,6 @@ PostgreSQL::Test::Utils - helper module for writing PostgreSQL's C<prove> tests.
# Miscellanea # Miscellanea
print "on Windows" if $PostgreSQL::Test::Utils::windows_os; print "on Windows" if $PostgreSQL::Test::Utils::windows_os;
my $path = PostgreSQL::Test::Utils::perl2host($backup_dir);
ok(check_mode_recursive($stream_dir, 0700, 0600), ok(check_mode_recursive($stream_dir, 0700, 0600),
"check stream dir permissions"); "check stream dir permissions");
PostgreSQL::Test::Utils::system_log('pg_ctl', 'kill', 'QUIT', $slow_pid); PostgreSQL::Test::Utils::system_log('pg_ctl', 'kill', 'QUIT', $slow_pid);
@ -297,61 +296,6 @@ sub tempdir_short
=pod =pod
=item perl2host()
Translate a virtual file name to a host file name. Currently, this is a no-op
except for the case of Perl=msys and host=mingw32. The subject need not
exist, but its parent or grandparent directory must exist unless cygpath is
available.
The returned path uses forward slashes but has no trailing slash.
=cut
sub perl2host
{
my ($subject) = @_;
return $subject;
if ($is_msys2)
{
# get absolute, windows type path
my $path = qx{cygpath -a -m "$subject"};
if (!$?)
{
chomp $path;
$path =~ s!/$!!;
return $path if $path;
}
# fall through if this didn't work.
}
my $here = cwd;
my $leaf;
if (chdir $subject)
{
$leaf = '';
}
else
{
$leaf = '/' . basename $subject;
my $parent = dirname $subject;
if (!chdir $parent)
{
$leaf = '/' . basename($parent) . $leaf;
$parent = dirname $parent;
chdir $parent or die "could not chdir \"$parent\": $!";
}
}
# this odd way of calling 'pwd -W' is the only way that seems to work.
my $dir = qx{sh -c "pwd -W"};
chomp $dir;
$dir =~ s!/$!!;
chdir $here;
return $dir . $leaf;
}
=pod
=item has_wal_read_bug() =item has_wal_read_bug()
Returns true if $tmp_check is subject to a sparc64+ext4 bug that causes WAL Returns true if $tmp_check is subject to a sparc64+ext4 bug that causes WAL
@ -727,8 +671,6 @@ sub dir_symlink
my $newname = shift; my $newname = shift;
if ($windows_os) if ($windows_os)
{ {
$oldname = perl2host($oldname);
$newname = perl2host($newname);
$oldname =~ s,/,\\,g; $oldname =~ s,/,\\,g;
$newname =~ s,/,\\,g; $newname =~ s,/,\\,g;
my $cmd = qq{mklink /j "$newname" "$oldname"}; my $cmd = qq{mklink /j "$newname" "$oldname"};

View File

@ -33,9 +33,7 @@ ok(-f "$pgdata/$baseUnloggedPath", 'main fork in base exists');
my $tablespaceDir = PostgreSQL::Test::Utils::tempdir; my $tablespaceDir = PostgreSQL::Test::Utils::tempdir;
my $realTSDir = PostgreSQL::Test::Utils::perl2host($tablespaceDir); $node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$tablespaceDir'");
$node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
$node->safe_psql('postgres', $node->safe_psql('postgres',
'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1'); 'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1');

View File

@ -112,7 +112,7 @@ log_ipcs();
$gnat->start; $gnat->start;
log_ipcs(); log_ipcs();
my $regress_shlib = PostgreSQL::Test::Utils::perl2host($ENV{REGRESS_SHLIB}); my $regress_shlib = $ENV{REGRESS_SHLIB};
$gnat->safe_psql('postgres', <<EOSQL); $gnat->safe_psql('postgres', <<EOSQL);
CREATE FUNCTION wait_pid(int) CREATE FUNCTION wait_pid(int)
RETURNS void RETURNS void

View File

@ -60,7 +60,6 @@ wal_skip_threshold = 0
# Setup # Setup
my $tablespace_dir = $node->basedir . '/tablespace_other'; my $tablespace_dir = $node->basedir . '/tablespace_other';
mkdir($tablespace_dir); mkdir($tablespace_dir);
$tablespace_dir = PostgreSQL::Test::Utils::perl2host($tablespace_dir);
my $result; my $result;
# Test redo of CREATE TABLESPACE. # Test redo of CREATE TABLESPACE.
@ -152,7 +151,6 @@ wal_skip_threshold = 0
$copy_file, qq(20000,30000 $copy_file, qq(20000,30000
20001,30001 20001,30001
20002,30002)); 20002,30002));
$copy_file = PostgreSQL::Test::Utils::perl2host($copy_file);
# Test truncation with inserted tuples using both INSERT and COPY. Tuples # Test truncation with inserted tuples using both INSERT and COPY. Tuples
# inserted after the truncation should be seen. # inserted after the truncation should be seen.

View File

@ -28,7 +28,7 @@ $node_primary->init(allows_streaming => 1, has_archiving => 1);
# Note: consistent use of forward slashes here avoids any escaping problems # Note: consistent use of forward slashes here avoids any escaping problems
# that arise from use of backslashes. That means we need to double-quote all # that arise from use of backslashes. That means we need to double-quote all
# the paths in the archive_command # the paths in the archive_command
my $perlbin = PostgreSQL::Test::Utils::perl2host($^X); my $perlbin = $^X;
$perlbin =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os; $perlbin =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os;
my $archivedir_primary = $node_primary->archive_dir; my $archivedir_primary = $node_primary->archive_dir;
$archivedir_primary =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os; $archivedir_primary =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os;

View File

@ -48,8 +48,8 @@ $node_standby_1->append_conf('postgresql.conf',
'max_standby_streaming_delay = 600s'); 'max_standby_streaming_delay = 600s');
$node_standby_1->start; $node_standby_1->start;
my $dlpath = PostgreSQL::Test::Utils::perl2host(dirname($ENV{REGRESS_SHLIB})); my $dlpath = dirname($ENV{REGRESS_SHLIB});
my $outputdir = PostgreSQL::Test::Utils::perl2host($PostgreSQL::Test::Utils::tmp_check); my $outputdir = $PostgreSQL::Test::Utils::tmp_check;
# Run the regression tests against the primary. # Run the regression tests against the primary.
my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || ""; my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || "";

View File

@ -51,7 +51,7 @@ foreach my $keyfile (@keys)
"couldn't copy ssl/$keyfile to $cert_tempdir/$keyfile for permissions change: $!"; "couldn't copy ssl/$keyfile to $cert_tempdir/$keyfile for permissions change: $!";
chmod 0600, "$cert_tempdir/$keyfile" chmod 0600, "$cert_tempdir/$keyfile"
or die "failed to change permissions on $cert_tempdir/$keyfile: $!"; or die "failed to change permissions on $cert_tempdir/$keyfile: $!";
$key{$keyfile} = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/$keyfile"); $key{$keyfile} = "$cert_tempdir/$keyfile";
$key{$keyfile} =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os; $key{$keyfile} =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os;
} }
@ -63,7 +63,7 @@ copy("ssl/client.key", "$cert_tempdir/client_wrongperms.key")
"couldn't copy ssl/client_key to $cert_tempdir/client_wrongperms.key for permission change: $!"; "couldn't copy ssl/client_key to $cert_tempdir/client_wrongperms.key for permission change: $!";
chmod 0644, "$cert_tempdir/client_wrongperms.key" chmod 0644, "$cert_tempdir/client_wrongperms.key"
or die "failed to change permissions on $cert_tempdir/client_wrongperms.key: $!"; or die "failed to change permissions on $cert_tempdir/client_wrongperms.key: $!";
$key{'client_wrongperms.key'} = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/client_wrongperms.key"); $key{'client_wrongperms.key'} = "$cert_tempdir/client_wrongperms.key";
$key{'client_wrongperms.key'} =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os; $key{'client_wrongperms.key'} =~ s!\\!/!g if $PostgreSQL::Test::Utils::windows_os;
#### Set up the server. #### Set up the server.

View File

@ -94,7 +94,7 @@ $node->connect_fails(
# be used in a different test, so the name of this temporary client key # be used in a different test, so the name of this temporary client key
# is chosen here to be unique. # is chosen here to be unique.
my $cert_tempdir = PostgreSQL::Test::Utils::tempdir(); my $cert_tempdir = PostgreSQL::Test::Utils::tempdir();
my $client_tmp_key = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/client_scram.key"); my $client_tmp_key = "$cert_tempdir/client_scram.key";
copy("ssl/client.key", "$cert_tempdir/client_scram.key") copy("ssl/client.key", "$cert_tempdir/client_scram.key")
or die or die
"couldn't copy ssl/client_key to $cert_tempdir/client_scram.key for permission change: $!"; "couldn't copy ssl/client_key to $cert_tempdir/client_scram.key for permission change: $!";

View File

@ -34,7 +34,7 @@ my $common_connstr;
# The client's private key must not be world-readable, so take a copy # The client's private key must not be world-readable, so take a copy
# of the key stored in the code tree and update its permissions. # of the key stored in the code tree and update its permissions.
my $cert_tempdir = PostgreSQL::Test::Utils::tempdir(); my $cert_tempdir = PostgreSQL::Test::Utils::tempdir();
my $client_tmp_key = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/client_ext.key"); my $client_tmp_key = "$cert_tempdir/client_ext.key";
copy("ssl/client_ext.key", "$cert_tempdir/client_ext.key") copy("ssl/client_ext.key", "$cert_tempdir/client_ext.key")
or die or die
"couldn't copy ssl/client_ext.key to $cert_tempdir/client_ext.key for permissions change: $!"; "couldn't copy ssl/client_ext.key to $cert_tempdir/client_ext.key for permissions change: $!";