From 7b2f1cd78605cfc7812a41f616d47a8d1b4fed46 Mon Sep 17 00:00:00 2001
From: Melanie Plageman <melanieplageman@gmail.com>
Date: Thu, 30 Apr 2026 16:06:06 -0400
Subject: [PATCH v1_PG18 2/3] Turn off debug for pg_combinebackup TAP tests

Having --debug as the default option to pg_combinebackup in
init_from_backup() makes the logs extremely verbose. It seems better to
let developers set an environment variable or pass it as a keyword
argument to init_from_backup() to turn on debugging as they wish.
---
 src/test/perl/PostgreSQL/Test/Cluster.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 2e31c23a6ac..53ce8169f39 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -898,7 +898,11 @@ pathnames that should be used for the target cluster.
 
 To restore from an incremental backup, pass the parameter combine_with_prior
 as a reference to an array of prior backup names with which this backup
-is to be combined using pg_combinebackup.
+is to be combined using pg_combinebackup.  By default, pg_combinebackup is
+run without --debug.  To enable --debug output when diagnosing test
+failures, either pass combine_debug => 1 as a keyword parameter, or set
+the environment variable PG_TEST_PG_COMBINEBACKUP_DEBUG to a true value
+to enable it globally for all callers.
 
 Streaming replication can be enabled on this node by passing the keyword
 parameter has_streaming => 1. This is disabled by default.
@@ -949,7 +953,9 @@ sub init_from_backup
 		}
 
 		local %ENV = $self->_get_env();
-		my @combineargs = ('pg_combinebackup', '--debug');
+		my @combineargs = ('pg_combinebackup');
+		push @combineargs, '--debug'
+		  if $params{combine_debug} // $ENV{PG_TEST_PG_COMBINEBACKUP_DEBUG};
 		if (exists $params{tablespace_map})
 		{
 			while (my ($olddir, $newdir) = each %{ $params{tablespace_map} })
-- 
2.43.0

