summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_archiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 8c20c263c4b..33182d5b445 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -147,6 +147,8 @@ InitDumpOptions(DumpOptions *opts)
opts->include_everything = true;
opts->cparams.promptPassword = TRI_DEFAULT;
opts->dumpSections = DUMP_UNSECTIONED;
+ opts->dumpSchema = true;
+ opts->dumpData = true;
}
/*
@@ -165,8 +167,8 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
dopt->cparams.username = ropt->cparams.username ? pg_strdup(ropt->cparams.username) : NULL;
dopt->cparams.promptPassword = ropt->cparams.promptPassword;
dopt->outputClean = ropt->dropSchema;
- dopt->dataOnly = ropt->dataOnly;
- dopt->schemaOnly = ropt->schemaOnly;
+ dopt->dumpData = ropt->dumpData;
+ dopt->dumpSchema = ropt->dumpSchema;
dopt->if_exists = ropt->if_exists;
dopt->column_inserts = ropt->column_inserts;
dopt->dumpSections = ropt->dumpSections;
@@ -419,12 +421,12 @@ RestoreArchive(Archive *AHX)
* Work out if we have an implied data-only restore. This can happen if
* the dump was data only or if the user has used a toc list to exclude
* all of the schema data. All we do is look for schema entries - if none
- * are found then we set the dataOnly flag.
+ * are found then we unset the dumpSchema flag.
*
* We could scan for wanted TABLE entries, but that is not the same as
- * dataOnly. At this stage, it seems unnecessary (6-Mar-2001).
+ * data-only. At this stage, it seems unnecessary (6-Mar-2001).
*/
- if (!ropt->dataOnly)
+ if (ropt->dumpSchema)
{
int impliedDataOnly = 1;
@@ -438,7 +440,7 @@ RestoreArchive(Archive *AHX)
}
if (impliedDataOnly)
{
- ropt->dataOnly = impliedDataOnly;
+ ropt->dumpSchema = false;
pg_log_info("implied data-only restore");
}
}
@@ -824,7 +826,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)
/* Dump any relevant dump warnings to stderr */
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{
- if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
+ if (ropt->dumpSchema && te->defn != NULL && strlen(te->defn) != 0)
pg_log_warning("warning from original dump file: %s", te->defn);
else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
pg_log_warning("warning from original dump file: %s", te->copyStmt);
@@ -1080,6 +1082,8 @@ NewRestoreOptions(void)
opts->dumpSections = DUMP_UNSECTIONED;
opts->compression_spec.algorithm = PG_COMPRESSION_NONE;
opts->compression_spec.level = 0;
+ opts->dumpSchema = true;
+ opts->dumpData = true;
return opts;
}
@@ -1090,7 +1094,7 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
RestoreOptions *ropt = AH->public.ropt;
/* This hack is only needed in a data-only restore */
- if (!ropt->dataOnly || !ropt->disable_triggers)
+ if (ropt->dumpSchema || !ropt->disable_triggers)
return;
pg_log_info("disabling triggers for %s", te->tag);
@@ -1116,7 +1120,7 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
RestoreOptions *ropt = AH->public.ropt;
/* This hack is only needed in a data-only restore */
- if (!ropt->dataOnly || !ropt->disable_triggers)
+ if (ropt->dumpSchema || !ropt->disable_triggers)
return;
pg_log_info("enabling triggers for %s", te->tag);
@@ -3147,13 +3151,13 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
if ((strcmp(te->desc, "<Init>") == 0) && (strcmp(te->tag, "Max OID") == 0))
return 0;
- /* Mask it if we only want schema */
- if (ropt->schemaOnly)
+ /* Mask it if we don't want data */
+ if (!ropt->dumpData)
{
/*
- * The sequence_data option overrides schemaOnly for SEQUENCE SET.
+ * The sequence_data option overrides dumpData for SEQUENCE SET.
*
- * In binary-upgrade mode, even with schemaOnly set, we do not mask
+ * In binary-upgrade mode, even with dumpData unset, we do not mask
* out large objects. (Only large object definitions, comments and
* other metadata should be generated in binary-upgrade mode, not the
* actual data, but that need not concern us here.)
@@ -3171,8 +3175,8 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
res = res & REQ_SCHEMA;
}
- /* Mask it if we only want data */
- if (ropt->dataOnly)
+ /* Mask it if we don't want schema */
+ if (!ropt->dumpSchema)
res = res & REQ_DATA;
return res;