66 static int enable_row_security = 0;
68 static int no_data_for_failed_tables = 0;
69 static int outputNoTableAm = 0;
70 static int outputNoTablespaces = 0;
78 struct option cmdopts[] = {
79 {
"clean", 0, NULL,
'c'},
80 {
"create", 0, NULL,
'C'},
81 {
"data-only", 0, NULL,
'a'},
82 {
"dbname", 1, NULL,
'd'},
83 {
"exit-on-error", 0, NULL,
'e'},
84 {
"exclude-schema", 1, NULL,
'N'},
85 {
"file", 1, NULL,
'f'},
86 {
"format", 1, NULL,
'F'},
87 {
"function", 1, NULL,
'P'},
88 {
"host", 1, NULL,
'h'},
89 {
"index", 1, NULL,
'I'},
90 {
"jobs", 1, NULL,
'j'},
91 {
"list", 0, NULL,
'l'},
92 {
"no-privileges", 0, NULL,
'x'},
93 {
"no-acl", 0, NULL,
'x'},
94 {
"no-owner", 0, NULL,
'O'},
95 {
"no-reconnect", 0, NULL,
'R'},
96 {
"port", 1, NULL,
'p'},
97 {
"no-password", 0, NULL,
'w'},
98 {
"password", 0, NULL,
'W'},
99 {
"schema", 1, NULL,
'n'},
100 {
"schema-only", 0, NULL,
's'},
101 {
"superuser", 1, NULL,
'S'},
102 {
"table", 1, NULL,
't'},
103 {
"trigger", 1, NULL,
'T'},
104 {
"use-list", 1, NULL,
'L'},
105 {
"username", 1, NULL,
'U'},
106 {
"verbose", 0, NULL,
'v'},
107 {
"single-transaction", 0, NULL,
'1'},
113 {
"enable-row-security",
no_argument, &enable_row_security, 1},
115 {
"no-data-for-failed-tables",
no_argument, &no_data_for_failed_tables, 1},
116 {
"no-table-access-method",
no_argument, &outputNoTableAm, 1},
117 {
"no-tablespaces",
no_argument, &outputNoTablespaces, 1},
142 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
147 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
149 puts(
"pg_restore (PostgreSQL) " PG_VERSION);
154 while ((
c =
getopt_long(argc, argv,
"acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
155 cmdopts, NULL)) != -1)
163 opts->dropSchema = 1;
172 opts->exit_on_error =
true;
194 opts->tocSummary = 1;
222 opts->selFunction = 1;
232 opts->selTrigger = 1;
236 opts->schemaOnly = 1;
270 opts->single_txn =
true;
271 opts->exit_on_error =
true;
298 inputFileSpec = argv[
optind++];
300 inputFileSpec = NULL;
305 pg_log_error(
"too many command-line arguments (first is \"%s\")",
312 if (!
opts->cparams.dbname && !
opts->filename && !
opts->tocSummary)
313 pg_fatal(
"one of -d/--dbname and -f/--file must be specified");
316 if (
opts->cparams.dbname)
320 pg_log_error(
"options -d/--dbname and -f/--file cannot be used together");
327 if (
opts->dataOnly &&
opts->schemaOnly)
328 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
330 if (
opts->dataOnly &&
opts->dropSchema)
331 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
337 if (
opts->createDB &&
opts->single_txn)
338 pg_fatal(
"options -C/--create and -1/--single-transaction cannot be used together");
341 if (
opts->single_txn && numWorkers > 1)
342 pg_fatal(
"cannot specify both --single-transaction and multiple jobs");
345 opts->enable_row_security = enable_row_security;
346 opts->noDataForFailedTables = no_data_for_failed_tables;
347 opts->noTableAm = outputNoTableAm;
348 opts->noTablespace = outputNoTablespaces;
356 pg_fatal(
"option --if-exists requires option -c/--clean");
360 if (
opts->formatName)
362 switch (
opts->formatName[0])
380 pg_fatal(
"unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
409 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)
#define pg_log_warning(...)
const char * get_progname(const char *argv0)
void simple_string_list_append(SimpleStringList *list, const char *val)