Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95d9813

Browse files
committed
Remove PostgreSQL::Test::Utils::perl2host completely
Commit f1ac4a7 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/[email protected] Discussion: https://postgr.es/m/[email protected]
1 parent cf12541 commit 95d9813

File tree

17 files changed

+25
-94
lines changed

17 files changed

+25
-94
lines changed

src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,11 @@
261261
# for the tablespace directories, which hopefully won't run afoul of
262262
# the 99 character length limit.
263263
my $sys_tempdir = PostgreSQL::Test::Utils::tempdir_short;
264-
my $real_sys_tempdir = PostgreSQL::Test::Utils::perl2host($sys_tempdir) . "/tempdir";
265-
my $shorter_tempdir = $sys_tempdir . "/tempdir";
266-
dir_symlink "$tempdir", $shorter_tempdir;
264+
my $real_sys_tempdir = "$sys_tempdir/tempdir";
265+
dir_symlink "$tempdir", $real_sys_tempdir;
267266

268267
mkdir "$tempdir/tblspc1";
269268
my $realTsDir = "$real_sys_tempdir/tblspc1";
270-
my $real_tempdir = PostgreSQL::Test::Utils::perl2host($tempdir);
271269
$node->safe_psql('postgres',
272270
"CREATE TABLESPACE tblspc1 LOCATION '$realTsDir';");
273271
$node->safe_psql('postgres',
@@ -346,7 +344,7 @@
346344
foreach my $filename (@tempRelationFiles)
347345
{
348346
append_to_file(
349-
"$shorter_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename",
347+
"$real_sys_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename",
350348
'TEMP_RELATION');
351349
}
352350

@@ -358,7 +356,7 @@
358356
[
359357
@pg_basebackup_defs, '-D',
360358
"$tempdir/backup1", '-Fp',
361-
"-T$realTsDir=$real_tempdir/tbackup/tblspc1",
359+
"-T$realTsDir=$tempdir/tbackup/tblspc1",
362360
],
363361
'plain format with tablespaces succeeds with tablespace mapping');
364362
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
@@ -406,7 +404,7 @@
406404

407405
# Also remove temp relation files or tablespace drop will fail.
408406
my $filepath =
409-
"$shorter_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename";
407+
"$real_sys_tempdir/tblspc1/$tblSpc1Id/$postgresOid/$filename";
410408

411409
unlink($filepath)
412410
or BAIL_OUT("unable to unlink $filepath");
@@ -428,7 +426,7 @@
428426
[
429427
@pg_basebackup_defs, '-D',
430428
"$tempdir/backup3", '-Fp',
431-
"-T$realTsDir=$real_tempdir/tbackup/tbl\\=spc2",
429+
"-T$realTsDir=$tempdir/tbackup/tbl\\=spc2",
432430
],
433431
'mapping tablespace with = sign in path');
434432
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
@@ -517,7 +515,7 @@
517515
[ @pg_basebackup_defs, '--target', 'blackhole', '-X', 'none' ],
518516
'backup target blackhole');
519517
$node->command_ok(
520-
[ @pg_basebackup_defs, '--target', "server:$real_tempdir/backuponserver", '-X', 'none' ],
518+
[ @pg_basebackup_defs, '--target', "server:$tempdir/backuponserver", '-X', 'none' ],
521519
'backup target server');
522520
ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created');
523521
rmtree("$tempdir/backuponserver");
@@ -526,7 +524,7 @@
526524
[qw(createuser --replication --role=pg_write_server_files backupuser)],
527525
'create backup user');
528526
$node->command_ok(
529-
[ @pg_basebackup_defs, '-U', 'backupuser', '--target', "server:$real_tempdir/backuponserver", '-X', 'none' ],
527+
[ @pg_basebackup_defs, '-U', 'backupuser', '--target', "server:$tempdir/backuponserver", '-X', 'none' ],
530528
'backup target server');
531529
ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created as non-superuser');
532530
rmtree("$tempdir/backuponserver");

src/bin/pg_checksums/t/002_actions.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ sub check_relation_corruption
207207
my $basedir = $node->basedir;
208208
my $tablespace_dir = "$basedir/ts_corrupt_dir";
209209
mkdir($tablespace_dir);
210-
$tablespace_dir = PostgreSQL::Test::Utils::perl2host($tablespace_dir);
211210
$node->safe_psql('postgres',
212211
"CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';");
213212
check_relation_corruption($node, 'corrupt2', 'ts_corrupt');

src/bin/pg_verifybackup/t/003_corruption.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# Include a user-defined tablespace in the hopes of detecting problems in that
2020
# area.
21-
my $source_ts_path = PostgreSQL::Test::Utils::perl2host(PostgreSQL::Test::Utils::tempdir_short());
21+
my $source_ts_path =PostgreSQL::Test::Utils::tempdir_short();
2222
my $source_ts_prefix = $source_ts_path;
2323
$source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!;
2424

@@ -107,7 +107,7 @@
107107

108108
# Take a backup and check that it verifies OK.
109109
my $backup_path = $primary->backup_dir . '/' . $name;
110-
my $backup_ts_path = PostgreSQL::Test::Utils::perl2host(PostgreSQL::Test::Utils::tempdir_short());
110+
my $backup_ts_path = PostgreSQL::Test::Utils::tempdir_short();
111111
# The tablespace map parameter confuses Msys2, which tries to mangle
112112
# it. Tell it not to.
113113
# See https://www.msys2.org/wiki/Porting/#filesystem-namespaces

src/bin/pg_verifybackup/t/008_untar.pl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
$primary->start;
1919

2020
my $backup_path = $primary->backup_dir . '/server-backup';
21-
my $real_backup_path = PostgreSQL::Test::Utils::perl2host($backup_path);
2221
my $extract_path = $primary->backup_dir . '/extracted-backup';
2322

2423
my @test_configuration = (
@@ -61,7 +60,7 @@
6160
# Take a server-side backup.
6261
my @backup = (
6362
'pg_basebackup', '--no-sync', '-cfast', '--target',
64-
"server:$real_backup_path", '-Xfetch'
63+
"server:$backup_path", '-Xfetch'
6564
);
6665
push @backup, @{$tc->{'backup_flags'}};
6766
$primary->command_ok(\@backup,

src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
# for partitioned tables.
2020
my $ts = $node->basedir . '/regress_pgbench_tap_1_ts_dir';
2121
mkdir $ts or die "cannot create directory $ts";
22-
# this takes care of WIN-specific path issues
23-
my $ets = PostgreSQL::Test::Utils::perl2host($ts);
2422

2523
# the next commands will issue a syntax error if the path contains a "'"
2624
$node->safe_psql('postgres',
27-
"CREATE TABLESPACE regress_pgbench_tap_1_ts LOCATION '$ets';");
25+
"CREATE TABLESPACE regress_pgbench_tap_1_ts LOCATION '$ts';");
2826

2927
# Test concurrent OID generation via pg_enum_oid_index. This indirectly
3028
# exercises LWLock and spinlock concurrency.

src/bin/scripts/t/090_reindexdb.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# Create a tablespace for testing.
2222
my $tbspace_path = $node->basedir . '/regress_reindex_tbspace';
2323
mkdir $tbspace_path or die "cannot create directory $tbspace_path";
24-
$tbspace_path = PostgreSQL::Test::Utils::perl2host($tbspace_path);
2524
my $tbspace_name = 'reindex_tbspace';
2625
$node->safe_psql('postgres',
2726
"CREATE TABLESPACE $tbspace_name LOCATION '$tbspace_path';");

src/test/modules/test_misc/t/002_tablespace.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
# Create a couple of directories to use as tablespaces.
1616
my $basedir = $node->basedir();
17-
my $TS1_LOCATION = PostgreSQL::Test::Utils::perl2host("$basedir/ts1");
17+
my $TS1_LOCATION = "$basedir/ts1";
1818
$TS1_LOCATION =~ s/\/\.\//\//g; # collapse foo/./bar to foo/bar
1919
mkdir($TS1_LOCATION);
20-
my $TS2_LOCATION = PostgreSQL::Test::Utils::perl2host("$basedir/ts2");
20+
my $TS2_LOCATION = "$basedir/ts2";
2121
$TS2_LOCATION =~ s/\/\.\//\//g;
2222
mkdir($TS2_LOCATION);
2323

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ primary_conninfo='$root_connstr'
10761076
sub enable_restoring
10771077
{
10781078
my ($self, $root_node, $standby) = @_;
1079-
my $path = PostgreSQL::Test::Utils::perl2host($root_node->archive_dir);
1079+
my $path = $root_node->archive_dir;
10801080
my $name = $self->name;
10811081

10821082
print "### Enabling WAL restore for node \"$name\"\n";
@@ -1144,7 +1144,7 @@ sub set_standby_mode
11441144
sub enable_archiving
11451145
{
11461146
my ($self) = @_;
1147-
my $path = PostgreSQL::Test::Utils::perl2host($self->archive_dir);
1147+
my $path = $self->archive_dir;
11481148
my $name = $self->name;
11491149

11501150
print "### Enabling WAL archiving for node \"$name\"\n";

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

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ PostgreSQL::Test::Utils - helper module for writing PostgreSQL's C<prove> tests.
2424
2525
# Miscellanea
2626
print "on Windows" if $PostgreSQL::Test::Utils::windows_os;
27-
my $path = PostgreSQL::Test::Utils::perl2host($backup_dir);
2827
ok(check_mode_recursive($stream_dir, 0700, 0600),
2928
"check stream dir permissions");
3029
PostgreSQL::Test::Utils::system_log('pg_ctl', 'kill', 'QUIT', $slow_pid);
@@ -297,61 +296,6 @@ sub tempdir_short
297296

298297
=pod
299298
300-
=item perl2host()
301-
302-
Translate a virtual file name to a host file name. Currently, this is a no-op
303-
except for the case of Perl=msys and host=mingw32. The subject need not
304-
exist, but its parent or grandparent directory must exist unless cygpath is
305-
available.
306-
307-
The returned path uses forward slashes but has no trailing slash.
308-
309-
=cut
310-
311-
sub perl2host
312-
{
313-
my ($subject) = @_;
314-
return $subject;
315-
if ($is_msys2)
316-
{
317-
# get absolute, windows type path
318-
my $path = qx{cygpath -a -m "$subject"};
319-
if (!$?)
320-
{
321-
chomp $path;
322-
$path =~ s!/$!!;
323-
return $path if $path;
324-
}
325-
# fall through if this didn't work.
326-
}
327-
my $here = cwd;
328-
my $leaf;
329-
if (chdir $subject)
330-
{
331-
$leaf = '';
332-
}
333-
else
334-
{
335-
$leaf = '/' . basename $subject;
336-
my $parent = dirname $subject;
337-
if (!chdir $parent)
338-
{
339-
$leaf = '/' . basename($parent) . $leaf;
340-
$parent = dirname $parent;
341-
chdir $parent or die "could not chdir \"$parent\": $!";
342-
}
343-
}
344-
345-
# this odd way of calling 'pwd -W' is the only way that seems to work.
346-
my $dir = qx{sh -c "pwd -W"};
347-
chomp $dir;
348-
$dir =~ s!/$!!;
349-
chdir $here;
350-
return $dir . $leaf;
351-
}
352-
353-
=pod
354-
355299
=item has_wal_read_bug()
356300
357301
Returns true if $tmp_check is subject to a sparc64+ext4 bug that causes WAL
@@ -727,8 +671,6 @@ sub dir_symlink
727671
my $newname = shift;
728672
if ($windows_os)
729673
{
730-
$oldname = perl2host($oldname);
731-
$newname = perl2host($newname);
732674
$oldname =~ s,/,\\,g;
733675
$newname =~ s,/,\\,g;
734676
my $cmd = qq{mklink /j "$newname" "$oldname"};

src/test/recovery/t/014_unlogged_reinit.pl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333

3434
my $tablespaceDir = PostgreSQL::Test::Utils::tempdir;
3535

36-
my $realTSDir = PostgreSQL::Test::Utils::perl2host($tablespaceDir);
37-
38-
$node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$realTSDir'");
36+
$node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$tablespaceDir'");
3937
$node->safe_psql('postgres',
4038
'CREATE UNLOGGED TABLE ts1_unlogged (id int) TABLESPACE ts1');
4139

0 commit comments

Comments
 (0)