67 static int enable_row_security = 0;
69 static int no_data_for_failed_tables = 0;
70 static int outputNoTableAm = 0;
71 static int outputNoTablespaces = 0;
79 struct option cmdopts[] = {
80 {
"clean", 0, NULL,
'c'},
81 {
"create", 0, NULL,
'C'},
82 {
"data-only", 0, NULL,
'a'},
83 {
"dbname", 1, NULL,
'd'},
84 {
"exit-on-error", 0, NULL,
'e'},
85 {
"exclude-schema", 1, NULL,
'N'},
86 {
"file", 1, NULL,
'f'},
87 {
"format", 1, NULL,
'F'},
88 {
"function", 1, NULL,
'P'},
89 {
"host", 1, NULL,
'h'},
90 {
"index", 1, NULL,
'I'},
91 {
"jobs", 1, NULL,
'j'},
92 {
"list", 0, NULL,
'l'},
93 {
"no-privileges", 0, NULL,
'x'},
94 {
"no-acl", 0, NULL,
'x'},
95 {
"no-owner", 0, NULL,
'O'},
96 {
"no-reconnect", 0, NULL,
'R'},
97 {
"port", 1, NULL,
'p'},
98 {
"no-password", 0, NULL,
'w'},
99 {
"password", 0, NULL,
'W'},
100 {
"schema", 1, NULL,
'n'},
101 {
"schema-only", 0, NULL,
's'},
102 {
"superuser", 1, NULL,
'S'},
103 {
"table", 1, NULL,
't'},
104 {
"trigger", 1, NULL,
'T'},
105 {
"use-list", 1, NULL,
'L'},
106 {
"username", 1, NULL,
'U'},
107 {
"verbose", 0, NULL,
'v'},
108 {
"single-transaction", 0, NULL,
'1'},
114 {
"enable-row-security",
no_argument, &enable_row_security, 1},
116 {
"no-data-for-failed-tables",
no_argument, &no_data_for_failed_tables, 1},
117 {
"no-table-access-method",
no_argument, &outputNoTableAm, 1},
118 {
"no-tablespaces",
no_argument, &outputNoTablespaces, 1},
145 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
150 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
152 puts(
"pg_restore (PostgreSQL) " PG_VERSION);
157 while ((
c =
getopt_long(argc, argv,
"acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
158 cmdopts, NULL)) != -1)
166 opts->dropSchema = 1;
175 opts->exit_on_error =
true;
197 opts->tocSummary = 1;
225 opts->selFunction = 1;
235 opts->selTrigger = 1;
239 opts->schemaOnly = 1;
273 opts->single_txn =
true;
274 opts->exit_on_error =
true;
301 opts->exit_on_error =
true;
313 inputFileSpec = argv[
optind++];
315 inputFileSpec = NULL;
320 pg_log_error(
"too many command-line arguments (first is \"%s\")",
327 if (!
opts->cparams.dbname && !
opts->filename && !
opts->tocSummary)
328 pg_fatal(
"one of -d/--dbname and -f/--file must be specified");
331 if (
opts->cparams.dbname)
335 pg_log_error(
"options -d/--dbname and -f/--file cannot be used together");
342 if (
opts->dataOnly &&
opts->schemaOnly)
343 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
345 if (
opts->dataOnly &&
opts->dropSchema)
346 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
348 if (
opts->single_txn &&
opts->txn_size > 0)
349 pg_fatal(
"options -1/--single-transaction and --transaction-size cannot be used together");
355 if (
opts->createDB &&
opts->single_txn)
356 pg_fatal(
"options -C/--create and -1/--single-transaction cannot be used together");
359 if (
opts->single_txn && numWorkers > 1)
360 pg_fatal(
"cannot specify both --single-transaction and multiple jobs");
363 opts->enable_row_security = enable_row_security;
364 opts->noDataForFailedTables = no_data_for_failed_tables;
365 opts->noTableAm = outputNoTableAm;
366 opts->noTablespace = outputNoTablespaces;
374 pg_fatal(
"option --if-exists requires option -c/--clean");
378 if (
opts->formatName)
380 switch (
opts->formatName[0])
398 pg_fatal(
"unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
427 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)