Commit 30b2731b authored by Tom Lane's avatar Tom Lane

Fix TAP tests and MSVC scripts for pathnames with spaces.

Change assorted places in our Perl code that did things like
	system("prog $path/file");
to do it more like
	system('prog', "$path/file");
which is safe against spaces and other special characters in the path
variable.  The latter was already the prevailing style, but a few bits
of code hadn't gotten this memo.  Back-patch to 9.4 as relevant.

Michael Paquier, Kyotaro Horiguchi

Discussion: <20160704.160213.111134711.horiguchi.kyotaro@lab.ntt.co.jp>
parent c5756272
...@@ -475,7 +475,8 @@ sub backup ...@@ -475,7 +475,8 @@ sub backup
my $name = $self->name; my $name = $self->name;
print "# Taking pg_basebackup $backup_name from node \"$name\"\n"; print "# Taking pg_basebackup $backup_name from node \"$name\"\n";
TestLib::system_or_bail("pg_basebackup -D $backup_path -p $port -x"); TestLib::system_or_bail('pg_basebackup', '-D', $backup_path,
'-p', $port, '-x');
print "# Backup finished\n"; print "# Backup finished\n";
} }
...@@ -763,7 +764,7 @@ sub enable_restoring ...@@ -763,7 +764,7 @@ sub enable_restoring
my $copy_command = my $copy_command =
$TestLib::windows_os $TestLib::windows_os
? qq{copy "$path\\\\%f" "%p"} ? qq{copy "$path\\\\%f" "%p"}
: qq{cp $path/%f %p}; : qq{cp "$path/%f" "%p"};
$self->append_conf( $self->append_conf(
'recovery.conf', qq( 'recovery.conf', qq(
...@@ -791,7 +792,7 @@ sub enable_archiving ...@@ -791,7 +792,7 @@ sub enable_archiving
my $copy_command = my $copy_command =
$TestLib::windows_os $TestLib::windows_os
? qq{copy "%p" "$path\\\\%f"} ? qq{copy "%p" "$path\\\\%f"}
: qq{cp %p $path/%f}; : qq{cp "%p" "$path/%f"};
# Enable archive_mode and archive_command on node # Enable archive_mode and archive_command on node
$self->append_conf( $self->append_conf(
......
...@@ -381,12 +381,21 @@ sub GenerateTimezoneFiles ...@@ -381,12 +381,21 @@ sub GenerateTimezoneFiles
my $mf = read_file("src/timezone/Makefile"); my $mf = read_file("src/timezone/Makefile");
$mf =~ s{\\\r?\n}{}g; $mf =~ s{\\\r?\n}{}g;
$mf =~ /^TZDATA\s*:?=\s*(.*)$/m $mf =~ /^TZDATA\s*:?=\s*(.*)$/m
|| die "Could not find TZDATA row in timezone makefile\n"; || die "Could not find TZDATA line in timezone makefile\n";
my @tzfiles = split /\s+/, $1; my @tzfiles = split /\s+/, $1;
unshift @tzfiles, '';
print "Generating timezone files..."; print "Generating timezone files...";
system("$conf\\zic\\zic -d \"$target/share/timezone\" "
. join(" src/timezone/data/", @tzfiles)); my @args = ("$conf/zic/zic",
'-d',
"$target/share/timezone");
foreach (@tzfiles)
{
my $tzfile = $_;
push(@args, "src/timezone/data/$tzfile")
}
system(@args);
print "\n"; print "\n";
} }
...@@ -634,9 +643,10 @@ sub CopyIncludeFiles ...@@ -634,9 +643,10 @@ sub CopyIncludeFiles
next unless (-d "src/include/$d"); next unless (-d "src/include/$d");
EnsureDirectories("$target/include/server/$d"); EnsureDirectories("$target/include/server/$d");
system( my @args = ('xcopy', '/s', '/i', '/q', '/r', '/y',
qq{xcopy /s /i /q /r /y src\\include\\$d\\*.h "$ctarget\\include\\server\\$d\\"} "src\\include\\$d\\*.h",
) && croak("Failed to copy include directory $d\n"); "$ctarget\\include\\server\\$d\\");
system(@args) && croak("Failed to copy include directory $d\n");
} }
closedir($D); closedir($D);
...@@ -689,9 +699,11 @@ sub GenerateNLSFiles ...@@ -689,9 +699,11 @@ sub GenerateNLSFiles
EnsureDirectories($target, "share/locale/$lang", EnsureDirectories($target, "share/locale/$lang",
"share/locale/$lang/LC_MESSAGES"); "share/locale/$lang/LC_MESSAGES");
system( my @args = ("$nlspath\\bin\\msgfmt",
"\"$nlspath\\bin\\msgfmt\" -o \"$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo\" $_" '-o',
) && croak("Could not run msgfmt on $dir\\$_"); "$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo",
$_);
system(@args) && croak("Could not run msgfmt on $dir\\$_");
print "."; print ".";
} }
} }
......
...@@ -412,35 +412,41 @@ sub upgradecheck ...@@ -412,35 +412,41 @@ sub upgradecheck
print "\nRunning initdb on old cluster\n\n"; print "\nRunning initdb on old cluster\n\n";
standard_initdb() or exit 1; standard_initdb() or exit 1;
print "\nStarting old cluster\n\n"; print "\nStarting old cluster\n\n";
system("pg_ctl start -l $logdir/postmaster1.log -w") == 0 or exit 1; my @args = ('pg_ctl', 'start', '-l', "$logdir/postmaster1.log", '-w');
system(@args) == 0 or exit 1;
print "\nSetting up data for upgrading\n\n"; print "\nSetting up data for upgrading\n\n";
installcheck(); installcheck();
# now we can chdir into the source dir # now we can chdir into the source dir
chdir "$topdir/src/bin/pg_upgrade"; chdir "$topdir/src/bin/pg_upgrade";
print "\nDumping old cluster\n\n"; print "\nDumping old cluster\n\n";
system("pg_dumpall -f $tmp_root/dump1.sql") == 0 or exit 1; @args = ('pg_dumpall', '-f', "$tmp_root/dump1.sql");
system(@args) == 0 or exit 1;
print "\nStopping old cluster\n\n"; print "\nStopping old cluster\n\n";
system("pg_ctl -m fast stop") == 0 or exit 1; system("pg_ctl -m fast stop") == 0 or exit 1;
$ENV{PGDATA} = "$data"; $ENV{PGDATA} = "$data";
print "\nSetting up new cluster\n\n"; print "\nSetting up new cluster\n\n";
standard_initdb() or exit 1; standard_initdb() or exit 1;
print "\nRunning pg_upgrade\n\n"; print "\nRunning pg_upgrade\n\n";
system("pg_upgrade -d $data.old -D $data -b $bindir -B $bindir") == 0 @args = ('pg_upgrade', '-d', "$data.old", '-D', $data, '-b', $bindir,
or exit 1; '-B', $bindir);
system(@args) == 0 or exit 1;
print "\nStarting new cluster\n\n"; print "\nStarting new cluster\n\n";
system("pg_ctl -l $logdir/postmaster2.log -w start") == 0 or exit 1; @args = ('pg_ctl', '-l', "$logdir/postmaster2.log", '-w', 'start');
system(@args) == 0 or exit 1;
print "\nSetting up stats on new cluster\n\n"; print "\nSetting up stats on new cluster\n\n";
system(".\\analyze_new_cluster.bat") == 0 or exit 1; system(".\\analyze_new_cluster.bat") == 0 or exit 1;
print "\nDumping new cluster\n\n"; print "\nDumping new cluster\n\n";
system("pg_dumpall -f $tmp_root/dump2.sql") == 0 or exit 1; @args = ('pg_dumpall', '-f', "$tmp_root/dump2.sql");
system(@args) == 0 or exit 1;
print "\nStopping new cluster\n\n"; print "\nStopping new cluster\n\n";
system("pg_ctl -m fast stop") == 0 or exit 1; system("pg_ctl -m fast stop") == 0 or exit 1;
print "\nDeleting old cluster\n\n"; print "\nDeleting old cluster\n\n";
system(".\\delete_old_cluster.bat") == 0 or exit 1; system(".\\delete_old_cluster.bat") == 0 or exit 1;
print "\nComparing old and new cluster dumps\n\n"; print "\nComparing old and new cluster dumps\n\n";
system("diff -q $tmp_root/dump1.sql $tmp_root/dump2.sql"); @args = ('diff', '-q', "$tmp_root/dump1.sql", "$tmp_root/dump2.sql");
system(@args);
$status = $?; $status = $?;
if (!$status) if (!$status)
{ {
......
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