Commit a9f0e8e5 authored by Stephen Frost's avatar Stephen Frost

In pg_dump, use a bitmap to represent what to include

pg_dump has historically used a simple boolean 'dump' value to indicate
if a given object should be included in the dump or not.  Instead, use
a bitmap which breaks down the components of an object into their
distinct pieces and use that bitmap to only include the components
requested.

This does not include any behavioral change, but is in preperation for
the change to dump out just ACLs for objects in pg_catalog.

Reviews by Alexander Korotkov, Jose Luis Tallon
parent 6c268df1
...@@ -443,7 +443,7 @@ AssignDumpId(DumpableObject *dobj) ...@@ -443,7 +443,7 @@ AssignDumpId(DumpableObject *dobj)
dobj->dumpId = ++lastDumpId; dobj->dumpId = ++lastDumpId;
dobj->name = NULL; /* must be set later */ dobj->name = NULL; /* must be set later */
dobj->namespace = NULL; /* may be set later */ dobj->namespace = NULL; /* may be set later */
dobj->dump = true; /* default assumption */ dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
dobj->ext_member = false; /* default assumption */ dobj->ext_member = false; /* default assumption */
dobj->dependencies = NULL; dobj->dependencies = NULL;
dobj->nDeps = 0; dobj->nDeps = 0;
......
...@@ -1287,7 +1287,7 @@ checkExtensionMembership(DumpableObject *dobj, DumpOptions *dopt) ...@@ -1287,7 +1287,7 @@ checkExtensionMembership(DumpableObject *dobj, DumpOptions *dopt)
* extension contents with something different. * extension contents with something different.
*/ */
if (!dopt->binary_upgrade) if (!dopt->binary_upgrade)
dobj->dump = false; dobj->dump = DUMP_COMPONENT_NONE;
else else
dobj->dump = ext->dobj.dump; dobj->dump = ext->dobj.dump;
...@@ -1309,16 +1309,18 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt) ...@@ -1309,16 +1309,18 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt)
* namespaces. If specific namespaces are being dumped, dump just those * namespaces. If specific namespaces are being dumped, dump just those
* namespaces. Otherwise, dump all non-system namespaces. * namespaces. Otherwise, dump all non-system namespaces.
*/ */
if (table_include_oids.head != NULL) if (table_include_oids.head != NULL)
nsinfo->dobj.dump = false; nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
else if (schema_include_oids.head != NULL) else if (schema_include_oids.head != NULL)
nsinfo->dobj.dump = simple_oid_list_member(&schema_include_oids, nsinfo->dobj.dump = simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid); nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 || else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 ||
strcmp(nsinfo->dobj.name, "information_schema") == 0) strcmp(nsinfo->dobj.name, "information_schema") == 0)
nsinfo->dobj.dump = false; nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
else else
nsinfo->dobj.dump = true; nsinfo->dobj.dump = DUMP_COMPONENT_ALL;
/* /*
* In any case, a namespace can be excluded by an exclusion switch * In any case, a namespace can be excluded by an exclusion switch
...@@ -1326,7 +1328,7 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt) ...@@ -1326,7 +1328,7 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt)
if (nsinfo->dobj.dump && if (nsinfo->dobj.dump &&
simple_oid_list_member(&schema_exclude_oids, simple_oid_list_member(&schema_exclude_oids,
nsinfo->dobj.catId.oid)) nsinfo->dobj.catId.oid))
nsinfo->dobj.dump = false; nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1345,7 +1347,8 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt) ...@@ -1345,7 +1347,8 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt)
*/ */
if (table_include_oids.head != NULL) if (table_include_oids.head != NULL)
tbinfo->dobj.dump = simple_oid_list_member(&table_include_oids, tbinfo->dobj.dump = simple_oid_list_member(&table_include_oids,
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
else else
tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump; tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump;
...@@ -1355,7 +1358,7 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt) ...@@ -1355,7 +1358,7 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt)
if (tbinfo->dobj.dump && if (tbinfo->dobj.dump &&
simple_oid_list_member(&table_exclude_oids, simple_oid_list_member(&table_exclude_oids,
tbinfo->dobj.catId.oid)) tbinfo->dobj.catId.oid))
tbinfo->dobj.dump = false; tbinfo->dobj.dump = DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1384,7 +1387,7 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt) ...@@ -1384,7 +1387,7 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt)
if (tytable != NULL) if (tytable != NULL)
tyinfo->dobj.dump = tytable->dobj.dump; tyinfo->dobj.dump = tytable->dobj.dump;
else else
tyinfo->dobj.dump = false; tyinfo->dobj.dump = DUMP_COMPONENT_NONE;
return; return;
} }
...@@ -1404,11 +1407,7 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt) ...@@ -1404,11 +1407,7 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt)
if (checkExtensionMembership(&tyinfo->dobj, dopt)) if (checkExtensionMembership(&tyinfo->dobj, dopt))
return; /* extension membership overrides all else */ return; /* extension membership overrides all else */
/* dump only types in dumpable namespaces */ tyinfo->dobj.dump = tyinfo->dobj.namespace->dobj.dump;
if (!tyinfo->dobj.namespace->dobj.dump)
tyinfo->dobj.dump = false;
else
tyinfo->dobj.dump = true;
} }
/* /*
...@@ -1427,7 +1426,8 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt) ...@@ -1427,7 +1426,8 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
if (dinfo->dobj.namespace) if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump; dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else else
dinfo->dobj.dump = dopt->include_everything; dinfo->dobj.dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1446,9 +1446,10 @@ selectDumpableCast(CastInfo *cast, DumpOptions *dopt) ...@@ -1446,9 +1446,10 @@ selectDumpableCast(CastInfo *cast, DumpOptions *dopt)
return; /* extension membership overrides all else */ return; /* extension membership overrides all else */
if (cast->dobj.catId.oid < (Oid) FirstNormalObjectId) if (cast->dobj.catId.oid < (Oid) FirstNormalObjectId)
cast->dobj.dump = false; cast->dobj.dump = DUMP_COMPONENT_NONE;
else else
cast->dobj.dump = dopt->include_everything; cast->dobj.dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1466,9 +1467,10 @@ selectDumpableProcLang(ProcLangInfo *plang, DumpOptions *dopt) ...@@ -1466,9 +1467,10 @@ selectDumpableProcLang(ProcLangInfo *plang, DumpOptions *dopt)
return; /* extension membership overrides all else */ return; /* extension membership overrides all else */
if (plang->dobj.catId.oid < (Oid) FirstNormalObjectId) if (plang->dobj.catId.oid < (Oid) FirstNormalObjectId)
plang->dobj.dump = false; plang->dobj.dump = DUMP_COMPONENT_NONE;
else else
plang->dobj.dump = dopt->include_everything; plang->dobj.dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1505,9 +1507,10 @@ static void ...@@ -1505,9 +1507,10 @@ static void
selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt) selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
{ {
if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false; extinfo->dobj.dump = DUMP_COMPONENT_NONE;
else else
extinfo->dobj.dump = dopt->include_everything; extinfo->dobj.dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1529,7 +1532,8 @@ selectDumpableObject(DumpableObject *dobj, DumpOptions *dopt) ...@@ -1529,7 +1532,8 @@ selectDumpableObject(DumpableObject *dobj, DumpOptions *dopt)
if (dobj->namespace) if (dobj->namespace)
dobj->dump = dobj->namespace->dobj.dump; dobj->dump = dobj->namespace->dobj.dump;
else else
dobj->dump = dopt->include_everything; dobj->dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1934,13 +1938,14 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo) ...@@ -1934,13 +1938,14 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
* dependency on its table as "special" and pass it to ArchiveEntry now. * dependency on its table as "special" and pass it to ArchiveEntry now.
* See comments for BuildArchiveDependencies. * See comments for BuildArchiveDependencies.
*/ */
ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId, if (tdinfo->dobj.dump & DUMP_COMPONENT_DATA)
tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name, ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
NULL, tbinfo->rolname, tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name,
false, "TABLE DATA", SECTION_DATA, NULL, tbinfo->rolname,
"", "", copyStmt, false, "TABLE DATA", SECTION_DATA,
&(tbinfo->dobj.dumpId), 1, "", "", copyStmt,
dumpFn, tdinfo); &(tbinfo->dobj.dumpId), 1,
dumpFn, tdinfo);
destroyPQExpBuffer(copyBuf); destroyPQExpBuffer(copyBuf);
destroyPQExpBuffer(clistBuf); destroyPQExpBuffer(clistBuf);
...@@ -1968,23 +1973,24 @@ refreshMatViewData(Archive *fout, TableDataInfo *tdinfo) ...@@ -1968,23 +1973,24 @@ refreshMatViewData(Archive *fout, TableDataInfo *tdinfo)
appendPQExpBuffer(q, "REFRESH MATERIALIZED VIEW %s;\n", appendPQExpBuffer(q, "REFRESH MATERIALIZED VIEW %s;\n",
fmtId(tbinfo->dobj.name)); fmtId(tbinfo->dobj.name));
ArchiveEntry(fout, if (tdinfo->dobj.dump & DUMP_COMPONENT_DATA)
tdinfo->dobj.catId, /* catalog ID */ ArchiveEntry(fout,
tdinfo->dobj.dumpId, /* dump ID */ tdinfo->dobj.catId, /* catalog ID */
tbinfo->dobj.name, /* Name */ tdinfo->dobj.dumpId, /* dump ID */
tbinfo->dobj.namespace->dobj.name, /* Namespace */ tbinfo->dobj.name, /* Name */
NULL, /* Tablespace */ tbinfo->dobj.namespace->dobj.name, /* Namespace */
tbinfo->rolname, /* Owner */ NULL, /* Tablespace */
false, /* with oids */ tbinfo->rolname, /* Owner */
"MATERIALIZED VIEW DATA", /* Desc */ false, /* with oids */
SECTION_POST_DATA, /* Section */ "MATERIALIZED VIEW DATA", /* Desc */
q->data, /* Create */ SECTION_POST_DATA, /* Section */
"", /* Del */ q->data, /* Create */
NULL, /* Copy */ "", /* Del */
tdinfo->dobj.dependencies, /* Deps */ NULL, /* Copy */
tdinfo->dobj.nDeps, /* # Deps */ tdinfo->dobj.dependencies, /* Deps */
NULL, /* Dumper */ tdinfo->dobj.nDeps, /* # Deps */
NULL); /* Dumper Arg */ NULL, /* Dumper */
NULL); /* Dumper Arg */
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
} }
...@@ -2000,7 +2006,7 @@ getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids) ...@@ -2000,7 +2006,7 @@ getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids)
for (i = 0; i < numTables; i++) for (i = 0; i < numTables; i++)
{ {
if (tblinfo[i].dobj.dump) if (tblinfo[i].dobj.dump & DUMP_COMPONENT_DATA)
makeTableDataInfo(dopt, &(tblinfo[i]), oids); makeTableDataInfo(dopt, &(tblinfo[i]), oids);
} }
} }
...@@ -2261,7 +2267,7 @@ guessConstraintInheritance(TableInfo *tblinfo, int numTables) ...@@ -2261,7 +2267,7 @@ guessConstraintInheritance(TableInfo *tblinfo, int numTables)
continue; continue;
/* Don't bother computing anything for non-target tables, either */ /* Don't bother computing anything for non-target tables, either */
if (!tbinfo->dobj.dump) if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue; continue;
numParents = tbinfo->numParents; numParents = tbinfo->numParents;
...@@ -2811,31 +2817,34 @@ dumpBlob(Archive *fout, BlobInfo *binfo) ...@@ -2811,31 +2817,34 @@ dumpBlob(Archive *fout, BlobInfo *binfo)
"SELECT pg_catalog.lo_unlink('%s');\n", "SELECT pg_catalog.lo_unlink('%s');\n",
binfo->dobj.name); binfo->dobj.name);
ArchiveEntry(fout, binfo->dobj.catId, binfo->dobj.dumpId, if (binfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
binfo->dobj.name, ArchiveEntry(fout, binfo->dobj.catId, binfo->dobj.dumpId,
NULL, NULL, binfo->dobj.name,
binfo->rolname, false, NULL, NULL,
"BLOB", SECTION_PRE_DATA, binfo->rolname, false,
cquery->data, dquery->data, NULL, "BLOB", SECTION_PRE_DATA,
NULL, 0, cquery->data, dquery->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* set up tag for comment and/or ACL */ /* set up tag for comment and/or ACL */
resetPQExpBuffer(cquery); resetPQExpBuffer(cquery);
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name); appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */ /* Dump comment if any */
dumpComment(fout, cquery->data, if (binfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, binfo->rolname, dumpComment(fout, cquery->data,
binfo->dobj.catId, 0, binfo->dobj.dumpId); NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */ /* Dump security label if any */
dumpSecLabel(fout, cquery->data, if (binfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
NULL, binfo->rolname, dumpSecLabel(fout, cquery->data,
binfo->dobj.catId, 0, binfo->dobj.dumpId); NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */ /* Dump ACL if any */
if (binfo->blobacl) if (binfo->blobacl && (binfo->dobj.dump & DUMP_COMPONENT_ACL))
dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT", dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data, binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl); NULL, binfo->rolname, binfo->blobacl);
...@@ -2956,7 +2965,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables) ...@@ -2956,7 +2965,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
TableInfo *tbinfo = &tblinfo[i]; TableInfo *tbinfo = &tblinfo[i];
/* Ignore row security on tables not to be dumped */ /* Ignore row security on tables not to be dumped */
if (!tbinfo->dobj.dump) if (!(tbinfo->dobj.dump & DUMP_COMPONENT_POLICY))
continue; continue;
if (g_verbose) if (g_verbose)
...@@ -3097,15 +3106,16 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo) ...@@ -3097,15 +3106,16 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
appendPQExpBuffer(query, "ALTER TABLE %s ENABLE ROW LEVEL SECURITY;", appendPQExpBuffer(query, "ALTER TABLE %s ENABLE ROW LEVEL SECURITY;",
fmtId(polinfo->dobj.name)); fmtId(polinfo->dobj.name));
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId, if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
polinfo->dobj.name, ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
polinfo->dobj.namespace->dobj.name, polinfo->dobj.name,
NULL, polinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, NULL,
"ROW SECURITY", SECTION_POST_DATA, tbinfo->rolname, false,
query->data, "", NULL, "ROW SECURITY", SECTION_POST_DATA,
NULL, 0, query->data, "", NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
return; return;
...@@ -3150,15 +3160,16 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo) ...@@ -3150,15 +3160,16 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
tag = psprintf("%s %s", tbinfo->dobj.name, polinfo->dobj.name); tag = psprintf("%s %s", tbinfo->dobj.name, polinfo->dobj.name);
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId, if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
tag, ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
polinfo->dobj.namespace->dobj.name, tag,
NULL, polinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, NULL,
"POLICY", SECTION_POST_DATA, tbinfo->rolname, false,
query->data, delqry->data, NULL, "POLICY", SECTION_POST_DATA,
NULL, 0, query->data, delqry->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
free(tag); free(tag);
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
...@@ -3764,7 +3775,8 @@ getTypes(Archive *fout, int *numTypes) ...@@ -3764,7 +3775,8 @@ getTypes(Archive *fout, int *numTypes)
*/ */
tyinfo[i].nDomChecks = 0; tyinfo[i].nDomChecks = 0;
tyinfo[i].domChecks = NULL; tyinfo[i].domChecks = NULL;
if (tyinfo[i].dobj.dump && tyinfo[i].typtype == TYPTYPE_DOMAIN) if ((tyinfo[i].dobj.dump & DUMP_COMPONENT_DEFINITION) &&
tyinfo[i].typtype == TYPTYPE_DOMAIN)
getDomainConstraints(fout, &(tyinfo[i])); getDomainConstraints(fout, &(tyinfo[i]));
/* /*
...@@ -3777,8 +3789,9 @@ getTypes(Archive *fout, int *numTypes) ...@@ -3777,8 +3789,9 @@ getTypes(Archive *fout, int *numTypes)
* should copy the base type's catId, but then it might capture the * should copy the base type's catId, but then it might capture the
* pg_depend entries for the type, which we don't want. * pg_depend entries for the type, which we don't want.
*/ */
if (tyinfo[i].dobj.dump && (tyinfo[i].typtype == TYPTYPE_BASE || if ((tyinfo[i].dobj.dump & DUMP_COMPONENT_DEFINITION) &&
tyinfo[i].typtype == TYPTYPE_RANGE)) (tyinfo[i].typtype == TYPTYPE_BASE ||
tyinfo[i].typtype == TYPTYPE_RANGE))
{ {
stinfo = (ShellTypeInfo *) pg_malloc(sizeof(ShellTypeInfo)); stinfo = (ShellTypeInfo *) pg_malloc(sizeof(ShellTypeInfo));
stinfo->dobj.objType = DO_SHELL_TYPE; stinfo->dobj.objType = DO_SHELL_TYPE;
...@@ -3794,7 +3807,7 @@ getTypes(Archive *fout, int *numTypes) ...@@ -3794,7 +3807,7 @@ getTypes(Archive *fout, int *numTypes)
* dump it if the I/O or canonicalize functions need to be dumped; * dump it if the I/O or canonicalize functions need to be dumped;
* this is taken care of while sorting dependencies. * this is taken care of while sorting dependencies.
*/ */
stinfo->dobj.dump = false; stinfo->dobj.dump = DUMP_COMPONENT_NONE;
/* /*
* However, if dumping from pre-7.3, there will be no dependency * However, if dumping from pre-7.3, there will be no dependency
...@@ -3812,7 +3825,7 @@ getTypes(Archive *fout, int *numTypes) ...@@ -3812,7 +3825,7 @@ getTypes(Archive *fout, int *numTypes)
typoutput = atooid(PQgetvalue(res, i, i_typoutput)); typoutput = atooid(PQgetvalue(res, i, i_typoutput));
funcInfo = findFuncByOid(typinput); funcInfo = findFuncByOid(typinput);
if (funcInfo && funcInfo->dobj.dump) if (funcInfo && funcInfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
{ {
/* base type depends on function */ /* base type depends on function */
addObjectDependency(&tyinfo[i].dobj, addObjectDependency(&tyinfo[i].dobj,
...@@ -3821,11 +3834,11 @@ getTypes(Archive *fout, int *numTypes) ...@@ -3821,11 +3834,11 @@ getTypes(Archive *fout, int *numTypes)
addObjectDependency(&funcInfo->dobj, addObjectDependency(&funcInfo->dobj,
stinfo->dobj.dumpId); stinfo->dobj.dumpId);
/* mark shell type as to be dumped */ /* mark shell type as to be dumped */
stinfo->dobj.dump = true; stinfo->dobj.dump = DUMP_COMPONENT_ALL;
} }
funcInfo = findFuncByOid(typoutput); funcInfo = findFuncByOid(typoutput);
if (funcInfo && funcInfo->dobj.dump) if (funcInfo && funcInfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
{ {
/* base type depends on function */ /* base type depends on function */
addObjectDependency(&tyinfo[i].dobj, addObjectDependency(&tyinfo[i].dobj,
...@@ -3834,7 +3847,7 @@ getTypes(Archive *fout, int *numTypes) ...@@ -3834,7 +3847,7 @@ getTypes(Archive *fout, int *numTypes)
addObjectDependency(&funcInfo->dobj, addObjectDependency(&funcInfo->dobj,
stinfo->dobj.dumpId); stinfo->dobj.dumpId);
/* mark shell type as to be dumped */ /* mark shell type as to be dumped */
stinfo->dobj.dump = true; stinfo->dobj.dump = DUMP_COMPONENT_ALL;
} }
} }
} }
...@@ -5357,10 +5370,11 @@ getTables(Archive *fout, int *numTables) ...@@ -5357,10 +5370,11 @@ getTables(Archive *fout, int *numTables)
* Decide whether we want to dump this table. * Decide whether we want to dump this table.
*/ */
if (tblinfo[i].relkind == RELKIND_COMPOSITE_TYPE) if (tblinfo[i].relkind == RELKIND_COMPOSITE_TYPE)
tblinfo[i].dobj.dump = false; tblinfo[i].dobj.dump = DUMP_COMPONENT_NONE;
else else
selectDumpableTable(&tblinfo[i], dopt); selectDumpableTable(&tblinfo[i], dopt);
tblinfo[i].interesting = tblinfo[i].dobj.dump;
tblinfo[i].interesting = tblinfo[i].dobj.dump ? true : false;
tblinfo[i].postponed_def = false; /* might get set during sort */ tblinfo[i].postponed_def = false; /* might get set during sort */
...@@ -5427,13 +5441,13 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables) ...@@ -5427,13 +5441,13 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
if (!OidIsValid(seqinfo->owning_tab)) if (!OidIsValid(seqinfo->owning_tab))
continue; /* not an owned sequence */ continue; /* not an owned sequence */
if (seqinfo->dobj.dump) if (seqinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
continue; /* no need to search */ continue; /* no need to search */
owning_tab = findTableByOid(seqinfo->owning_tab); owning_tab = findTableByOid(seqinfo->owning_tab);
if (owning_tab && owning_tab->dobj.dump) if (owning_tab && owning_tab->dobj.dump)
{ {
seqinfo->interesting = true; seqinfo->interesting = true;
seqinfo->dobj.dump = true; seqinfo->dobj.dump = DUMP_COMPONENT_ALL;
} }
} }
} }
...@@ -5535,8 +5549,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables) ...@@ -5535,8 +5549,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
if (!tbinfo->hasindex) if (!tbinfo->hasindex)
continue; continue;
/* Ignore indexes of tables not to be dumped */ /* Ignore indexes of tables whose definitions are not to be dumped */
if (!tbinfo->dobj.dump) if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue; continue;
if (g_verbose) if (g_verbose)
...@@ -5903,7 +5917,8 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables) ...@@ -5903,7 +5917,8 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
{ {
TableInfo *tbinfo = &tblinfo[i]; TableInfo *tbinfo = &tblinfo[i];
if (!tbinfo->hastriggers || !tbinfo->dobj.dump) if (!tbinfo->hastriggers ||
!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue; continue;
if (g_verbose) if (g_verbose)
...@@ -6242,7 +6257,8 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables) ...@@ -6242,7 +6257,8 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
{ {
TableInfo *tbinfo = &tblinfo[i]; TableInfo *tbinfo = &tblinfo[i];
if (!tbinfo->hastriggers || !tbinfo->dobj.dump) if (!tbinfo->hastriggers ||
!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue; continue;
if (g_verbose) if (g_verbose)
...@@ -8595,12 +8611,13 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) ...@@ -8595,12 +8611,13 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
dumpBlob(fout, (BlobInfo *) dobj); dumpBlob(fout, (BlobInfo *) dobj);
break; break;
case DO_BLOB_DATA: case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId, if (dobj->dump & DUMP_COMPONENT_DATA)
dobj->name, NULL, NULL, "", ArchiveEntry(fout, dobj->catId, dobj->dumpId,
false, "BLOBS", SECTION_DATA, dobj->name, NULL, NULL, "",
"", "", NULL, false, "BLOBS", SECTION_DATA,
NULL, 0, "", "", NULL,
dumpBlobs, NULL); NULL, 0,
dumpBlobs, NULL);
break; break;
case DO_POLICY: case DO_POLICY:
dumpPolicy(fout, (PolicyInfo *) dobj); dumpPolicy(fout, (PolicyInfo *) dobj);
...@@ -8648,26 +8665,31 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) ...@@ -8648,26 +8665,31 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data);
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, if (nspinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
nspinfo->dobj.name, ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
NULL, NULL, nspinfo->dobj.name,
nspinfo->rolname, NULL, NULL,
false, "SCHEMA", SECTION_PRE_DATA, nspinfo->rolname,
q->data, delq->data, NULL, false, "SCHEMA", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Schema Comments and Security Labels */ /* Dump Schema Comments and Security Labels */
dumpComment(fout, labelq->data, if (nspinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, nspinfo->rolname, dumpComment(fout, labelq->data,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); NULL, nspinfo->rolname,
dumpSecLabel(fout, labelq->data, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA", if (nspinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
qnspname, NULL, nspinfo->dobj.name, NULL, dumpSecLabel(fout, labelq->data,
nspinfo->rolname, nspinfo->nspacl); NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
if (nspinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
free(qnspname); free(qnspname);
...@@ -8777,22 +8799,26 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo) ...@@ -8777,22 +8799,26 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
appendPQExpBuffer(labelq, "EXTENSION %s", qextname); appendPQExpBuffer(labelq, "EXTENSION %s", qextname);
ArchiveEntry(fout, extinfo->dobj.catId, extinfo->dobj.dumpId, if (extinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
extinfo->dobj.name, ArchiveEntry(fout, extinfo->dobj.catId, extinfo->dobj.dumpId,
NULL, NULL, extinfo->dobj.name,
"", NULL, NULL,
false, "EXTENSION", SECTION_PRE_DATA, "",
q->data, delq->data, NULL, false, "EXTENSION", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Extension Comments and Security Labels */ /* Dump Extension Comments and Security Labels */
dumpComment(fout, labelq->data, if (extinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, "", dumpComment(fout, labelq->data,
extinfo->dobj.catId, 0, extinfo->dobj.dumpId); NULL, "",
dumpSecLabel(fout, labelq->data, extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId); if (extinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
free(qextname); free(qextname);
...@@ -8932,28 +8958,33 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo) ...@@ -8932,28 +8958,33 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tyinfo->dobj.name, ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.name,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"TYPE", SECTION_PRE_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "TYPE", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Type Comments and Security Labels */ /* Dump Type Comments and Security Labels */
dumpComment(fout, labelq->data, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, dumpComment(fout, labelq->data,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
dumpSecLabel(fout, labelq->data, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
qtypname, NULL, tyinfo->dobj.name, dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->rolname, tyinfo->typacl); tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
PQclear(res); PQclear(res);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -9065,28 +9096,33 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo) ...@@ -9065,28 +9096,33 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tyinfo->dobj.name, ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.name,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"TYPE", SECTION_PRE_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "TYPE", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Type Comments and Security Labels */ /* Dump Type Comments and Security Labels */
dumpComment(fout, labelq->data, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, dumpComment(fout, labelq->data,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
dumpSecLabel(fout, labelq->data, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
qtypname, NULL, tyinfo->dobj.name, dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
tyinfo->dobj.namespace->dobj.name, qtypname, NULL, tyinfo->dobj.name,
tyinfo->rolname, tyinfo->typacl); tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
PQclear(res); PQclear(res);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -9135,28 +9171,33 @@ dumpUndefinedType(Archive *fout, TypeInfo *tyinfo) ...@@ -9135,28 +9171,33 @@ dumpUndefinedType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tyinfo->dobj.name, ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.name,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"TYPE", SECTION_PRE_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "TYPE", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Type Comments and Security Labels */ /* Dump Type Comments and Security Labels */
dumpComment(fout, labelq->data, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, dumpComment(fout, labelq->data,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
dumpSecLabel(fout, labelq->data, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
qtypname, NULL, tyinfo->dobj.name, dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
tyinfo->dobj.namespace->dobj.name, qtypname, NULL, tyinfo->dobj.name,
tyinfo->rolname, tyinfo->typacl); tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
destroyPQExpBuffer(delq); destroyPQExpBuffer(delq);
...@@ -9524,28 +9565,33 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -9524,28 +9565,33 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tyinfo->dobj.name, ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.name,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"TYPE", SECTION_PRE_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "TYPE", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Type Comments and Security Labels */ /* Dump Type Comments and Security Labels */
dumpComment(fout, labelq->data, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, dumpComment(fout, labelq->data,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
dumpSecLabel(fout, labelq->data, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
qtypname, NULL, tyinfo->dobj.name, dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->rolname, tyinfo->typacl); tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
PQclear(res); PQclear(res);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -9687,28 +9733,33 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo) ...@@ -9687,28 +9733,33 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tyinfo->dobj.name, ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.name,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"DOMAIN", SECTION_PRE_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "DOMAIN", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Domain Comments and Security Labels */ /* Dump Domain Comments and Security Labels */
dumpComment(fout, labelq->data, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, dumpComment(fout, labelq->data,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
dumpSecLabel(fout, labelq->data, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
qtypname, NULL, tyinfo->dobj.name, dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->rolname, tyinfo->typacl); tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
/* Dump any per-constraint comments */ /* Dump any per-constraint comments */
for (i = 0; i < tyinfo->nDomChecks; i++) for (i = 0; i < tyinfo->nDomChecks; i++)
...@@ -9720,10 +9771,13 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo) ...@@ -9720,10 +9771,13 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo)
fmtId(domcheck->dobj.name)); fmtId(domcheck->dobj.name));
appendPQExpBuffer(labelq, "ON DOMAIN %s", appendPQExpBuffer(labelq, "ON DOMAIN %s",
qtypname); qtypname);
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->rolname, dumpComment(fout, labelq->data,
domcheck->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname,
domcheck->dobj.catId, 0, tyinfo->dobj.dumpId);
destroyPQExpBuffer(labelq); destroyPQExpBuffer(labelq);
} }
...@@ -9913,29 +9967,34 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) ...@@ -9913,29 +9967,34 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tyinfo->dobj.name, ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tyinfo->dobj.name,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"TYPE", SECTION_PRE_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "TYPE", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Type Comments and Security Labels */ /* Dump Type Comments and Security Labels */
dumpComment(fout, labelq->data, if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, dumpComment(fout, labelq->data,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
dumpSecLabel(fout, labelq->data, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
qtypname, NULL, tyinfo->dobj.name, dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
tyinfo->dobj.namespace->dobj.name, qtypname, NULL, tyinfo->dobj.name,
tyinfo->rolname, tyinfo->typacl); tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
PQclear(res); PQclear(res);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -9945,7 +10004,8 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) ...@@ -9945,7 +10004,8 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
/* Dump any per-column comments */ /* Dump any per-column comments */
dumpCompositeTypeColComments(fout, tyinfo); if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpCompositeTypeColComments(fout, tyinfo);
} }
/* /*
...@@ -10090,15 +10150,16 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo) ...@@ -10090,15 +10150,16 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
appendPQExpBuffer(q, "CREATE TYPE %s;\n", appendPQExpBuffer(q, "CREATE TYPE %s;\n",
fmtId(stinfo->dobj.name)); fmtId(stinfo->dobj.name));
ArchiveEntry(fout, stinfo->dobj.catId, stinfo->dobj.dumpId, if (stinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
stinfo->dobj.name, ArchiveEntry(fout, stinfo->dobj.catId, stinfo->dobj.dumpId,
stinfo->dobj.namespace->dobj.name, stinfo->dobj.name,
NULL, stinfo->dobj.namespace->dobj.name,
stinfo->baseType->rolname, false, NULL,
"SHELL TYPE", SECTION_PRE_DATA, stinfo->baseType->rolname, false,
q->data, "", NULL, "SHELL TYPE", SECTION_PRE_DATA,
NULL, 0, q->data, "", NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
} }
...@@ -10227,23 +10288,27 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) ...@@ -10227,23 +10288,27 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data); binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data);
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId, if (plang->dobj.dump & DUMP_COMPONENT_DEFINITION)
plang->dobj.name, ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
lanschema, NULL, plang->lanowner, plang->dobj.name,
false, "PROCEDURAL LANGUAGE", SECTION_PRE_DATA, lanschema, NULL, plang->lanowner,
defqry->data, delqry->data, NULL, false, "PROCEDURAL LANGUAGE", SECTION_PRE_DATA,
NULL, 0, defqry->data, delqry->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */ /* Dump Proc Lang Comments and Security Labels */
dumpComment(fout, labelq->data, if (plang->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, "", dumpComment(fout, labelq->data,
plang->dobj.catId, 0, plang->dobj.dumpId); NULL, "",
dumpSecLabel(fout, labelq->data, plang->dobj.catId, 0, plang->dobj.dumpId);
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId); if (plang->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted) if (plang->lanpltrusted && plang->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name, qlanname, NULL, plang->dobj.name,
lanschema, lanschema,
...@@ -10892,28 +10957,33 @@ dumpFunc(Archive *fout, FuncInfo *finfo) ...@@ -10892,28 +10957,33 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &finfo->dobj, labelq->data); binary_upgrade_extension_member(q, &finfo->dobj, labelq->data);
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId, if (finfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
funcsig_tag, ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
finfo->dobj.namespace->dobj.name, funcsig_tag,
NULL, finfo->dobj.namespace->dobj.name,
finfo->rolname, false, NULL,
"FUNCTION", SECTION_PRE_DATA, finfo->rolname, false,
q->data, delqry->data, NULL, "FUNCTION", SECTION_PRE_DATA,
NULL, 0, q->data, delqry->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Function Comments and Security Labels */ /* Dump Function Comments and Security Labels */
dumpComment(fout, labelq->data, if (finfo->dobj.dump & DUMP_COMPONENT_COMMENT)
finfo->dobj.namespace->dobj.name, finfo->rolname, dumpComment(fout, labelq->data,
finfo->dobj.catId, 0, finfo->dobj.dumpId); finfo->dobj.namespace->dobj.name, finfo->rolname,
dumpSecLabel(fout, labelq->data, finfo->dobj.catId, 0, finfo->dobj.dumpId);
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId); if (finfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION", if (finfo->dobj.dump & DUMP_COMPONENT_ACL)
funcsig, NULL, funcsig_tag, dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
finfo->dobj.namespace->dobj.name, funcsig, NULL, funcsig_tag,
finfo->rolname, finfo->proacl); finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
PQclear(res); PQclear(res);
...@@ -11022,18 +11092,20 @@ dumpCast(Archive *fout, CastInfo *cast) ...@@ -11022,18 +11092,20 @@ dumpCast(Archive *fout, CastInfo *cast)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data); binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data);
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId, if (cast->dobj.dump & DUMP_COMPONENT_DEFINITION)
labelq->data, ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
"pg_catalog", NULL, "", labelq->data,
false, "CAST", SECTION_PRE_DATA, "pg_catalog", NULL, "",
defqry->data, delqry->data, NULL, false, "CAST", SECTION_PRE_DATA,
NULL, 0, defqry->data, delqry->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Cast Comments */ /* Dump Cast Comments */
dumpComment(fout, labelq->data, if (cast->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, "", dumpComment(fout, labelq->data,
cast->dobj.catId, 0, cast->dobj.dumpId); NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
free(sourceType); free(sourceType);
free(targetType); free(targetType);
...@@ -11142,18 +11214,20 @@ dumpTransform(Archive *fout, TransformInfo *transform) ...@@ -11142,18 +11214,20 @@ dumpTransform(Archive *fout, TransformInfo *transform)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &transform->dobj, labelq->data); binary_upgrade_extension_member(defqry, &transform->dobj, labelq->data);
ArchiveEntry(fout, transform->dobj.catId, transform->dobj.dumpId, if (transform->dobj.dump & DUMP_COMPONENT_DEFINITION)
labelq->data, ArchiveEntry(fout, transform->dobj.catId, transform->dobj.dumpId,
"pg_catalog", NULL, "", labelq->data,
false, "TRANSFORM", SECTION_PRE_DATA, "pg_catalog", NULL, "",
defqry->data, delqry->data, NULL, false, "TRANSFORM", SECTION_PRE_DATA,
transform->dobj.dependencies, transform->dobj.nDeps, defqry->data, delqry->data, NULL,
NULL, NULL); transform->dobj.dependencies, transform->dobj.nDeps,
NULL, NULL);
/* Dump Transform Comments */ /* Dump Transform Comments */
dumpComment(fout, labelq->data, if (transform->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, "", dumpComment(fout, labelq->data,
transform->dobj.catId, 0, transform->dobj.dumpId); NULL, "",
transform->dobj.catId, 0, transform->dobj.dumpId);
free(lanname); free(lanname);
free(transformType); free(transformType);
...@@ -11396,20 +11470,22 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ...@@ -11396,20 +11470,22 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data);
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId, if (oprinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
oprinfo->dobj.name, ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
oprinfo->dobj.namespace->dobj.name, oprinfo->dobj.name,
NULL, oprinfo->dobj.namespace->dobj.name,
oprinfo->rolname, NULL,
false, "OPERATOR", SECTION_PRE_DATA, oprinfo->rolname,
q->data, delq->data, NULL, false, "OPERATOR", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Operator Comments */ /* Dump Operator Comments */
dumpComment(fout, labelq->data, if (oprinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname, dumpComment(fout, labelq->data,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId); oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -11974,20 +12050,22 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ...@@ -11974,20 +12050,22 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data);
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId, if (opcinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
opcinfo->dobj.name, ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
opcinfo->dobj.namespace->dobj.name, opcinfo->dobj.name,
NULL, opcinfo->dobj.namespace->dobj.name,
opcinfo->rolname, NULL,
false, "OPERATOR CLASS", SECTION_PRE_DATA, opcinfo->rolname,
q->data, delq->data, NULL, false, "OPERATOR CLASS", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Operator Class Comments */ /* Dump Operator Class Comments */
dumpComment(fout, labelq->data, if (opcinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, opcinfo->rolname, dumpComment(fout, labelq->data,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId); NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
free(amname); free(amname);
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
...@@ -12288,20 +12366,22 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) ...@@ -12288,20 +12366,22 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data);
ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId, if (opfinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
opfinfo->dobj.name, ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId,
opfinfo->dobj.namespace->dobj.name, opfinfo->dobj.name,
NULL, opfinfo->dobj.namespace->dobj.name,
opfinfo->rolname, NULL,
false, "OPERATOR FAMILY", SECTION_PRE_DATA, opfinfo->rolname,
q->data, delq->data, NULL, false, "OPERATOR FAMILY", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Operator Family Comments */ /* Dump Operator Family Comments */
dumpComment(fout, labelq->data, if (opfinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, opfinfo->rolname, dumpComment(fout, labelq->data,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId); NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
free(amname); free(amname);
PQclear(res_ops); PQclear(res_ops);
...@@ -12378,20 +12458,22 @@ dumpCollation(Archive *fout, CollInfo *collinfo) ...@@ -12378,20 +12458,22 @@ dumpCollation(Archive *fout, CollInfo *collinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data);
ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId, if (collinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
collinfo->dobj.name, ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId,
collinfo->dobj.namespace->dobj.name, collinfo->dobj.name,
NULL, collinfo->dobj.namespace->dobj.name,
collinfo->rolname, NULL,
false, "COLLATION", SECTION_PRE_DATA, collinfo->rolname,
q->data, delq->data, NULL, false, "COLLATION", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Collation Comments */ /* Dump Collation Comments */
dumpComment(fout, labelq->data, if (collinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
collinfo->dobj.namespace->dobj.name, collinfo->rolname, dumpComment(fout, labelq->data,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId); collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -12478,20 +12560,22 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) ...@@ -12478,20 +12560,22 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data);
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId, if (convinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
convinfo->dobj.name, ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
convinfo->dobj.namespace->dobj.name, convinfo->dobj.name,
NULL, convinfo->dobj.namespace->dobj.name,
convinfo->rolname, NULL,
false, "CONVERSION", SECTION_PRE_DATA, convinfo->rolname,
q->data, delq->data, NULL, false, "CONVERSION", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Conversion Comments */ /* Dump Conversion Comments */
dumpComment(fout, labelq->data, if (convinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
convinfo->dobj.namespace->dobj.name, convinfo->rolname, dumpComment(fout, labelq->data,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId); convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -12941,23 +13025,30 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -12941,23 +13025,30 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data); binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data);
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_DEFINITION)
aggsig_tag, ArchiveEntry(fout, agginfo->aggfn.dobj.catId,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.dobj.dumpId,
NULL, aggsig_tag,
agginfo->aggfn.rolname, agginfo->aggfn.dobj.namespace->dobj.name,
false, "AGGREGATE", SECTION_PRE_DATA, NULL,
q->data, delq->data, NULL, agginfo->aggfn.rolname,
NULL, 0, false, "AGGREGATE", SECTION_PRE_DATA,
NULL, NULL); q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
/* Dump Aggregate Comments */ /* Dump Aggregate Comments */
dumpComment(fout, labelq->data, if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_COMMENT)
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, dumpComment(fout, labelq->data,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); agginfo->aggfn.dobj.namespace->dobj.name,
dumpSecLabel(fout, labelq->data, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name,
agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
/* /*
* Since there is no GRANT ON AGGREGATE syntax, we have to make the ACL * Since there is no GRANT ON AGGREGATE syntax, we have to make the ACL
...@@ -12970,11 +13061,12 @@ dumpAgg(Archive *fout, AggInfo *agginfo) ...@@ -12970,11 +13061,12 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
aggsig = format_function_signature(fout, &agginfo->aggfn, true); aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false); aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_ACL)
"FUNCTION", dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
aggsig, NULL, aggsig_tag, "FUNCTION",
agginfo->aggfn.dobj.namespace->dobj.name, aggsig, NULL, aggsig_tag,
agginfo->aggfn.rolname, agginfo->aggfn.proacl); agginfo->aggfn.dobj.namespace->dobj.name,
agginfo->aggfn.rolname, agginfo->aggfn.proacl);
free(aggsig); free(aggsig);
if (aggfullsig) if (aggfullsig)
...@@ -13042,20 +13134,22 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo) ...@@ -13042,20 +13134,22 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data);
ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId, if (prsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
prsinfo->dobj.name, ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId,
prsinfo->dobj.namespace->dobj.name, prsinfo->dobj.name,
NULL, prsinfo->dobj.namespace->dobj.name,
"", NULL,
false, "TEXT SEARCH PARSER", SECTION_PRE_DATA, "",
q->data, delq->data, NULL, false, "TEXT SEARCH PARSER", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Parser Comments */ /* Dump Parser Comments */
dumpComment(fout, labelq->data, if (prsinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, "", dumpComment(fout, labelq->data,
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId); NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
destroyPQExpBuffer(delq); destroyPQExpBuffer(delq);
...@@ -13130,20 +13224,22 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) ...@@ -13130,20 +13224,22 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data);
ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId, if (dictinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
dictinfo->dobj.name, ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId,
dictinfo->dobj.namespace->dobj.name, dictinfo->dobj.name,
NULL, dictinfo->dobj.namespace->dobj.name,
dictinfo->rolname, NULL,
false, "TEXT SEARCH DICTIONARY", SECTION_PRE_DATA, dictinfo->rolname,
q->data, delq->data, NULL, false, "TEXT SEARCH DICTIONARY", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Dictionary Comments */ /* Dump Dictionary Comments */
dumpComment(fout, labelq->data, if (dictinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, dictinfo->rolname, dumpComment(fout, labelq->data,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId); NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
destroyPQExpBuffer(delq); destroyPQExpBuffer(delq);
...@@ -13197,20 +13293,22 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo) ...@@ -13197,20 +13293,22 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data);
ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId, if (tmplinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tmplinfo->dobj.name, ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId,
tmplinfo->dobj.namespace->dobj.name, tmplinfo->dobj.name,
NULL, tmplinfo->dobj.namespace->dobj.name,
"", NULL,
false, "TEXT SEARCH TEMPLATE", SECTION_PRE_DATA, "",
q->data, delq->data, NULL, false, "TEXT SEARCH TEMPLATE", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Template Comments */ /* Dump Template Comments */
dumpComment(fout, labelq->data, if (tmplinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, "", dumpComment(fout, labelq->data,
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId); NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
destroyPQExpBuffer(delq); destroyPQExpBuffer(delq);
...@@ -13326,20 +13424,22 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) ...@@ -13326,20 +13424,22 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data); binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data);
ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId, if (cfginfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
cfginfo->dobj.name, ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId,
cfginfo->dobj.namespace->dobj.name, cfginfo->dobj.name,
NULL, cfginfo->dobj.namespace->dobj.name,
cfginfo->rolname, NULL,
false, "TEXT SEARCH CONFIGURATION", SECTION_PRE_DATA, cfginfo->rolname,
q->data, delq->data, NULL, false, "TEXT SEARCH CONFIGURATION", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Configuration Comments */ /* Dump Configuration Comments */
dumpComment(fout, labelq->data, if (cfginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, cfginfo->rolname, dumpComment(fout, labelq->data,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId); NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
destroyPQExpBuffer(delq); destroyPQExpBuffer(delq);
...@@ -13393,27 +13493,30 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) ...@@ -13393,27 +13493,30 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data);
ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, if (fdwinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
fdwinfo->dobj.name, ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
NULL, fdwinfo->dobj.name,
NULL, NULL,
fdwinfo->rolname, NULL,
false, "FOREIGN DATA WRAPPER", SECTION_PRE_DATA, fdwinfo->rolname,
q->data, delq->data, NULL, false, "FOREIGN DATA WRAPPER", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Handle the ACL */ /* Handle the ACL */
dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, if (fdwinfo->dobj.dump & DUMP_COMPONENT_ACL)
"FOREIGN DATA WRAPPER", dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
qfdwname, NULL, fdwinfo->dobj.name, "FOREIGN DATA WRAPPER",
NULL, fdwinfo->rolname, qfdwname, NULL, fdwinfo->dobj.name,
fdwinfo->fdwacl); NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */ /* Dump Foreign Data Wrapper Comments */
dumpComment(fout, labelq->data, if (fdwinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, fdwinfo->rolname, dumpComment(fout, labelq->data,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId); NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
free(qfdwname); free(qfdwname);
...@@ -13486,33 +13589,37 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) ...@@ -13486,33 +13589,37 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data);
ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, if (srvinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
srvinfo->dobj.name, ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
NULL, srvinfo->dobj.name,
NULL, NULL,
srvinfo->rolname, NULL,
false, "SERVER", SECTION_PRE_DATA, srvinfo->rolname,
q->data, delq->data, NULL, false, "SERVER", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Handle the ACL */ /* Handle the ACL */
dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, if (srvinfo->dobj.dump & DUMP_COMPONENT_ACL)
"FOREIGN SERVER", dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
qsrvname, NULL, srvinfo->dobj.name, "FOREIGN SERVER",
NULL, srvinfo->rolname, qsrvname, NULL, srvinfo->dobj.name,
srvinfo->srvacl); NULL, srvinfo->rolname,
srvinfo->srvacl);
/* Dump user mappings */ /* Dump user mappings */
dumpUserMappings(fout, if (srvinfo->dobj.dump & DUMP_COMPONENT_USERMAP)
srvinfo->dobj.name, NULL, dumpUserMappings(fout,
srvinfo->rolname, srvinfo->dobj.name, NULL,
srvinfo->dobj.catId, srvinfo->dobj.dumpId); srvinfo->rolname,
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */ /* Dump Foreign Server Comments */
dumpComment(fout, labelq->data, if (srvinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, srvinfo->rolname, dumpComment(fout, labelq->data,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId); NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
free(qsrvname); free(qsrvname);
...@@ -13675,15 +13782,16 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo) ...@@ -13675,15 +13782,16 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
exit_horribly(NULL, "could not parse default ACL list (%s)\n", exit_horribly(NULL, "could not parse default ACL list (%s)\n",
daclinfo->defaclacl); daclinfo->defaclacl);
ArchiveEntry(fout, daclinfo->dobj.catId, daclinfo->dobj.dumpId, if (daclinfo->dobj.dump & DUMP_COMPONENT_ACL)
tag->data, ArchiveEntry(fout, daclinfo->dobj.catId, daclinfo->dobj.dumpId,
tag->data,
daclinfo->dobj.namespace ? daclinfo->dobj.namespace->dobj.name : NULL, daclinfo->dobj.namespace ? daclinfo->dobj.namespace->dobj.name : NULL,
NULL, NULL,
daclinfo->defaclrole, daclinfo->defaclrole,
false, "DEFAULT ACL", SECTION_POST_DATA, false, "DEFAULT ACL", SECTION_POST_DATA,
q->data, "", NULL, q->data, "", NULL,
NULL, 0, NULL, 0,
NULL, NULL); NULL, NULL);
destroyPQExpBuffer(tag); destroyPQExpBuffer(tag);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -14052,19 +14160,16 @@ collectSecLabels(Archive *fout, SecLabelItem **items) ...@@ -14052,19 +14160,16 @@ collectSecLabels(Archive *fout, SecLabelItem **items)
static void static void
dumpTable(Archive *fout, TableInfo *tbinfo) dumpTable(Archive *fout, TableInfo *tbinfo)
{ {
DumpOptions *dopt = fout->dopt; char *namecopy;
if (tbinfo->dobj.dump && !dopt->dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE) if (tbinfo->relkind == RELKIND_SEQUENCE)
dumpSequence(fout, tbinfo); dumpSequence(fout, tbinfo);
else else
dumpTableSchema(fout, tbinfo); dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */ /* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name)); namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
if (tbinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" : (tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE", "TABLE",
...@@ -14072,47 +14177,49 @@ dumpTable(Archive *fout, TableInfo *tbinfo) ...@@ -14072,47 +14177,49 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->relacl); tbinfo->relacl);
/* /*
* Handle column ACLs, if any. Note: we pull these with a separate * Handle column ACLs, if any. Note: we pull these with a separate
* query rather than trying to fetch them during getTableAttrs, so * query rather than trying to fetch them during getTableAttrs, so
* that we won't miss ACLs on system columns. * that we won't miss ACLs on system columns.
*/ */
if (fout->remoteVersion >= 80400) if (fout->remoteVersion >= 80400 && tbinfo->dobj.dump & DUMP_COMPONENT_ACL)
{ {
PQExpBuffer query = createPQExpBuffer(); PQExpBuffer query = createPQExpBuffer();
PGresult *res; PGresult *res;
int i; int i;
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT attname, attacl FROM pg_catalog.pg_attribute " "SELECT attname, attacl FROM pg_catalog.pg_attribute "
"WHERE attrelid = '%u' AND NOT attisdropped AND attacl IS NOT NULL " "WHERE attrelid = '%u' AND NOT attisdropped "
"ORDER BY attnum", "AND attacl IS NOT NULL "
tbinfo->dobj.catId.oid); "ORDER BY attnum",
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); tbinfo->dobj.catId.oid);
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
for (i = 0; i < PQntuples(res); i++) for (i = 0; i < PQntuples(res); i++)
{ {
char *attname = PQgetvalue(res, i, 0); char *attname = PQgetvalue(res, i, 0);
char *attacl = PQgetvalue(res, i, 1); char *attacl = PQgetvalue(res, i, 1);
char *attnamecopy; char *attnamecopy;
char *acltag; char *acltag;
attnamecopy = pg_strdup(fmtId(attname)); attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname); acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */ /* Column's GRANT type is always TABLE */
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag, namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl); attacl);
free(attnamecopy); free(attnamecopy);
free(acltag); free(acltag);
}
PQclear(res);
destroyPQExpBuffer(query);
} }
PQclear(res);
free(namecopy); destroyPQExpBuffer(query);
} }
free(namecopy);
return;
} }
/* /*
...@@ -14790,24 +14897,28 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -14790,24 +14897,28 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (dopt->binary_upgrade) if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data); binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data);
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tbinfo->dobj.name, ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
(tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace, (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
tbinfo->rolname, tbinfo->rolname,
(strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false, (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
reltypename, reltypename,
tbinfo->postponed_def ? SECTION_POST_DATA : SECTION_PRE_DATA, tbinfo->postponed_def ?
q->data, delq->data, NULL, SECTION_POST_DATA : SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump Table Comments */ /* Dump Table Comments */
dumpTableComment(fout, tbinfo, reltypename); if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpTableComment(fout, tbinfo, reltypename);
/* Dump Table Security Labels */ /* Dump Table Security Labels */
dumpTableSecLabel(fout, tbinfo, reltypename); if (tbinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpTableSecLabel(fout, tbinfo, reltypename);
/* Dump comments on inlined table constraints */ /* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++) for (j = 0; j < tbinfo->ncheck; j++)
...@@ -14817,7 +14928,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -14817,7 +14928,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (constr->separate || !constr->conislocal) if (constr->separate || !constr->conislocal)
continue; continue;
dumpTableConstraintComment(fout, constr); if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpTableConstraintComment(fout, constr);
} }
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -14867,15 +14979,16 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) ...@@ -14867,15 +14979,16 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
tag = psprintf("%s %s", tbinfo->dobj.name, tbinfo->attnames[adnum - 1]); tag = psprintf("%s %s", tbinfo->dobj.name, tbinfo->attnames[adnum - 1]);
ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId, if (adinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tag,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, NULL,
false, "DEFAULT", SECTION_PRE_DATA, tbinfo->rolname,
q->data, delq->data, NULL, false, "DEFAULT", SECTION_PRE_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
free(tag); free(tag);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
...@@ -14983,24 +15096,26 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) ...@@ -14983,24 +15096,26 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
appendPQExpBuffer(delq, "%s;\n", appendPQExpBuffer(delq, "%s;\n",
fmtId(indxinfo->dobj.name)); fmtId(indxinfo->dobj.name));
ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId, if (indxinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
indxinfo->dobj.name, ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, indxinfo->dobj.name,
indxinfo->tablespace, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, indxinfo->tablespace,
"INDEX", SECTION_POST_DATA, tbinfo->rolname, false,
q->data, delq->data, NULL, "INDEX", SECTION_POST_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
} }
/* Dump Index Comments */ /* Dump Index Comments */
dumpComment(fout, labelq->data, if (indxinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tbinfo->dobj.namespace->dobj.name, dumpComment(fout, labelq->data,
tbinfo->rolname, tbinfo->dobj.namespace->dobj.name,
indxinfo->dobj.catId, 0, tbinfo->rolname,
is_constraint ? indxinfo->indexconstraint : indxinfo->dobj.catId, 0,
indxinfo->dobj.dumpId); is_constraint ? indxinfo->indexconstraint :
indxinfo->dobj.dumpId);
destroyPQExpBuffer(q); destroyPQExpBuffer(q);
destroyPQExpBuffer(delq); destroyPQExpBuffer(delq);
...@@ -15114,15 +15229,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -15114,15 +15229,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name); tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name);
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tag,
indxinfo->tablespace, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, indxinfo->tablespace,
"CONSTRAINT", SECTION_POST_DATA, tbinfo->rolname, false,
q->data, delq->data, NULL, "CONSTRAINT", SECTION_POST_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
} }
else if (coninfo->contype == 'f') else if (coninfo->contype == 'f')
{ {
...@@ -15149,15 +15265,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -15149,15 +15265,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name); tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name);
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tag,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, NULL,
"FK CONSTRAINT", SECTION_POST_DATA, tbinfo->rolname, false,
q->data, delq->data, NULL, "FK CONSTRAINT", SECTION_POST_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
} }
else if (coninfo->contype == 'c' && tbinfo) else if (coninfo->contype == 'c' && tbinfo)
{ {
...@@ -15186,15 +15303,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -15186,15 +15303,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name); tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name);
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tag,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, NULL,
"CHECK CONSTRAINT", SECTION_POST_DATA, tbinfo->rolname, false,
q->data, delq->data, NULL, "CHECK CONSTRAINT", SECTION_POST_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
} }
} }
else if (coninfo->contype == 'c' && tbinfo == NULL) else if (coninfo->contype == 'c' && tbinfo == NULL)
...@@ -15224,15 +15342,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -15224,15 +15342,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tyinfo->dobj.name, coninfo->dobj.name); tag = psprintf("%s %s", tyinfo->dobj.name, coninfo->dobj.name);
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId, if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tyinfo->dobj.namespace->dobj.name, tag,
NULL, tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, false, NULL,
"CHECK CONSTRAINT", SECTION_POST_DATA, tyinfo->rolname, false,
q->data, delq->data, NULL, "CHECK CONSTRAINT", SECTION_POST_DATA,
NULL, 0, q->data, delq->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
} }
} }
else else
...@@ -15242,7 +15361,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) ...@@ -15242,7 +15361,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
} }
/* Dump Constraint Comments --- only works for table constraints */ /* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate) if (tbinfo && coninfo->separate &&
coninfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpTableConstraintComment(fout, coninfo); dumpTableConstraintComment(fout, coninfo);
free(tag); free(tag);
...@@ -15267,10 +15387,12 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo) ...@@ -15267,10 +15387,12 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
fmtId(coninfo->dobj.name)); fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s", appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name)); fmtId(tbinfo->dobj.name));
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, if (coninfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tbinfo->rolname, dumpComment(fout, labelq->data,
coninfo->dobj.catId, 0, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId); coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId);
destroyPQExpBuffer(labelq); destroyPQExpBuffer(labelq);
...@@ -15465,15 +15587,16 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -15465,15 +15587,16 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
binary_upgrade_extension_member(query, &tbinfo->dobj, binary_upgrade_extension_member(query, &tbinfo->dobj,
labelq->data); labelq->data);
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tbinfo->dobj.name, ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tbinfo->dobj.name,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, NULL,
false, "SEQUENCE", SECTION_PRE_DATA, tbinfo->rolname,
query->data, delqry->data, NULL, false, "SEQUENCE", SECTION_PRE_DATA,
NULL, 0, query->data, delqry->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* /*
* If the sequence is owned by a table column, emit the ALTER for it as a * If the sequence is owned by a table column, emit the ALTER for it as a
...@@ -15501,25 +15624,29 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ...@@ -15501,25 +15624,29 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(query, ".%s;\n", appendPQExpBuffer(query, ".%s;\n",
fmtId(owning_tab->attnames[tbinfo->owning_col - 1])); fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
ArchiveEntry(fout, nilCatalogId, createDumpId(), if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tbinfo->dobj.name, ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->dobj.namespace->dobj.name, tbinfo->dobj.name,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, NULL,
false, "SEQUENCE OWNED BY", SECTION_PRE_DATA, tbinfo->rolname,
query->data, "", NULL, false, "SEQUENCE OWNED BY", SECTION_PRE_DATA,
&(tbinfo->dobj.dumpId), 1, query->data, "", NULL,
NULL, NULL); &(tbinfo->dobj.dumpId), 1,
NULL, NULL);
} }
} }
/* Dump Sequence Comments and Security Labels */ /* Dump Sequence Comments and Security Labels */
dumpComment(fout, labelq->data, if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, dumpComment(fout, labelq->data,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
dumpSecLabel(fout, labelq->data, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); if (tbinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -15568,15 +15695,16 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo) ...@@ -15568,15 +15695,16 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo)
appendPQExpBuffer(query, ", %s, %s);\n", appendPQExpBuffer(query, ", %s, %s);\n",
last, (called ? "true" : "false")); last, (called ? "true" : "false"));
ArchiveEntry(fout, nilCatalogId, createDumpId(), if (tbinfo->dobj.dump & DUMP_COMPONENT_DATA)
tbinfo->dobj.name, ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->dobj.namespace->dobj.name, tbinfo->dobj.name,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, NULL,
false, "SEQUENCE SET", SECTION_DATA, tbinfo->rolname,
query->data, "", NULL, false, "SEQUENCE SET", SECTION_DATA,
&(tbinfo->dobj.dumpId), 1, query->data, "", NULL,
NULL, NULL); &(tbinfo->dobj.dumpId), 1,
NULL, NULL);
PQclear(res); PQclear(res);
...@@ -15778,19 +15906,21 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) ...@@ -15778,19 +15906,21 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
tag = psprintf("%s %s", tbinfo->dobj.name, tginfo->dobj.name); tag = psprintf("%s %s", tbinfo->dobj.name, tginfo->dobj.name);
ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId, if (tginfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tag,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, NULL,
"TRIGGER", SECTION_POST_DATA, tbinfo->rolname, false,
query->data, delqry->data, NULL, "TRIGGER", SECTION_POST_DATA,
NULL, 0, query->data, delqry->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
dumpComment(fout, labelq->data, if (tginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, dumpComment(fout, labelq->data,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId); tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
free(tag); free(tag);
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
...@@ -15856,14 +15986,16 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) ...@@ -15856,14 +15986,16 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
appendPQExpBuffer(labelq, "EVENT TRIGGER %s", appendPQExpBuffer(labelq, "EVENT TRIGGER %s",
fmtId(evtinfo->dobj.name)); fmtId(evtinfo->dobj.name));
ArchiveEntry(fout, evtinfo->dobj.catId, evtinfo->dobj.dumpId, if (evtinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
evtinfo->dobj.name, NULL, NULL, evtinfo->evtowner, false, ArchiveEntry(fout, evtinfo->dobj.catId, evtinfo->dobj.dumpId,
"EVENT TRIGGER", SECTION_POST_DATA, evtinfo->dobj.name, NULL, NULL, evtinfo->evtowner, false,
query->data, "", NULL, NULL, 0, NULL, NULL); "EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
dumpComment(fout, labelq->data, if (evtinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
NULL, evtinfo->evtowner, dumpComment(fout, labelq->data,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId); NULL, evtinfo->evtowner,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
destroyPQExpBuffer(query); destroyPQExpBuffer(query);
destroyPQExpBuffer(labelq); destroyPQExpBuffer(labelq);
...@@ -15983,21 +16115,23 @@ dumpRule(Archive *fout, RuleInfo *rinfo) ...@@ -15983,21 +16115,23 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
tag = psprintf("%s %s", tbinfo->dobj.name, rinfo->dobj.name); tag = psprintf("%s %s", tbinfo->dobj.name, rinfo->dobj.name);
ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId, if (rinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
tag, ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
tbinfo->dobj.namespace->dobj.name, tag,
NULL, tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname, false, NULL,
"RULE", SECTION_POST_DATA, tbinfo->rolname, false,
cmd->data, delcmd->data, NULL, "RULE", SECTION_POST_DATA,
NULL, 0, cmd->data, delcmd->data, NULL,
NULL, NULL); NULL, 0,
NULL, NULL);
/* Dump rule comments */ /* Dump rule comments */
dumpComment(fout, labelq->data, if (rinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
tbinfo->dobj.namespace->dobj.name, dumpComment(fout, labelq->data,
tbinfo->rolname, tbinfo->dobj.namespace->dobj.name,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId); tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
PQclear(res); PQclear(res);
...@@ -16172,7 +16306,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[], ...@@ -16172,7 +16306,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
{ {
TableInfo *configtbl; TableInfo *configtbl;
Oid configtbloid = atooid(extconfigarray[j]); Oid configtbloid = atooid(extconfigarray[j]);
bool dumpobj = curext->dobj.dump; bool dumpobj =
curext->dobj.dump & DUMP_COMPONENT_DEFINITION;
configtbl = findTableByOid(configtbloid); configtbl = findTableByOid(configtbloid);
if (configtbl == NULL) if (configtbl == NULL)
...@@ -16182,7 +16317,7 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[], ...@@ -16182,7 +16317,7 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
* Tables of not-to-be-dumped extensions shouldn't be dumped * Tables of not-to-be-dumped extensions shouldn't be dumped
* unless the table or its schema is explicitly included * unless the table or its schema is explicitly included
*/ */
if (!curext->dobj.dump) if (!(curext->dobj.dump & DUMP_COMPONENT_DEFINITION))
{ {
/* check table explicitly requested */ /* check table explicitly requested */
if (table_include_oids.head != NULL && if (table_include_oids.head != NULL &&
...@@ -16191,7 +16326,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[], ...@@ -16191,7 +16326,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
dumpobj = true; dumpobj = true;
/* check table's schema explicitly requested */ /* check table's schema explicitly requested */
if (configtbl->dobj.namespace->dobj.dump) if (configtbl->dobj.namespace->dobj.dump &
DUMP_COMPONENT_DATA)
dumpobj = true; dumpobj = true;
} }
......
...@@ -81,6 +81,18 @@ typedef enum ...@@ -81,6 +81,18 @@ typedef enum
DO_POLICY DO_POLICY
} DumpableObjectType; } DumpableObjectType;
/* component types of an object which can be selected for dumping */
typedef uint32 DumpComponents; /* a bitmask of dump object components */
#define DUMP_COMPONENT_NONE (0)
#define DUMP_COMPONENT_DEFINITION (1 << 0)
#define DUMP_COMPONENT_DATA (1 << 1)
#define DUMP_COMPONENT_COMMENT (1 << 2)
#define DUMP_COMPONENT_SECLABEL (1 << 3)
#define DUMP_COMPONENT_ACL (1 << 4)
#define DUMP_COMPONENT_POLICY (1 << 5)
#define DUMP_COMPONENT_USERMAP (1 << 6)
#define DUMP_COMPONENT_ALL (0xFFFF)
typedef struct _dumpableObject typedef struct _dumpableObject
{ {
DumpableObjectType objType; DumpableObjectType objType;
...@@ -88,7 +100,7 @@ typedef struct _dumpableObject ...@@ -88,7 +100,7 @@ typedef struct _dumpableObject
DumpId dumpId; /* assigned by AssignDumpId() */ DumpId dumpId; /* assigned by AssignDumpId() */
char *name; /* object name (should never be NULL) */ char *name; /* object name (should never be NULL) */
struct _namespaceInfo *namespace; /* containing namespace, or NULL */ struct _namespaceInfo *namespace; /* containing namespace, or NULL */
bool dump; /* true if we want to dump this object */ DumpComponents dump; /* bitmask of components to dump */
bool ext_member; /* true if object is member of extension */ bool ext_member; /* true if object is member of extension */
DumpId *dependencies; /* dumpIds of objects this one depends on */ DumpId *dependencies; /* dumpIds of objects this one depends on */
int nDeps; /* number of valid dependencies */ int nDeps; /* number of valid dependencies */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment