Remove PostgreSQL::Test::Utils::perl2host completely
authorAndrew Dunstan
Sun, 20 Feb 2022 13:55:06 +0000 (08:55 -0500)
committerAndrew Dunstan
Sun, 20 Feb 2022 13:55:06 +0000 (08:55 -0500)
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[email protected]

src/bin/pg_basebackup/t/010_pg_basebackup.pl
src/bin/pg_checksums/t/002_actions.pl
src/bin/pg_verifybackup/t/003_corruption.pl
src/bin/pgbench/t/001_pgbench_with_server.pl
src/bin/scripts/t/090_reindexdb.pl
src/test/perl/PostgresNode.pm
src/test/perl/TestLib.pm
src/test/recovery/t/014_unlogged_reinit.pl
src/test/recovery/t/017_shm.pl
src/test/recovery/t/018_wal_optimize.pl
src/test/recovery/t/025_stuck_on_old_timeline.pl

index 3b320e26692260f96339eb4e15f80eb76541b279..0db3e0a3167ca2cd5f59fa39f842d3e88e087fca 100644 (file)
@@ -239,13 +239,11 @@ $node->start;
 # for the tablespace directories, which hopefully won't run afoul of
 # the 99 character length limit.
 my $sys_tempdir = TestLib::tempdir_short;
-my $real_sys_tempdir = TestLib::perl2host($sys_tempdir) . "/tempdir";
-my $shorter_tempdir =  $sys_tempdir . "/tempdir";
-dir_symlink "$tempdir", $shorter_tempdir;
+my $real_sys_tempdir = "$sys_tempdir/tempdir";
+dir_symlink "$tempdir", $real_sys_tempdir;
 
 mkdir "$tempdir/tblspc1";
 my $realTsDir    = "$real_sys_tempdir/tblspc1";
-my $real_tempdir = TestLib::perl2host($tempdir);
 $node->safe_psql('postgres',
    "CREATE TABLESPACE tblspc1 LOCATION '$realTsDir';");
 $node->safe_psql('postgres',
@@ -324,7 +322,7 @@ my $tblSpc1Id = basename(
 foreach my $filename (@tempRelationFiles)
 {
    append_to_file(
-       "$shorter_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename",
+       "$real_sys_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename",
        'TEMP_RELATION');
 }
 
@@ -334,9 +332,9 @@ $node->command_fails(
 
 $node->command_ok(
    [
-       'pg_basebackup',    '-D',
-       "$tempdir/backup1", '-Fp',
-       "-T$realTsDir=$real_tempdir/tbackup/tblspc1"
+       'pg_basebackup', '-D',
+       "$tempdir/backup1",  '-Fp',
+       "-T$realTsDir=$tempdir/tbackup/tblspc1",
    ],
    'plain format with tablespaces succeeds with tablespace mapping');
 ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
@@ -384,7 +382,7 @@ foreach my $filename (@tempRelationFiles)
 
    # Also remove temp relation files or tablespace drop will fail.
    my $filepath =
-     "$shorter_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename";
+     "$real_sys_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename";
 
    unlink($filepath)
      or BAIL_OUT("unable to unlink $filepath");
@@ -404,9 +402,9 @@ $node->safe_psql('postgres',
 $realTsDir =~ s/=/\\=/;
 $node->command_ok(
    [
-       'pg_basebackup',    '-D',
-       "$tempdir/backup3", '-Fp',
-       "-T$realTsDir=$real_tempdir/tbackup/tbl\\=spc2"
+       'pg_basebackup', '-D',
+       "$tempdir/backup3",  '-Fp',
+       "-T$realTsDir=$tempdir/tbackup/tbl\\=spc2",
    ],
    'mapping tablespace with = sign in path');
 ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
index af88b9479539db0d16fff73bd0de68ad196a53ea..4cace1542d809f1b1067598a02657488459e8211 100644 (file)
@@ -190,7 +190,6 @@ check_relation_corruption($node, 'corrupt1', 'pg_default');
 my $basedir        = $node->basedir;
 my $tablespace_dir = "$basedir/ts_corrupt_dir";
 mkdir($tablespace_dir);
-$tablespace_dir = TestLib::perl2host($tablespace_dir);
 $node->safe_psql('postgres',
    "CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';");
 check_relation_corruption($node, 'corrupt2', 'ts_corrupt');
index 682b3b857e6236e0ef5d4c77fe8a2c28c056fd86..867c1029105ac6158cc7e47b20b7da54da28e7cf 100644 (file)
@@ -18,7 +18,7 @@ $primary->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_path   = TestLib::tempdir_short();
 my $source_ts_prefix = $source_ts_path;
 $source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!;
 
@@ -107,7 +107,7 @@ for my $scenario (@scenario)
 
        # Take a backup and check that it verifies OK.
        my $backup_path    = $primary->backup_dir . '/' . $name;
-       my $backup_ts_path = TestLib::perl2host(TestLib::tempdir_short());
+       my $backup_ts_path = 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
index 0242e80992a64bf0ee4332d994c6dfc6b9dfa336..796eb57208df35ef5acc9c54cbe045cb747295a1 100644 (file)
@@ -19,12 +19,10 @@ $node->start;
 # for partitioned tables.
 my $ts = $node->basedir . '/regress_pgbench_tap_1_ts_dir';
 mkdir $ts or die "cannot create directory $ts";
-# this takes care of WIN-specific path issues
-my $ets = TestLib::perl2host($ts);
 
 # the next commands will issue a syntax error if the path contains a "'"
 $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
 # exercises LWLock and spinlock concurrency.
index af5bdf352c40e04c5dc27559154b002a1782883d..8bdedcb3d7a13cae016c93441073bfb95e11e4c0 100644 (file)
@@ -21,7 +21,6 @@ $ENV{PGOPTIONS} = '--client-min-messages=WARNING';
 # Create a tablespace for testing.
 my $tbspace_path = $node->basedir . '/regress_reindex_tbspace';
 mkdir $tbspace_path or die "cannot create directory $tbspace_path";
-$tbspace_path = TestLib::perl2host($tbspace_path);
 my $tbspace_name = 'reindex_tbspace';
 $node->safe_psql('postgres',
    "CREATE TABLESPACE $tbspace_name LOCATION '$tbspace_path';");
index 2fb4fbcb1b7166c31df284b047a5aee35e06916f..40ba59f3864b41105a81e41959328efe96bb4c7a 100644 (file)
@@ -1016,7 +1016,7 @@ primary_conninfo='$root_connstr'
 sub enable_restoring
 {
    my ($self, $root_node, $standby) = @_;
-   my $path = TestLib::perl2host($root_node->archive_dir);
+   my $path = $root_node->archive_dir;
    my $name = $self->name;
 
    print "### Enabling WAL restore for node \"$name\"\n";
@@ -1084,7 +1084,7 @@ sub set_standby_mode
 sub enable_archiving
 {
    my ($self) = @_;
-   my $path   = TestLib::perl2host($self->archive_dir);
+   my $path   = $self->archive_dir;
    my $name   = $self->name;
 
    print "### Enabling WAL archiving for node \"$name\"\n";
index e4dda0db9dc89225ae95f9cce75573030581abc3..7217b009e4b0a7a7449fa095c697cdbdfa5eee34 100644 (file)
@@ -24,7 +24,6 @@ TestLib - helper module for writing PostgreSQL's C tests.
 
   # Miscellanea
   print "on Windows" if $TestLib::windows_os;
-  my $path = TestLib::perl2host($backup_dir);
   ok(check_mode_recursive($stream_dir, 0700, 0600),
     "check stream dir permissions");
   TestLib::system_log('pg_ctl', 'kill', 'QUIT', $slow_pid);
@@ -298,61 +297,6 @@ sub tempdir_short
 
 =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 unless $Config{osname} eq 'msys';
-   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()
 
 Returns true if $tmp_check is subject to a sparc64+ext4 bug that causes WAL
@@ -708,8 +652,6 @@ sub dir_symlink
    my $newname = shift;
    if ($windows_os)
    {
-       $oldname = perl2host($oldname);
-       $newname = perl2host($newname);
        $oldname =~ s,/,\\,g;
        $newname =~ s,/,\\,g;
        my $cmd = qq{mklink /j "$newname" "$oldname"};
index b629d549dd947d1cbe6de9934f2936c221149a5c..6d40535e4052141ea8cd9d7b91ea85114fc0c5b7 100644 (file)
@@ -33,9 +33,7 @@ ok(-f "$pgdata/$baseUnloggedPath",        'main fork in base exists');
 
 my $tablespaceDir = TestLib::tempdir;
 
-my $realTSDir = TestLib::perl2host($tablespaceDir);
-
-$node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
+$node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$tablespaceDir'");
 $node->safe_psql('postgres',
    'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1');
 
index f29284b6408521f6e655732b95514b9f460e57c4..6c12292fe6e4d3b00e43c5f79c3f6849054eeb12 100644 (file)
@@ -116,7 +116,7 @@ log_ipcs();
 $gnat->start;
 log_ipcs();
 
-my $regress_shlib = TestLib::perl2host($ENV{REGRESS_SHLIB});
+my $regress_shlib = $ENV{REGRESS_SHLIB};
 $gnat->safe_psql('postgres', <
 CREATE FUNCTION wait_pid(int)
    RETURNS void
index 9cefe04bce6e9f6f6a7d089c331ec68461b67892..69e1462a4f5d8fbba5ac69c253f8d0aa9c6cae82 100644 (file)
@@ -60,7 +60,6 @@ wal_skip_threshold = 0
    # Setup
    my $tablespace_dir = $node->basedir . '/tablespace_other';
    mkdir($tablespace_dir);
-   $tablespace_dir = TestLib::perl2host($tablespace_dir);
    my $result;
 
    # Test redo of CREATE TABLESPACE.
@@ -152,7 +151,6 @@ wal_skip_threshold = 0
        $copy_file, qq(20000,30000
 20001,30001
 20002,30002));
-   $copy_file = TestLib::perl2host($copy_file);
 
    # Test truncation with inserted tuples using both INSERT and COPY.  Tuples
    # inserted after the truncation should be seen.
index fb15f9576bec21e6779bdf60405d19c062ff54d6..023cab49a2b32388400142d5c86dd39ba5701147 100644 (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
 # that arise from use of backslashes. That means we need to double-quote all
 # the paths in the archive_command
-my $perlbin = TestLib::perl2host($^X);
+my $perlbin = $^X;
 $perlbin =~ s!\\!/!g if $TestLib::windows_os;
 my $archivedir_primary = $node_primary->archive_dir;
 $archivedir_primary =~ s!\\!/!g if $TestLib::windows_os;