diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 3d2a1d27aef..20cdd2d92f0 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..86eec1b0064 100644 --- a/src/bin/pg_dump/t/001_basic.pl +++ b/src/bin/pg_dump/t/001_basic.pl @@ -101,6 +101,11 @@ command_fails_like( qr/\Qpg_dump: error: options -c\/--clean and -a\/--data-only cannot be used together\E/, 'pg_dump: options -c/--clean 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_restore', '-c', '-a', '-f -' ], qr/\Qpg_restore: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,