In PostgresNode.pm, don't pass SQL to psql on the command line
authorAndrew Dunstan
Thu, 3 Jun 2021 20:08:33 +0000 (16:08 -0400)
committerAndrew Dunstan
Thu, 3 Jun 2021 20:14:06 +0000 (16:14 -0400)
The Msys shell mangles certain patterns in its command line, so avoid
handing arbitrary SQL to psql on the command line and instead use
IPC::Run's redirection facility for stdin. This pattern is already
mostly whats used, but query_poll_until() was not doing the right thing.

Problem discovered on the buildfarm when a new TAP test failed on msys.

src/test/perl/PostgresNode.pm

index 46530255e07c37e682e79d8a9f64030a3cb3eb20..45d16361286e2414f2dcd4de21989bf2c0a88de7 100644 (file)
@@ -2127,7 +2127,7 @@ sub poll_query_until
 
    my $cmd = [
        $self->installed_command('psql'),
-       '-XAt', '-c', $query, '-d', $self->connstr($dbname)
+       '-XAt', '-d', $self->connstr($dbname)
    ];
    my ($stdout, $stderr);
    my $max_attempts = 180 * 10;
@@ -2135,7 +2135,8 @@ sub poll_query_until
 
    while ($attempts < $max_attempts)
    {
-       my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
+       my $result = IPC::Run::run $cmd, '<', \$query,
+         '>', \$stdout, '2>', \$stderr;
 
        $stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
        chomp($stdout);