0001-Fix-pg_waldump-test-for-libarchive-tar.patch
text/x-patch
Filename: 0001-Fix-pg_waldump-test-for-libarchive-tar.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Fix pg_waldump test for libarchive tar.
| File | + | − |
|---|---|---|
| src/bin/pg_waldump/t/001_basic.pl | 9 | 2 |
From b1a9131d072dadfe9c5666e75a932ba70b8d2f99 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 29 Mar 2026 12:03:42 +1300
Subject: [PATCH] Fix pg_waldump test for libarchive tar.
libarchive tar (the one shipped on macOS, *BSD systems) might decide to
archive non-standard sparse encoding with GNU extensions (unlike GNU tar
itself) by default. pg_waldump can't read them. Suppress that, if $TAR
understands --no-sparse-files.
Discussion: https://postgr.es/m/1624716.1774736283%40sss.pgh.pa.us
---
src/bin/pg_waldump/t/001_basic.pl | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/bin/pg_waldump/t/001_basic.pl b/src/bin/pg_waldump/t/001_basic.pl
index 8bb8fa225f6..d911296bb66 100644
--- a/src/bin/pg_waldump/t/001_basic.pl
+++ b/src/bin/pg_waldump/t/001_basic.pl
@@ -11,6 +11,14 @@ use Test::More;
use List::Util qw(shuffle);
my $tar = $ENV{TAR};
+my @TAR_C_FLAGS;
+
+# libarchive tar (as found on *BSD and macOS) might create sparse files by
+# default, and we can't read them
+if (system("$tar --no-read-sparse -c - /dev/null > /dev/null") == 0)
+{
+ push(@TAR_C_FLAGS, "--no-read-sparse");
+}
program_help_ok('pg_waldump');
program_version_ok('pg_waldump');
@@ -331,7 +339,6 @@ sub test_pg_waldump
sub generate_archive
{
my ($archive, $directory, $compression_flags) = @_;
-
my @files;
opendir my $dh, $directory or die "opendir: $!";
while (my $entry = readdir $dh) {
@@ -346,7 +353,7 @@ sub generate_archive
# move into the WAL directory before archiving files
my $cwd = getcwd;
chdir($directory) || die "chdir: $!";
- command_ok([$tar, $compression_flags, $archive, @files]);
+ command_ok([$tar, @TAR_C_FLAGS, $compression_flags, $archive, @files]);
chdir($cwd) || die "chdir: $!";
}
--
2.52.0