]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pg_dumpall: Fix handling of incompatible options.
authorNathan Bossart <nathan@postgresql.org>
Mon, 16 Mar 2026 16:01:20 +0000 (11:01 -0500)
committerNathan Bossart <nathan@postgresql.org>
Mon, 16 Mar 2026 16:01:20 +0000 (11:01 -0500)
This commit teaches pg_dumpall to fail when both --clean and
--data-only are specified.  Previously, it passed the options
through to pg_dump, which would fail after pg_dumpall had already
started producing output.  Like recent commits b2898baaf7 and
7c8280eeb5, no back-patch.

Author: Mahendra Singh Thalor <mahi6run@gmail.com>
Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Discussion: https://postgr.es/m/CAKYtNArrHiJ0LDB9BFZiUWs6tC78QkBN50wiwO07WhxewYDS3Q%40mail.gmail.com

src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/t/001_basic.pl

index 3d2a1d27aefddf32e517dc43b1dfc1d84f2c09ff..20cdd2d92f091bf838e26bb2d20bf0e68ee97ff7 100644 (file)
@@ -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");
index 2f5eb48e7b86c4e4ad8dfb3d358855dcd4fcbb14..86eec1b00641b34e21516565f3555759c4a64058 100644 (file)
@@ -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/,