From ddaff0adb9db990c131b854bc04b08f2c1207193 Mon Sep 17 00:00:00 2001
From: Andrey Tsygunka <aitsygunka@yandex.ru>
Date: Sat, 25 Oct 2025 17:29:40 +0300
Subject: [PATCH] tests: fix an unexpected termination of the test script when 
 calling 'query()'

When calling the 'query()' method after the psql session was
terminated for some reason, the test script process also
terminates prematurely without returning an error. This
occurs when calling 'pump_until()' to get the stderr stream
in 'query()'.

Added a pumpable check to ensure the psql process is alive.

Fixes: 8b886a4e3488 (tests: BackgroundPsql: Fix potential for lost errors on windows)
Signed-off-by: Andrey Tsygunka <aitsygunka@yandex.ru>
---
 src/test/perl/PostgreSQL/Test/BackgroundPsql.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
index 60bbd5dd445..efd0945c11f 100644
--- a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
+++ b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
@@ -272,7 +272,7 @@ sub query
 		\$self->{stdout}, qr/$banner_match/);
 	pump_until(
 		$self->{run}, $self->{timeout},
-		\$self->{stderr}, qr/$banner_match/);
+		\$self->{stderr}, qr/$banner_match/) if $self->{run}->pumpable;
 
 	die "psql query timed out" if $self->{timeout}->is_expired;
 
-- 
2.25.1

