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)
dobj->dumpId = ++lastDumpId;
dobj->name = NULL; /* must 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->dependencies = NULL;
dobj->nDeps = 0;
......
......@@ -1287,7 +1287,7 @@ checkExtensionMembership(DumpableObject *dobj, DumpOptions *dopt)
* extension contents with something different.
*/
if (!dopt->binary_upgrade)
dobj->dump = false;
dobj->dump = DUMP_COMPONENT_NONE;
else
dobj->dump = ext->dobj.dump;
......@@ -1309,16 +1309,18 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt)
* namespaces. If specific namespaces are being dumped, dump just those
* namespaces. Otherwise, dump all non-system namespaces.
*/
if (table_include_oids.head != NULL)
nsinfo->dobj.dump = false;
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
else if (schema_include_oids.head != NULL)
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 ||
strcmp(nsinfo->dobj.name, "information_schema") == 0)
nsinfo->dobj.dump = false;
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
else
nsinfo->dobj.dump = true;
nsinfo->dobj.dump = DUMP_COMPONENT_ALL;
/*
* In any case, a namespace can be excluded by an exclusion switch
......@@ -1326,7 +1328,7 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt)
if (nsinfo->dobj.dump &&
simple_oid_list_member(&schema_exclude_oids,
nsinfo->dobj.catId.oid))
nsinfo->dobj.dump = false;
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
}
/*
......@@ -1345,7 +1347,8 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt)
*/
if (table_include_oids.head != NULL)
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
tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump;
......@@ -1355,7 +1358,7 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt)
if (tbinfo->dobj.dump &&
simple_oid_list_member(&table_exclude_oids,
tbinfo->dobj.catId.oid))
tbinfo->dobj.dump = false;
tbinfo->dobj.dump = DUMP_COMPONENT_NONE;
}
/*
......@@ -1384,7 +1387,7 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt)
if (tytable != NULL)
tyinfo->dobj.dump = tytable->dobj.dump;
else
tyinfo->dobj.dump = false;
tyinfo->dobj.dump = DUMP_COMPONENT_NONE;
return;
}
......@@ -1404,11 +1407,7 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt)
if (checkExtensionMembership(&tyinfo->dobj, dopt))
return; /* extension membership overrides all else */
/* dump only types in dumpable namespaces */
if (!tyinfo->dobj.namespace->dobj.dump)
tyinfo->dobj.dump = false;
else
tyinfo->dobj.dump = true;
tyinfo->dobj.dump = tyinfo->dobj.namespace->dobj.dump;
}
/*
......@@ -1427,7 +1426,8 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
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)
return; /* extension membership overrides all else */
if (cast->dobj.catId.oid < (Oid) FirstNormalObjectId)
cast->dobj.dump = false;
cast->dobj.dump = DUMP_COMPONENT_NONE;
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)
return; /* extension membership overrides all else */
if (plang->dobj.catId.oid < (Oid) FirstNormalObjectId)
plang->dobj.dump = false;
plang->dobj.dump = DUMP_COMPONENT_NONE;
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
selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
{
if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
extinfo->dobj.dump = DUMP_COMPONENT_NONE;
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)
if (dobj->namespace)
dobj->dump = dobj->namespace->dobj.dump;
else
dobj->dump = dopt->include_everything;
dobj->dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
}
/*
......@@ -1934,6 +1938,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
* dependency on its table as "special" and pass it to ArchiveEntry now.
* See comments for BuildArchiveDependencies.
*/
if (tdinfo->dobj.dump & DUMP_COMPONENT_DATA)
ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
......@@ -1968,6 +1973,7 @@ refreshMatViewData(Archive *fout, TableDataInfo *tdinfo)
appendPQExpBuffer(q, "REFRESH MATERIALIZED VIEW %s;\n",
fmtId(tbinfo->dobj.name));
if (tdinfo->dobj.dump & DUMP_COMPONENT_DATA)
ArchiveEntry(fout,
tdinfo->dobj.catId, /* catalog ID */
tdinfo->dobj.dumpId, /* dump ID */
......@@ -2000,7 +2006,7 @@ getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids)
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
if (tblinfo[i].dobj.dump & DUMP_COMPONENT_DATA)
makeTableDataInfo(dopt, &(tblinfo[i]), oids);
}
}
......@@ -2261,7 +2267,7 @@ guessConstraintInheritance(TableInfo *tblinfo, int numTables)
continue;
/* Don't bother computing anything for non-target tables, either */
if (!tbinfo->dobj.dump)
if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue;
numParents = tbinfo->numParents;
......@@ -2811,6 +2817,7 @@ dumpBlob(Archive *fout, BlobInfo *binfo)
"SELECT pg_catalog.lo_unlink('%s');\n",
binfo->dobj.name);
if (binfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, binfo->dobj.catId, binfo->dobj.dumpId,
binfo->dobj.name,
NULL, NULL,
......@@ -2825,17 +2832,19 @@ dumpBlob(Archive *fout, BlobInfo *binfo)
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
if (binfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
if (binfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* 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",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
......@@ -2956,7 +2965,7 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
TableInfo *tbinfo = &tblinfo[i];
/* Ignore row security on tables not to be dumped */
if (!tbinfo->dobj.dump)
if (!(tbinfo->dobj.dump & DUMP_COMPONENT_POLICY))
continue;
if (g_verbose)
......@@ -3097,6 +3106,7 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
appendPQExpBuffer(query, "ALTER TABLE %s ENABLE ROW LEVEL SECURITY;",
fmtId(polinfo->dobj.name));
if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
polinfo->dobj.name,
polinfo->dobj.namespace->dobj.name,
......@@ -3150,6 +3160,7 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
tag = psprintf("%s %s", tbinfo->dobj.name, polinfo->dobj.name);
if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
tag,
polinfo->dobj.namespace->dobj.name,
......@@ -3764,7 +3775,8 @@ getTypes(Archive *fout, int *numTypes)
*/
tyinfo[i].nDomChecks = 0;
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]));
/*
......@@ -3777,7 +3789,8 @@ getTypes(Archive *fout, int *numTypes)
* should copy the base type's catId, but then it might capture the
* 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_BASE ||
tyinfo[i].typtype == TYPTYPE_RANGE))
{
stinfo = (ShellTypeInfo *) pg_malloc(sizeof(ShellTypeInfo));
......@@ -3794,7 +3807,7 @@ getTypes(Archive *fout, int *numTypes)
* dump it if the I/O or canonicalize functions need to be dumped;
* 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
......@@ -3812,7 +3825,7 @@ getTypes(Archive *fout, int *numTypes)
typoutput = atooid(PQgetvalue(res, i, i_typoutput));
funcInfo = findFuncByOid(typinput);
if (funcInfo && funcInfo->dobj.dump)
if (funcInfo && funcInfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
{
/* base type depends on function */
addObjectDependency(&tyinfo[i].dobj,
......@@ -3821,11 +3834,11 @@ getTypes(Archive *fout, int *numTypes)
addObjectDependency(&funcInfo->dobj,
stinfo->dobj.dumpId);
/* mark shell type as to be dumped */
stinfo->dobj.dump = true;
stinfo->dobj.dump = DUMP_COMPONENT_ALL;
}
funcInfo = findFuncByOid(typoutput);
if (funcInfo && funcInfo->dobj.dump)
if (funcInfo && funcInfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
{
/* base type depends on function */
addObjectDependency(&tyinfo[i].dobj,
......@@ -3834,7 +3847,7 @@ getTypes(Archive *fout, int *numTypes)
addObjectDependency(&funcInfo->dobj,
stinfo->dobj.dumpId);
/* 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)
* Decide whether we want to dump this table.
*/
if (tblinfo[i].relkind == RELKIND_COMPOSITE_TYPE)
tblinfo[i].dobj.dump = false;
tblinfo[i].dobj.dump = DUMP_COMPONENT_NONE;
else
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 */
......@@ -5427,13 +5441,13 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
if (!OidIsValid(seqinfo->owning_tab))
continue; /* not an owned sequence */
if (seqinfo->dobj.dump)
if (seqinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
continue; /* no need to search */
owning_tab = findTableByOid(seqinfo->owning_tab);
if (owning_tab && owning_tab->dobj.dump)
{
seqinfo->interesting = true;
seqinfo->dobj.dump = true;
seqinfo->dobj.dump = DUMP_COMPONENT_ALL;
}
}
}
......@@ -5535,8 +5549,8 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
if (!tbinfo->hasindex)
continue;
/* Ignore indexes of tables not to be dumped */
if (!tbinfo->dobj.dump)
/* Ignore indexes of tables whose definitions are not to be dumped */
if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue;
if (g_verbose)
......@@ -5903,7 +5917,8 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
{
TableInfo *tbinfo = &tblinfo[i];
if (!tbinfo->hastriggers || !tbinfo->dobj.dump)
if (!tbinfo->hastriggers ||
!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue;
if (g_verbose)
......@@ -6242,7 +6257,8 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
{
TableInfo *tbinfo = &tblinfo[i];
if (!tbinfo->hastriggers || !tbinfo->dobj.dump)
if (!tbinfo->hastriggers ||
!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue;
if (g_verbose)
......@@ -8595,6 +8611,7 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
dumpBlob(fout, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
if (dobj->dump & DUMP_COMPONENT_DATA)
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
dobj->name, NULL, NULL, "",
false, "BLOBS", SECTION_DATA,
......@@ -8648,6 +8665,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data);
if (nspinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
nspinfo->dobj.name,
NULL, NULL,
......@@ -8658,13 +8676,17 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
NULL, NULL);
/* Dump Schema Comments and Security Labels */
if (nspinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
if (nspinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, labelq->data,
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);
......@@ -8777,6 +8799,7 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
appendPQExpBuffer(labelq, "EXTENSION %s", qextname);
if (extinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, extinfo->dobj.catId, extinfo->dobj.dumpId,
extinfo->dobj.name,
NULL, NULL,
......@@ -8787,9 +8810,12 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
NULL, NULL);
/* Dump Extension Comments and Security Labels */
if (extinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
......@@ -8932,6 +8958,7 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
......@@ -8943,13 +8970,17 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
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,
......@@ -9065,6 +9096,7 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
......@@ -9076,13 +9108,17 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
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,
......@@ -9135,6 +9171,7 @@ dumpUndefinedType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
......@@ -9146,13 +9183,17 @@ dumpUndefinedType(Archive *fout, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
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,
......@@ -9524,6 +9565,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
......@@ -9535,13 +9577,17 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
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,
......@@ -9687,6 +9733,7 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
......@@ -9698,13 +9745,17 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Domain Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
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,
......@@ -9720,10 +9771,13 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo)
fmtId(domcheck->dobj.name));
appendPQExpBuffer(labelq, "ON DOMAIN %s",
qtypname);
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname,
domcheck->dobj.catId, 0, tyinfo->dobj.dumpId);
destroyPQExpBuffer(labelq);
}
......@@ -9913,6 +9967,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
......@@ -9925,13 +9980,17 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
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,
......@@ -9945,6 +10004,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
destroyPQExpBuffer(query);
/* Dump any per-column comments */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpCompositeTypeColComments(fout, tyinfo);
}
......@@ -10090,6 +10150,7 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
appendPQExpBuffer(q, "CREATE TYPE %s;\n",
fmtId(stinfo->dobj.name));
if (stinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, stinfo->dobj.catId, stinfo->dobj.dumpId,
stinfo->dobj.name,
stinfo->dobj.namespace->dobj.name,
......@@ -10227,6 +10288,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data);
if (plang->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
plang->dobj.name,
lanschema, NULL, plang->lanowner,
......@@ -10236,14 +10298,17 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
if (plang->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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",
qlanname, NULL, plang->dobj.name,
lanschema,
......@@ -10892,6 +10957,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &finfo->dobj, labelq->data);
if (finfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
funcsig_tag,
finfo->dobj.namespace->dobj.name,
......@@ -10903,13 +10969,17 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
NULL, NULL);
/* Dump Function Comments and Security Labels */
if (finfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
if (finfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
......@@ -11022,6 +11092,7 @@ dumpCast(Archive *fout, CastInfo *cast)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data);
if (cast->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
labelq->data,
"pg_catalog", NULL, "",
......@@ -11031,6 +11102,7 @@ dumpCast(Archive *fout, CastInfo *cast)
NULL, NULL);
/* Dump Cast Comments */
if (cast->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
......@@ -11142,6 +11214,7 @@ dumpTransform(Archive *fout, TransformInfo *transform)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &transform->dobj, labelq->data);
if (transform->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, transform->dobj.catId, transform->dobj.dumpId,
labelq->data,
"pg_catalog", NULL, "",
......@@ -11151,6 +11224,7 @@ dumpTransform(Archive *fout, TransformInfo *transform)
NULL, NULL);
/* Dump Transform Comments */
if (transform->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, "",
transform->dobj.catId, 0, transform->dobj.dumpId);
......@@ -11396,6 +11470,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data);
if (oprinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
oprinfo->dobj.name,
oprinfo->dobj.namespace->dobj.name,
......@@ -11407,6 +11482,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
NULL, NULL);
/* Dump Operator Comments */
if (oprinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
......@@ -11974,6 +12050,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data);
if (opcinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
opcinfo->dobj.name,
opcinfo->dobj.namespace->dobj.name,
......@@ -11985,6 +12062,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
NULL, NULL);
/* Dump Operator Class Comments */
if (opcinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
......@@ -12288,6 +12366,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data);
if (opfinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId,
opfinfo->dobj.name,
opfinfo->dobj.namespace->dobj.name,
......@@ -12299,6 +12378,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
NULL, NULL);
/* Dump Operator Family Comments */
if (opfinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
......@@ -12378,6 +12458,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data);
if (collinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId,
collinfo->dobj.name,
collinfo->dobj.namespace->dobj.name,
......@@ -12389,6 +12470,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo)
NULL, NULL);
/* Dump Collation Comments */
if (collinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
......@@ -12478,6 +12560,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data);
if (convinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
convinfo->dobj.name,
convinfo->dobj.namespace->dobj.name,
......@@ -12489,6 +12572,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
NULL, NULL);
/* Dump Conversion Comments */
if (convinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
......@@ -12941,7 +13025,9 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
if (dopt->binary_upgrade)
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)
ArchiveEntry(fout, agginfo->aggfn.dobj.catId,
agginfo->aggfn.dobj.dumpId,
aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
NULL,
......@@ -12952,11 +13038,16 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
NULL, NULL);
/* Dump Aggregate Comments */
if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.namespace->dobj.name,
agginfo->aggfn.rolname,
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.namespace->dobj.name,
agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
/*
......@@ -12970,6 +13061,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
......@@ -13042,6 +13134,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data);
if (prsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId,
prsinfo->dobj.name,
prsinfo->dobj.namespace->dobj.name,
......@@ -13053,6 +13146,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
NULL, NULL);
/* Dump Parser Comments */
if (prsinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
......@@ -13130,6 +13224,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data);
if (dictinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId,
dictinfo->dobj.name,
dictinfo->dobj.namespace->dobj.name,
......@@ -13141,6 +13236,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
NULL, NULL);
/* Dump Dictionary Comments */
if (dictinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
......@@ -13197,6 +13293,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data);
if (tmplinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId,
tmplinfo->dobj.name,
tmplinfo->dobj.namespace->dobj.name,
......@@ -13208,6 +13305,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
NULL, NULL);
/* Dump Template Comments */
if (tmplinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
......@@ -13326,6 +13424,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data);
if (cfginfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId,
cfginfo->dobj.name,
cfginfo->dobj.namespace->dobj.name,
......@@ -13337,6 +13436,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
NULL, NULL);
/* Dump Configuration Comments */
if (cfginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
......@@ -13393,6 +13493,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data);
if (fdwinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
fdwinfo->dobj.name,
NULL,
......@@ -13404,6 +13505,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
NULL, NULL);
/* Handle the ACL */
if (fdwinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
......@@ -13411,6 +13513,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
if (fdwinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
......@@ -13486,6 +13589,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data);
if (srvinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
srvinfo->dobj.name,
NULL,
......@@ -13497,6 +13601,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
NULL, NULL);
/* Handle the ACL */
if (srvinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
......@@ -13504,12 +13609,14 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
srvinfo->srvacl);
/* Dump user mappings */
if (srvinfo->dobj.dump & DUMP_COMPONENT_USERMAP)
dumpUserMappings(fout,
srvinfo->dobj.name, NULL,
srvinfo->rolname,
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
if (srvinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
......@@ -13675,6 +13782,7 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
exit_horribly(NULL, "could not parse default ACL list (%s)\n",
daclinfo->defaclacl);
if (daclinfo->dobj.dump & DUMP_COMPONENT_ACL)
ArchiveEntry(fout, daclinfo->dobj.catId, daclinfo->dobj.dumpId,
tag->data,
daclinfo->dobj.namespace ? daclinfo->dobj.namespace->dobj.name : NULL,
......@@ -14052,10 +14160,6 @@ collectSecLabels(Archive *fout, SecLabelItem **items)
static void
dumpTable(Archive *fout, TableInfo *tbinfo)
{
DumpOptions *dopt = fout->dopt;
if (tbinfo->dobj.dump && !dopt->dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
......@@ -14065,6 +14169,7 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
if (tbinfo->dobj.dump & DUMP_COMPONENT_ACL)
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
......@@ -14077,7 +14182,7 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
* query rather than trying to fetch them during getTableAttrs, so
* 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();
PGresult *res;
......@@ -14085,7 +14190,8 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(query,
"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 "
"AND attacl IS NOT NULL "
"ORDER BY attnum",
tbinfo->dobj.catId.oid);
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
......@@ -14112,7 +14218,8 @@ dumpTable(Archive *fout, TableInfo *tbinfo)
}
free(namecopy);
}
return;
}
/*
......@@ -14790,6 +14897,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data);
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
......@@ -14797,16 +14905,19 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
tbinfo->rolname,
(strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false,
reltypename,
tbinfo->postponed_def ? SECTION_POST_DATA : SECTION_PRE_DATA,
tbinfo->postponed_def ?
SECTION_POST_DATA : SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
/* Dump Table Comments */
if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpTableComment(fout, tbinfo, reltypename);
/* Dump Table Security Labels */
if (tbinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpTableSecLabel(fout, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
......@@ -14817,6 +14928,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (constr->separate || !constr->conislocal)
continue;
if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpTableConstraintComment(fout, constr);
}
......@@ -14867,6 +14979,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
tag = psprintf("%s %s", tbinfo->dobj.name, tbinfo->attnames[adnum - 1]);
if (adinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
......@@ -14983,6 +15096,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
appendPQExpBuffer(delq, "%s;\n",
fmtId(indxinfo->dobj.name));
if (indxinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
indxinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
......@@ -14995,6 +15109,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
}
/* Dump Index Comments */
if (indxinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
......@@ -15114,6 +15229,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name);
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
......@@ -15149,6 +15265,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name);
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
......@@ -15186,6 +15303,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tbinfo->dobj.name, coninfo->dobj.name);
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
......@@ -15224,6 +15342,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
tag = psprintf("%s %s", tyinfo->dobj.name, coninfo->dobj.name);
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tyinfo->dobj.namespace->dobj.name,
......@@ -15242,7 +15361,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
}
/* 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);
free(tag);
......@@ -15267,6 +15387,8 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
if (coninfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
......@@ -15465,6 +15587,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
binary_upgrade_extension_member(query, &tbinfo->dobj,
labelq->data);
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
......@@ -15501,6 +15624,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
appendPQExpBuffer(query, ".%s;\n",
fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
......@@ -15514,9 +15638,12 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
}
/* Dump Sequence Comments and Security Labels */
if (tbinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
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);
......@@ -15568,6 +15695,7 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo)
appendPQExpBuffer(query, ", %s, %s);\n",
last, (called ? "true" : "false"));
if (tbinfo->dobj.dump & DUMP_COMPONENT_DATA)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
......@@ -15778,6 +15906,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
tag = psprintf("%s %s", tbinfo->dobj.name, tginfo->dobj.name);
if (tginfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
......@@ -15788,6 +15917,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
NULL, 0,
NULL, NULL);
if (tginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
......@@ -15856,11 +15986,13 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
appendPQExpBuffer(labelq, "EVENT TRIGGER %s",
fmtId(evtinfo->dobj.name));
if (evtinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, evtinfo->dobj.catId, evtinfo->dobj.dumpId,
evtinfo->dobj.name, NULL, NULL, evtinfo->evtowner, false,
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
if (evtinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
NULL, evtinfo->evtowner,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
......@@ -15983,6 +16115,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
tag = psprintf("%s %s", tbinfo->dobj.name, rinfo->dobj.name);
if (rinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
......@@ -15994,6 +16127,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
NULL, NULL);
/* Dump rule comments */
if (rinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
......@@ -16172,7 +16306,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
{
TableInfo *configtbl;
Oid configtbloid = atooid(extconfigarray[j]);
bool dumpobj = curext->dobj.dump;
bool dumpobj =
curext->dobj.dump & DUMP_COMPONENT_DEFINITION;
configtbl = findTableByOid(configtbloid);
if (configtbl == NULL)
......@@ -16182,7 +16317,7 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
* Tables of not-to-be-dumped extensions shouldn't be dumped
* unless the table or its schema is explicitly included
*/
if (!curext->dobj.dump)
if (!(curext->dobj.dump & DUMP_COMPONENT_DEFINITION))
{
/* check table explicitly requested */
if (table_include_oids.head != NULL &&
......@@ -16191,7 +16326,8 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
dumpobj = true;
/* check table's schema explicitly requested */
if (configtbl->dobj.namespace->dobj.dump)
if (configtbl->dobj.namespace->dobj.dump &
DUMP_COMPONENT_DATA)
dumpobj = true;
}
......
......@@ -81,6 +81,18 @@ typedef enum
DO_POLICY
} 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
{
DumpableObjectType objType;
......@@ -88,7 +100,7 @@ typedef struct _dumpableObject
DumpId dumpId; /* assigned by AssignDumpId() */
char *name; /* object name (should never be 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 */
DumpId *dependencies; /* dumpIds of objects this one depends on */
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