v02-PG15-16-17-pg_dumpall-clean-and-data-only-are-incompatible.noci
application/octet-stream
Filename: v02-PG15-16-17-pg_dumpall-clean-and-data-only-are-incompatible.noci
Type: application/octet-stream
Part: 3
From 1d4cc989d2484d4734cd8071da31ce3cf8801401 Mon Sep 17 00:00:00 2001
From: Mahendra Singh Thalor <mahi6run@gmail.com>
Date: Sun, 15 Mar 2026 19:17:13 +0530
Subject: [PATCH] PG15 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.
PG15
---
src/bin/pg_dump/pg_dumpall.c | 8 ++++++++
src/bin/pg_dump/t/001_basic.pl | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 06e9ac10f56..6aedf2761d5 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -383,6 +383,14 @@ main(int argc, char *argv[])
exit_nicely(1);
}
+ /* --clean and --data-only are incompatible */
+ if (output_clean && data_only)
+ {
+ pg_log_error("options -c/--clean and -a/--data-only cannot be used together");
+ pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+ exit_nicely(1);
+ }
+
if (if_exists && !output_clean)
pg_fatal("option --if-exists requires option -c/--clean");
diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index a583c8a6d24..5ba4df928aa 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 -s/--schema-only and -a/--data-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', '--include-foreign-data=xxx' ],
qr/\Qpg_dump: error: options -s\/--schema-only and --include-foreign-data cannot be used together\E/,
--
2.52.0