v01-pg_dumpall-clean-and-data-only-are-incompatible.patch
text/x-patch
Filename: v01-pg_dumpall-clean-and-data-only-are-incompatible.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch v1
Subject: pg_dumpall: -clean and --data-only are incompatible
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_dumpall.c | 4 | 0 |
| src/bin/pg_dump/t/001_basic.pl | 5 | 0 |
From bbc014ab3e6d956df53aa7965d3a6b6d5d869baf Mon Sep 17 00:00:00 2001
From: Mahendra Singh Thalor <mahi6run@gmail.com>
Date: Sun, 15 Mar 2026 00:38:16 +0530
Subject: [PATCH] pg_dumpall: -clean and --data-only are incompatible
Report error when -clean and --data-only are given with pg_dumpall.
As of now, we are dumping some data and later we are exiting with
error from pg_dump.
---
src/bin/pg_dump/pg_dumpall.c | 4 ++++
src/bin/pg_dump/t/001_basic.pl | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 3d2a1d27aef..47a062d0160 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -455,6 +455,10 @@ main(int argc, char *argv[])
schema_only, "-s/--schema-only",
tablespaces_only, "-t/--tablespaces-only");
+ /* --clean and --data-only are incompatible */
+ check_mut_excl_opts(output_clean, "-c/--clean",
+ data_only, "-a/--data-only");
+
if (if_exists && !output_clean)
pg_fatal("option %s requires option %s",
"--if-exists", "-c/--clean");
diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index 2f5eb48e7b8..8aab1187282 100644
--- a/src/bin/pg_dump/t/001_basic.pl
+++ b/src/bin/pg_dump/t/001_basic.pl
@@ -50,6 +50,11 @@ command_fails_like(
'pg_dump: options -a/--data-only and -s/--schema-only cannot be used together'
);
+command_fails_like(
+ [ 'pg_dumpall', '-c', '-a' ],
+ qr/\Qpg_dumpall: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
+ 'pg_dumpall: options -c/--clean and -a/--data-only cannot be used together');
+
command_fails_like(
[ 'pg_dump', '-s', '--statistics-only' ],
qr/\Qpg_dump: error: options -s\/--schema-only and --statistics-only cannot be used together\E/,
--
2.52.0