aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c9
-rw-r--r--src/bin/pg_dump/pg_restore.c11
-rw-r--r--src/bin/pg_dump/t/001_basic.pl8
3 files changed, 18 insertions, 10 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index e976def42aa..defa8a41b77 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -359,15 +359,6 @@ RestoreArchive(Archive *AHX)
AH->stage = STAGE_INITIALIZING;
/*
- * Check for nonsensical option combinations.
- *
- * -C is not compatible with -1, because we can't create a database inside
- * a transaction block.
- */
- if (ropt->createDB && ropt->single_txn)
- exit_horribly(modulename, "-C and -1 are incompatible options\n");
-
- /*
* If we're going to do parallel restore, there are some restrictions.
*/
parallel_mode = (AH->public.numWorkers > 1 && ropt->useDB);
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 34d93ab472b..44012ff44d1 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -331,6 +331,17 @@ main(int argc, char **argv)
exit_nicely(1);
}
+ /*
+ * -C is not compatible with -1, because we can't create a database inside
+ * a transaction block.
+ */
+ if (opts->createDB && opts->single_txn)
+ {
+ fprintf(stderr, _("%s: options -C/--create and -1/--single-transaction cannot be used together\n"),
+ progname);
+ exit_nicely(1);
+ }
+
if (numWorkers <= 0)
{
fprintf(stderr, _("%s: invalid number of parallel jobs\n"), progname);
diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index 17edf444b25..de00dbca392 100644
--- a/src/bin/pg_dump/t/001_basic.pl
+++ b/src/bin/pg_dump/t/001_basic.pl
@@ -4,7 +4,7 @@ use warnings;
use Config;
use PostgresNode;
use TestLib;
-use Test::More tests => 70;
+use Test::More tests => 72;
my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
@@ -150,3 +150,9 @@ command_fails_like(
[ 'pg_dumpall', '--if-exists' ],
qr/\Qpg_dumpall: option --if-exists requires option -c\/--clean\E/,
'pg_dumpall: option --if-exists requires option -c/--clean');
+
+command_fails_like(
+ [ 'pg_restore', '-C', '-1' ],
+ qr/\Qpg_restore: options -C\/--create and -1\/--single-transaction cannot be used together\E/,
+ 'pg_restore: options -C\/--create and -1\/--single-transaction cannot be used together'
+);