]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Avoid uninitialized value error in TAP tests' Cluster->psql
authorAndrew Dunstan <andrew@dunslane.net>
Mon, 30 Jun 2025 13:49:31 +0000 (09:49 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Mon, 30 Jun 2025 13:49:50 +0000 (09:49 -0400)
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

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

index 49b2c86b29cbf61f2f327b4e08545c6b97f379e8..301766d2ed93c4b87cb156bbe9b436a68b4c6199 100644 (file)
@@ -2199,6 +2199,14 @@ sub psql
                        $ret = $?;
                };
                my $exc_save = $@;
+
+               # we need a dummy $stderr from hereon, if we didn't collect it
+               if (! defined $stderr)
+               {
+                       my $errtxt = "<not collected>";
+                       $stderr = \$errtxt;
+               }
+
                if ($exc_save)
                {