Skip to content

Commit c3e28e9

Browse files
committed
Avoid uninitialized value error in TAP tests' Cluster->psql
If the method is called in scalar context and we didn't pass in a stderr handle, one won't be created. However, some error paths assume that it exists, so in this case create a dummy stderr to avoid the resulting perl error. Per gripe from Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru> and adapted from his patch. Discussion: https://postgr.es/m/378eac5de4b8ecb5be7bcdf2db9d2c4d@postgrespro.ru
1 parent 40a96cd commit c3e28e9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,14 @@ sub psql
21992199
$ret = $?;
22002200
};
22012201
my $exc_save = $@;
2202+
2203+
# we need a dummy $stderr from hereon, if we didn't collect it
2204+
if (! defined $stderr)
2205+
{
2206+
my $errtxt = "<not collected>";
2207+
$stderr = \$errtxt;
2208+
}
2209+
22022210
if ($exc_save)
22032211
{
22042212

0 commit comments

Comments
 (0)