From 163956c37940aeee1bf4c48fb62ae22612ec89be Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 13 Oct 2025 16:43:06 -0400
Subject: [PATCH v4 4/4] Widen the wide row used to verify correct (de)
 compression.

Commit 1a05c1d25 advises us (not without reason) to ensure that this
test case fully fills DEFAULT_IO_BUFFER_SIZE, so that loops within
the compression logic will iterate completely.  To follow that
advice with the proposed DEFAULT_IO_BUFFER_SIZE of 128K, we need
something close to this.  This does indeed increase the reported
code coverage by a few lines.

This is a very expensive test, however: it increases the total
runtime of 002_pg_dump.pl by about 12% for me, and that's already
one of the more expensive TAP tests.  I wonder if there isn't a
less brute-force way of getting the same result.  If there's not,
is this really worth it?

One idea is to take this out of the main structure of 002_pg_dump.pl
so that the test instance is run just once per compression type,
rather than many many times as it is here.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3515357.1760128017@sss.pgh.pa.us
---
 src/bin/pg_dump/t/002_pg_dump.pl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 8b287a673bf..8bbd6ed47a9 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -3732,14 +3732,15 @@ my %tests = (
 	},
 
 	# Insert enough data to surpass DEFAULT_IO_BUFFER_SIZE during
-	# (de)compression operations
+	# (de)compression operations.  The weird regex is because Perl
+	# restricts us to repeat counts of less than 32K.
 	'COPY test_compression_method' => {
 		create_order => 111,
 		create_sql => 'INSERT INTO dump_test.test_compression_method (col1) '
-		  . 'SELECT string_agg(a::text, \'\') FROM generate_series(1,4096) a;',
+		  . 'SELECT string_agg(a::text, \'\') FROM generate_series(1,65536) a;',
 		regexp => qr/^
 			\QCOPY dump_test.test_compression_method (col1) FROM stdin;\E
-			\n(?:\d{15277}\n){1}\\\.\n
+			\n(?:(?:\d\d\d\d\d\d\d\d\d\d){31657}\d\d\d\d\n){1}\\\.\n
 			/xm,
 		like => {
 			%full_runs,
-- 
2.43.7

