mirror of
https://github.com/postgres/postgres.git
synced 2026-04-25 08:08:08 -04:00
pg_dumpall: Fix handling of incompatible options.
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 commitsb2898baaf7and7c8280eeb5, 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
This commit is contained in:
parent
cd8844e7db
commit
be0d0b457c
2 changed files with 9 additions and 0 deletions
|
|
@ -455,6 +455,10 @@ main(int argc, char *argv[])
|
||||||
schema_only, "-s/--schema-only",
|
schema_only, "-s/--schema-only",
|
||||||
tablespaces_only, "-t/--tablespaces-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)
|
if (if_exists && !output_clean)
|
||||||
pg_fatal("option %s requires option %s",
|
pg_fatal("option %s requires option %s",
|
||||||
"--if-exists", "-c/--clean");
|
"--if-exists", "-c/--clean");
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,11 @@ command_fails_like(
|
||||||
qr/\Qpg_dump: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
|
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');
|
'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(
|
command_fails_like(
|
||||||
[ 'pg_restore', '-c', '-a', '-f -' ],
|
[ 'pg_restore', '-c', '-a', '-f -' ],
|
||||||
qr/\Qpg_restore: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
|
qr/\Qpg_restore: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue