0002-Do-not-dump-statistics-in-the-file-dumped-f-20250313.patch

text/x-patch

Filename: 0002-Do-not-dump-statistics-in-the-file-dumped-f-20250313.patch
Type: text/x-patch
Part: 2
Message: Re: Test to dump and restore objects left behind by regression

Patch

Format: format-patch
Series: patch 0002
Subject: Do not dump statistics in the file dumped for comparison
File+
src/bin/pg_upgrade/t/002_pg_upgrade.pl 7 7
From 75f2b869764d9db3ac5c548636ed5c2be8b47b36 Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Tue, 25 Feb 2025 11:42:51 +0530
Subject: [PATCH 2/3] Do not dump statistics in the file dumped for comparison

The dumped and restored statistics of a materialized view may differ as
reported in [1].  Hence do not dump the statistics to avoid differences
in the dump output from the original and restored database.

[1] https://www.postgresql.org/message-id/CAExHW5s47kmubpbbRJzSM-Zfe0Tj2O3GBagB7YAyE8rQ-V24Uw@mail.gmail.com

Ashutosh Bapat
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index bd8313cee6f..65f4c7d4f2b 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -641,15 +641,15 @@ sub get_dump_for_comparison
 	my $dumpfile = $tempdir . '/' . $file_prefix . '.sql';
 	my $dump_adjusted = "${dumpfile}_adjusted";
 
-	# Usually we avoid comparing statistics in our tests since it is flaky by
-	# nature. However, if statistics is dumped and restored it is expected to be
-	# restored as it is i.e. the statistics from the original database and that
-	# from the restored database should match. We turn off autovacuum on the
-	# source and the target database to avoid any statistics update during
-	# restore operation. Hence we do not exclude statistics from dump.
+	# If statistics is dumped and restored it is expected to be restored as it
+	# is i.e. the statistics from the original database and that from the
+	# restored database should match. We turn off autovacuum on the source and
+	# the target database to avoid any statistics update during restore
+	# operation. But as of now, there are cases when statistics is not being
+	# restored faithfully. Hence for now do not dump statistics.
 	$node->command_ok(
 		[
-			'pg_dump', '--no-sync', '-d', $node->connstr($db), '-f',
+			'pg_dump', '--no-sync', '--no-statistics', '-d', $node->connstr($db), '-f',
 			$dumpfile
 		],
 		'dump for comparison succeeded');
-- 
2.34.1