From f9f1d98844318d020d315db6c1bd11b8a35c70a7 Mon Sep 17 00:00:00 2001 From: Mahendra Singh Thalor Date: Sun, 15 Mar 2026 18:55:43 +0530 Subject: [PATCH] PG18 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 PG18 --- src/bin/pg_dump/pg_dumpall.c | 9 +++++++++ src/bin/pg_dump/t/001_basic.pl | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 40b133bb230..1a19b82a1d2 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -423,6 +423,15 @@ main(int argc, char *argv[]) exit_nicely(1); } + /* --clean and --data-only are incompatible */ + if (output_clean && data_only) + { + pg_log_error("options %s and %s cannot be used together", + "-c/--clean", "-a/--data-only"); + pg_log_error_hint("Try \"%s --help\" for more information.", progname); + exit_nicely(1); + } + 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 37d893d5e6a..31ab2657ef9 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', '--statistics-only' ], qr/\Qpg_dump: error: options -s\/--schema-only and --statistics-only cannot be used together\E/, -- 2.52.0