68 static int enable_row_security = 0;
70 static int no_data_for_failed_tables = 0;
71 static int outputNoTableAm = 0;
72 static int outputNoTablespaces = 0;
80 struct option cmdopts[] = {
81 {
"clean", 0, NULL,
'c'},
82 {
"create", 0, NULL,
'C'},
83 {
"data-only", 0, NULL,
'a'},
84 {
"dbname", 1, NULL,
'd'},
85 {
"exit-on-error", 0, NULL,
'e'},
86 {
"exclude-schema", 1, NULL,
'N'},
87 {
"file", 1, NULL,
'f'},
88 {
"format", 1, NULL,
'F'},
89 {
"function", 1, NULL,
'P'},
90 {
"host", 1, NULL,
'h'},
91 {
"index", 1, NULL,
'I'},
92 {
"jobs", 1, NULL,
'j'},
93 {
"list", 0, NULL,
'l'},
94 {
"no-privileges", 0, NULL,
'x'},
95 {
"no-acl", 0, NULL,
'x'},
96 {
"no-owner", 0, NULL,
'O'},
97 {
"no-reconnect", 0, NULL,
'R'},
98 {
"port", 1, NULL,
'p'},
99 {
"no-password", 0, NULL,
'w'},
100 {
"password", 0, NULL,
'W'},
101 {
"schema", 1, NULL,
'n'},
102 {
"schema-only", 0, NULL,
's'},
103 {
"superuser", 1, NULL,
'S'},
104 {
"table", 1, NULL,
't'},
105 {
"trigger", 1, NULL,
'T'},
106 {
"use-list", 1, NULL,
'L'},
107 {
"username", 1, NULL,
'U'},
108 {
"verbose", 0, NULL,
'v'},
109 {
"single-transaction", 0, NULL,
'1'},
115 {
"enable-row-security",
no_argument, &enable_row_security, 1},
117 {
"no-data-for-failed-tables",
no_argument, &no_data_for_failed_tables, 1},
118 {
"no-table-access-method",
no_argument, &outputNoTableAm, 1},
119 {
"no-tablespaces",
no_argument, &outputNoTablespaces, 1},
146 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
151 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
153 puts(
"pg_restore (PostgreSQL) " PG_VERSION);
158 while ((
c =
getopt_long(argc, argv,
"acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
159 cmdopts, NULL)) != -1)
167 opts->dropSchema = 1;
176 opts->exit_on_error =
true;
198 opts->tocSummary = 1;
226 opts->selFunction = 1;
236 opts->selTrigger = 1;
240 opts->schemaOnly = 1;
274 opts->single_txn =
true;
275 opts->exit_on_error =
true;
302 opts->exit_on_error =
true;
314 inputFileSpec = argv[
optind++];
316 inputFileSpec = NULL;
321 pg_log_error(
"too many command-line arguments (first is \"%s\")",
328 if (!
opts->cparams.dbname && !
opts->filename && !
opts->tocSummary)
329 pg_fatal(
"one of -d/--dbname and -f/--file must be specified");
332 if (
opts->cparams.dbname)
336 pg_log_error(
"options -d/--dbname and -f/--file cannot be used together");
343 if (
opts->dataOnly &&
opts->schemaOnly)
344 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
346 if (
opts->dataOnly &&
opts->dropSchema)
347 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
349 if (
opts->single_txn &&
opts->txn_size > 0)
350 pg_fatal(
"options -1/--single-transaction and --transaction-size cannot be used together");
356 if (
opts->createDB &&
opts->single_txn)
357 pg_fatal(
"options -C/--create and -1/--single-transaction cannot be used together");
360 if (
opts->single_txn && numWorkers > 1)
361 pg_fatal(
"cannot specify both --single-transaction and multiple jobs");
364 opts->enable_row_security = enable_row_security;
365 opts->noDataForFailedTables = no_data_for_failed_tables;
366 opts->noTableAm = outputNoTableAm;
367 opts->noTablespace = outputNoTablespaces;
375 pg_fatal(
"option --if-exists requires option -c/--clean");
379 if (
opts->formatName)
381 switch (
opts->formatName[0])
399 pg_fatal(
"unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
428 if (
opts->tocSummary)
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 * 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)
void CloseArchive(Archive *AHX)
void SortTocFromFile(Archive *AHX)
void PrintTOCSummary(Archive *AHX)
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void RestoreArchive(Archive *AHX)
Archive * OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
void set_dump_section(const char *arg, int *dumpSections)
static int disable_triggers
#define exit_nicely(code)
static int no_publications
static int no_security_labels
static int use_setsessauth
static int no_subscriptions
PGDLLIMPORT char * optarg
static void usage(const char *progname)
static void read_restore_filters(const char *filename, RestoreOptions *opts)
#define pg_log_warning(...)
const char * get_progname(const char *argv0)
void simple_string_list_append(SimpleStringList *list, const char *val)