opts->include_everything = true;
opts->cparams.promptPassword = TRI_DEFAULT;
opts->dumpSections = DUMP_UNSECTIONED;
+ opts->dumpSchema = true;
+ opts->dumpData = true;
}
/*
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;
* 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;
}
if (impliedDataOnly)
{
- ropt->dataOnly = impliedDataOnly;
+ ropt->dumpSchema = false;
pg_log_info("implied data-only restore");
}
}
/* 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);
opts->dumpSections = DUMP_UNSECTIONED;
opts->compression_spec.algorithm = PG_COMPRESSION_NONE;
opts->compression_spec.level = 0;
+ opts->dumpSchema = true;
+ opts->dumpData = true;
return opts;
}
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);
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);
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.)
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;
char *error_detail = NULL;
bool user_compression_defined = false;
DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
+ bool data_only = false;
+ bool schema_only = false;
static DumpOptions dopt;
switch (c)
{
case 'a': /* Dump data only */
- dopt.dataOnly = true;
+ data_only = true;
break;
case 'b': /* Dump LOs */
break;
case 's': /* dump schema only */
- dopt.schemaOnly = true;
+ schema_only = true;
break;
case 'S': /* Username for superuser in plain text output */
if (dopt.binary_upgrade)
dopt.sequence_data = 1;
- if (dopt.dataOnly && dopt.schemaOnly)
+ if (data_only && schema_only)
pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
- if (dopt.schemaOnly && foreign_servers_include_patterns.head != NULL)
+ if (schema_only && foreign_servers_include_patterns.head != NULL)
pg_fatal("options -s/--schema-only and --include-foreign-data cannot be used together");
if (numWorkers > 1 && foreign_servers_include_patterns.head != NULL)
pg_fatal("option --include-foreign-data is not supported with parallel backup");
- if (dopt.dataOnly && dopt.outputClean)
+ if (data_only && dopt.outputClean)
pg_fatal("options -c/--clean and -a/--data-only cannot be used together");
if (dopt.if_exists && !dopt.outputClean)
pg_fatal("option --if-exists requires option -c/--clean");
+ /* set derivative flags */
+ dopt.dumpSchema = (!data_only);
+ dopt.dumpData = (!schema_only);
+
/*
* --inserts are already implied above if --column-inserts or
* --rows-per-insert were specified.
* -s means "schema only" and LOs are data, not schema, so we never
* include LOs when -s is used.
*/
- if (dopt.include_everything && !dopt.schemaOnly && !dopt.dontOutputLOs)
+ if (dopt.include_everything && dopt.dumpData && !dopt.dontOutputLOs)
dopt.outputLOs = true;
/*
*/
tblinfo = getSchemaData(fout, &numTables);
- if (!dopt.schemaOnly)
+ if (dopt.dumpData)
{
getTableData(&dopt, tblinfo, numTables, 0);
buildMatViewRefreshDependencies(fout);
- if (dopt.dataOnly)
+ if (!dopt.dumpSchema)
getTableDataFKConstraints();
}
- if (dopt.schemaOnly && dopt.sequence_data)
+ if (!dopt.dumpData && dopt.sequence_data)
getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
/*
ropt->cparams.username = dopt.cparams.username ? pg_strdup(dopt.cparams.username) : NULL;
ropt->cparams.promptPassword = dopt.cparams.promptPassword;
ropt->dropSchema = dopt.outputClean;
- ropt->dataOnly = dopt.dataOnly;
- ropt->schemaOnly = dopt.schemaOnly;
+ ropt->dumpData = dopt.dumpData;
+ ropt->dumpSchema = dopt.dumpSchema;
ropt->if_exists = dopt.if_exists;
ropt->column_inserts = dopt.column_inserts;
ropt->dumpSections = dopt.dumpSections;
* Mark a default ACL as to be dumped or not
*
* For per-schema default ACLs, dump if the schema is to be dumped.
- * Otherwise dump if we are dumping "everything". Note that dataOnly
+ * Otherwise dump if we are dumping "everything". Note that dumpSchema
* and aclsSkip are checked separately.
*/
static void
const char *cmd;
char *tag;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/*
char *qpubname;
bool first = true;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
delq = createPQExpBuffer();
PQExpBuffer query;
char *tag;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
tag = psprintf("%s %s", pubinfo->dobj.name, schemainfo->dobj.name);
PQExpBuffer query;
char *tag;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
tag = psprintf("%s %s", pubinfo->dobj.name, tbinfo->dobj.name);
PQExpBuffer query;
char *tag;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
Assert(fout->dopt->binary_upgrade && fout->remoteVersion >= 170000);
int i;
char two_phase_disabled[] = {LOGICALREP_TWOPHASE_STATE_DISABLED, '\0'};
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
delq = createPQExpBuffer();
/* hash partitioning didn't exist before v11 */
if (fout->remoteVersion < 110000)
return;
- /* needn't bother if schema-only dump */
- if (fout->dopt->schemaOnly)
+ /* needn't bother if not dumping data */
+ if (!fout->dopt->dumpData)
return;
query = createPQExpBuffer();
* Now get info about column defaults. This is skipped for a data-only
* dump, as it is only needed for table schemas.
*/
- if (!dopt->dataOnly && tbloids->len > 1)
+ if (dopt->dumpSchema && tbloids->len > 1)
{
AttrDefInfo *attrdefs;
int numDefaults;
* Get info about table CHECK constraints. This is skipped for a
* data-only dump, as it is only needed for table schemas.
*/
- if (!dopt->dataOnly && checkoids->len > 2)
+ if (dopt->dumpSchema && checkoids->len > 2)
{
ConstraintInfo *constrs;
int numConstrs;
/* Comments are schema not data ... except LO comments are data */
if (strcmp(type, "LARGE OBJECT") != 0)
{
- if (dopt->dataOnly)
+ if (!dopt->dumpSchema)
return;
}
else
{
/* We do dump LO comments in binary-upgrade mode */
- if (dopt->schemaOnly && !dopt->binary_upgrade)
+ if (!dopt->dumpData && !dopt->binary_upgrade)
return;
}
return;
/* Comments are SCHEMA not data */
- if (dopt->dataOnly)
+ if (!dopt->dumpSchema)
return;
/* Search for comments associated with relation, using table */
PQExpBuffer delq;
char *qnspname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
PQExpBuffer delq;
char *qextname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
{
DumpOptions *dopt = fout->dopt;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/* Dump out in proper style */
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
FuncInfo *inlineInfo = NULL;
FuncInfo *validatorInfo = NULL;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/*
int nconfigitems = 0;
const char *keyword;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
const char *sourceType;
const char *targetType;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/* Cannot dump if we don't have the cast function's info */
char *lanname;
const char *transformType;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/* Cannot dump if we don't have the transform functions' info */
char *oprregproc;
char *oprref;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/*
PQExpBuffer delq;
char *qamname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
bool needComma;
int i;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
bool needComma;
int i;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
const char *colllocale;
const char *collicurules;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
const char *conproc;
bool condefault;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
const char *proparallel;
char defaultfinalmodify;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
PQExpBuffer delq;
char *qprsname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
char *nspname;
char *tmplname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
PQExpBuffer delq;
char *qtmplname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
int i_tokenname;
int i_dictname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
PQExpBuffer delq;
char *qfdwname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
char *qsrvname;
char *fdwname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
PQExpBuffer tag;
const char *type;
- /* Do nothing in data-only dump, or if we're skipping ACLs */
- if (dopt->dataOnly || dopt->aclsSkip)
+ /* Do nothing if not dumping schema, or if we're skipping ACLs */
+ if (!dopt->dumpSchema || dopt->aclsSkip)
return;
q = createPQExpBuffer();
return InvalidDumpId;
/* --data-only skips ACLs *except* large object ACLs */
- if (dopt->dataOnly && strcmp(type, "LARGE OBJECT") != 0)
+ if (!dopt->dumpSchema && strcmp(type, "LARGE OBJECT") != 0)
return InvalidDumpId;
sql = createPQExpBuffer();
*/
if (strcmp(type, "LARGE OBJECT") != 0)
{
- if (dopt->dataOnly)
+ if (!dopt->dumpSchema)
return;
}
else
{
/* We do dump large object security labels in binary-upgrade mode */
- if (dopt->schemaOnly && !dopt->binary_upgrade)
+ if (!dopt->dumpData && !dopt->binary_upgrade)
return;
}
return;
/* SecLabel are SCHEMA not data */
- if (dopt->dataOnly)
+ if (!dopt->dumpSchema)
return;
/* Search for comments associated with relation, using table */
DumpId tableAclDumpId = InvalidDumpId;
char *namecopy;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
PGresult *res;
char *partbound;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
char *tag;
char *foreign;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
char *qindxname;
char *qqindxname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
static void
dumpIndexAttach(Archive *fout, const IndexAttachInfo *attachinfo)
{
- /* Do nothing in data-only dump */
- if (fout->dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!fout->dopt->dumpSchema)
return;
if (attachinfo->partitionIdx->dobj.dump & DUMP_COMPONENT_DEFINITION)
PGresult *res;
char *stxdef;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
char *tag = NULL;
char *foreign;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
q = createPQExpBuffer();
if (fout->remoteVersion < 100000)
return;
else if (fout->remoteVersion < 180000 ||
- (fout->dopt->schemaOnly && !fout->dopt->sequence_data))
+ (!fout->dopt->dumpData && !fout->dopt->sequence_data))
query = "SELECT seqrelid, format_type(seqtypid, NULL), "
"seqstart, seqincrement, "
"seqmax, seqmin, "
char *qtabname;
char *tag;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
PQExpBuffer delqry;
char *qevtname;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
query = createPQExpBuffer();
PGresult *res;
char *tag;
- /* Do nothing in data-only dump */
- if (dopt->dataOnly)
+ /* Do nothing if not dumping schema */
+ if (!dopt->dumpSchema)
return;
/*
* objects for them, ensuring their data will be dumped even though the
* tables themselves won't be.
*
- * Note that we create TableDataInfo objects even in schemaOnly mode, ie,
+ * Note that we create TableDataInfo objects even in schema-only mode, ie,
* user data in a configuration table is treated like schema data. This
* seems appropriate since system data in a config table would get
* reloaded by CREATE EXTENSION. If the extension is not listed in the