Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc34bca9

Browse files
committed
Consolidate cross-option checks in pg_restore
This moves one check for conflicting options from the archive restorecode to the main function where other similar checks are performed.Also reword the error message to be consistent with other messages.The only option combination impacted is --create specified with--single-transaction, and informing the caller at an early step savesfrom opening the archive worked on. A TAP test is added for thiscombination.Author: Daniel GustafssonReviewed-by: Fabien CoelhoDiscussion:https://postgr.es/m/616808BD-4B59-4E6C-97A9-7317F62D5570@yesql.se
1 parentd5eec4e commitc34bca9

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,6 @@ RestoreArchive(Archive *AHX)
358358

359359
AH->stage=STAGE_INITIALIZING;
360360

361-
/*
362-
* Check for nonsensical option combinations.
363-
*
364-
* -C is not compatible with -1, because we can't create a database inside
365-
* a transaction block.
366-
*/
367-
if (ropt->createDB&&ropt->single_txn)
368-
exit_horribly(modulename,"-C and -1 are incompatible options\n");
369-
370361
/*
371362
* If we're going to do parallel restore, there are some restrictions.
372363
*/

‎src/bin/pg_dump/pg_restore.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@ main(int argc, char **argv)
331331
exit_nicely(1);
332332
}
333333

334+
/*
335+
* -C is not compatible with -1, because we can't create a database inside
336+
* a transaction block.
337+
*/
338+
if (opts->createDB&&opts->single_txn)
339+
{
340+
fprintf(stderr,_("%s: options -C/--create and -1/--single-transaction cannot be used together\n"),
341+
progname);
342+
exit_nicely(1);
343+
}
344+
334345
if (numWorkers <=0)
335346
{
336347
fprintf(stderr,_("%s: invalid number of parallel jobs\n"),progname);

‎src/bin/pg_dump/t/001_basic.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Config;
55
use PostgresNode;
66
use TestLib;
7-
use Test::Moretests=>70;
7+
use Test::Moretests=>72;
88

99
my$tempdir = TestLib::tempdir;
1010
my$tempdir_short = TestLib::tempdir_short;
@@ -150,3 +150,9 @@
150150
['pg_dumpall','--if-exists' ],
151151
qr/\Qpg_dumpall: option --if-exists requires option -c\/--clean\E/,
152152
'pg_dumpall: option --if-exists requires option -c/--clean');
153+
154+
command_fails_like(
155+
['pg_restore','-C','-1' ],
156+
qr/\Qpg_restore: options -C\/--create and -1\/--single-transaction cannot be used together\E/,
157+
'pg_restore: options -C\/--create and -1\/--single-transaction cannot be used together'
158+
);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp