60{
64 int numWorkers = 1;
70 static int enable_row_security = 0;
73 static int outputNoTableAm = 0;
74 static int outputNoTablespaces = 0;
87
89 {
"clean", 0,
NULL,
'c'},
90 {
"create", 0,
NULL,
'C'},
91 {
"data-only", 0,
NULL,
'a'},
92 {
"dbname", 1,
NULL,
'd'},
93 {
"exit-on-error", 0,
NULL,
'e'},
94 {
"exclude-schema", 1,
NULL,
'N'},
95 {
"file", 1,
NULL,
'f'},
96 {
"format", 1,
NULL,
'F'},
97 {
"function", 1,
NULL,
'P'},
98 {
"host", 1,
NULL,
'h'},
99 {
"index", 1,
NULL,
'I'},
100 {
"jobs", 1,
NULL,
'j'},
101 {
"list", 0,
NULL,
'l'},
102 {
"no-privileges", 0,
NULL,
'x'},
103 {
"no-acl", 0,
NULL,
'x'},
104 {
"no-owner", 0,
NULL,
'O'},
105 {
"no-reconnect", 0,
NULL,
'R'},
106 {
"port", 1,
NULL,
'p'},
107 {
"no-password", 0,
NULL,
'w'},
108 {
"password", 0,
NULL,
'W'},
109 {
"schema", 1,
NULL,
'n'},
110 {
"schema-only", 0,
NULL,
's'},
111 {
"superuser", 1,
NULL,
'S'},
112 {
"table", 1,
NULL,
't'},
113 {
"trigger", 1,
NULL,
'T'},
114 {
"use-list", 1,
NULL,
'L'},
115 {
"username", 1,
NULL,
'U'},
116 {
"verbose", 0,
NULL,
'v'},
117 {
"single-transaction", 0,
NULL,
'1'},
118
119
120
121
123 {
"enable-row-security",
no_argument, &enable_row_security, 1},
126 {
"no-table-access-method",
no_argument, &outputNoTableAm, 1},
127 {
"no-tablespaces",
no_argument, &outputNoTablespaces, 1},
145
147 };
148
152
154
156
158
159 if (argc > 1)
160 {
161 if (
strcmp(argv[1],
"--help") == 0 ||
strcmp(argv[1],
"-?") == 0)
162 {
165 }
166 if (
strcmp(argv[1],
"--version") == 0 ||
strcmp(argv[1],
"-V") == 0)
167 {
170 }
171 }
172
173 while ((
c =
getopt_long(argc, argv,
"acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
175 {
177 {
178 case 'a':
180 break;
181 case 'c':
182 opts->dropSchema = 1;
183 break;
184 case 'C':
186 break;
187 case 'd':
189 break;
190 case 'e':
191 opts->exit_on_error =
true;
192 break;
193 case 'f':
195 break;
196 case 'F':
199 break;
200 case 'h':
203 break;
204
205 case 'j':
208 &numWorkers))
210 break;
211
212 case 'l':
213 opts->tocSummary = 1;
214 break;
215
216 case 'L':
218 break;
219
220 case 'n':
222 break;
223
224 case 'N':
226 break;
227
228 case 'O':
230 break;
231
232 case 'p':
235 break;
236 case 'R':
237
238 break;
239 case 'P':
241 opts->selFunction = 1;
243 break;
244 case 'I':
248 break;
249 case 'T':
251 opts->selTrigger = 1;
253 break;
254 case 's':
256 break;
257 case 'S':
260 break;
261 case 't':
265 break;
266
267 case 'U':
269 break;
270
271 case 'v':
274 break;
275
276 case 'w':
278 break;
279
280 case 'W':
282 break;
283
284 case 'x':
286 break;
287
288 case '1':
289 opts->single_txn =
true;
290 opts->exit_on_error =
true;
291 break;
292
293 case 0:
294
295
296
297
298 break;
299
300 case 2:
302 break;
303
304 case 3:
306 break;
307
308 case 4:
310 break;
311
312 case 5:
317 opts->exit_on_error =
true;
318 break;
319
320 case 6:
322 break;
323
324 default:
325
328 }
329 }
330
331
334 else
336
337
339 {
340 pg_log_error(
"too many command-line arguments (first is \"%s\")",
344 }
345
346
347 if (!
opts->cparams.dbname && !
opts->filename && !
opts->tocSummary)
348 pg_fatal(
"one of -d/--dbname and -f/--file must be specified");
349
350
351 if (
opts->cparams.dbname)
352 {
354 {
355 pg_log_error(
"options %s and %s cannot be used together",
356 "-d/--dbname", "-f/--file");
359 }
360
361 if (
opts->restrict_key)
362 pg_fatal(
"options %s and %s cannot be used together",
363 "-d/--dbname", "--restrict-key");
364
366 }
367 else
368 {
369
370
371
372 if (!
opts->restrict_key)
374 if (!
opts->restrict_key)
375 pg_fatal(
"could not generate restrict key");
378 }
379
380
382 pg_fatal(
"options %s and %s cannot be used together",
383 "-s/--schema-only", "-a/--data-only");
385 pg_fatal(
"options %s and %s cannot be used together",
386 "-s/--schema-only", "--statistics-only");
388 pg_fatal(
"options %s and %s cannot be used together",
389 "-a/--data-only", "--statistics-only");
390
391
393 pg_fatal(
"options %s and %s cannot be used together",
394 "-a/--data-only", "--no-data");
396 pg_fatal(
"options %s and %s cannot be used together",
397 "-s/--schema-only", "--no-schema");
399 pg_fatal(
"options %s and %s cannot be used together",
400 "--statistics-only", "--no-statistics");
401
402
404 pg_fatal(
"options %s and %s cannot be used together",
405 "--statistics", "--no-statistics");
406
407
409 pg_fatal(
"options %s and %s cannot be used together",
410 "-a/--data-only", "--statistics");
412 pg_fatal(
"options %s and %s cannot be used together",
413 "-s/--schema-only", "--statistics");
414
416 pg_fatal(
"options %s and %s cannot be used together",
417 "-c/--clean", "-a/--data-only");
418
419 if (
opts->single_txn &&
opts->txn_size > 0)
420 pg_fatal(
"options %s and %s cannot be used together",
421 "-1/--single-transaction", "--transaction-size");
422
423
424
425
426
427 if (
opts->createDB &&
opts->single_txn)
428 pg_fatal(
"options %s and %s cannot be used together",
429 "-C/--create", "-1/--single-transaction");
430
431
432 if (
opts->single_txn && numWorkers > 1)
433 pg_fatal(
"cannot specify both --single-transaction and multiple jobs");
434
435
436
437
438
439
446
448 opts->enable_row_security = enable_row_security;
450 opts->noTableAm = outputNoTableAm;
451 opts->noTablespace = outputNoTablespaces;
458
460 pg_fatal(
"option %s requires option %s",
461 "--if-exists", "-c/--clean");
464
465 if (
opts->formatName)
466 {
478 {
479
480 pg_fatal(
"archive format \"%s\" is not supported; please use psql",
482 }
483 else
484 pg_fatal(
"unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
486 }
487
489
491
492
493
494
495
496
498
499
501
502
503
504
506
509
511
512 if (
opts->tocSummary)
514 else
515 {
518 }
519
520
523
524
526
528
530}
void on_exit_close_archive(Archive *AHX)
void init_parallel_dump_utils(void)
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
char * generate_restrict_key(void)
bool valid_restrict_key(const char *restrict_key)
char * pg_strdup(const char *in)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
void pg_logging_increase_verbosity(void)
void pg_logging_init(const char *argv0)
void pg_logging_set_level(enum pg_log_level new_level)
#define pg_log_error(...)
#define pg_log_error_hint(...)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
static AmcheckOptions opts
void ProcessArchiveRestoreOptions(Archive *AHX)
RestoreOptions * NewRestoreOptions(void)
Archive * OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
void CloseArchive(Archive *AHX)
void SortTocFromFile(Archive *AHX)
void PrintTOCSummary(Archive *AHX)
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void RestoreArchive(Archive *AHX)
void exit_nicely(int code)
void set_dump_section(const char *arg, int *dumpSections)
static int statistics_only
static int disable_triggers
static int no_publications
static int no_security_labels
static int use_setsessauth
static int no_subscriptions
static int with_statistics
PGDLLIMPORT char * optarg
static void read_restore_filters(const char *filename, RestoreOptions *opts)
#define pg_log_warning(...)
int pg_strcasecmp(const char *s1, const char *s2)
const char * get_progname(const char *argv0)
void simple_string_list_append(SimpleStringList *list, const char *val)