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

Commite72059f

Browse files
committed
pg_restore: Don't allow non-positive number of jobs
pg_restore will currently accept invalid values for the number ofparallel jobs to run (eg: -1), unlike pg_dump which does check that thevalue provided is reasonable.Worse, '-1' is actually a valid, independent, parameter (as an alias for--single-transaction), leading to potentially completely unexpectedresults from a command line such as: -> pg_restore -j -1Where a user would get neither parallel jobs nor a single-transaction.Add in validity checking of the parallel jobs option, as we already havein pg_dump, before we try to open up the archive. Also move the checkthat we haven't been asked to run more parallel jobs than possible onWindows to the same place, so we do all the option validity checkingbefore opening the archive.Back-patch all the way, though for 9.2 we're adding the Windows-specificcheck against MAXIMUM_WAIT_OBJECTS as that check wasn't back-patchedoriginally.Discussion:https://www.postgresql.org/message-id/20170110044815.GC18360%40tamriel.snowman.net
1 parent268f9e3 commite72059f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

‎src/bin/pg_dump/pg_restore.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,22 @@ main(int argc, char **argv)
330330
exit_nicely(1);
331331
}
332332

333+
if (numWorkers <=0)
334+
{
335+
fprintf(stderr,_("%s: invalid number of parallel jobs\n"),progname);
336+
exit(1);
337+
}
338+
339+
/* See comments in pg_dump.c */
340+
#ifdefWIN32
341+
if (numWorkers>MAXIMUM_WAIT_OBJECTS)
342+
{
343+
fprintf(stderr,_("%s: maximum number of parallel jobs is %d\n"),
344+
progname,MAXIMUM_WAIT_OBJECTS);
345+
exit(1);
346+
}
347+
#endif
348+
333349
/* Can't do single-txn mode with multiple connections */
334350
if (opts->single_txn&&numWorkers>1)
335351
{
@@ -402,16 +418,6 @@ main(int argc, char **argv)
402418
if (opts->tocFile)
403419
SortTocFromFile(AH);
404420

405-
/* See comments in pg_dump.c */
406-
#ifdefWIN32
407-
if (numWorkers>MAXIMUM_WAIT_OBJECTS)
408-
{
409-
fprintf(stderr,_("%s: maximum number of parallel jobs is %d\n"),
410-
progname,MAXIMUM_WAIT_OBJECTS);
411-
exit(1);
412-
}
413-
#endif
414-
415421
AH->numWorkers=numWorkers;
416422

417423
if (opts->tocSummary)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp