Commit d217b2c3 authored by Stephen Frost's avatar Stephen Frost

In pg_dump, split "dump" into "dump" and "dump_contains"

Historically, the "dump" component of the namespace has been used
to decide if the objects inside of the namespace should be dumped
also.  Given that "dump" is now a bitmask and may be partial, and
we may want to dump out all components of the namespace object but
only some of the components of objects contained in the namespace,
create a "dump_contains" bitmask which will represent what components
of the objects inside of a namespace should be dumped out.

No behavior change here, but in preparation for a change where we
will dump out just the ACLs of objects in pg_catalog, but we might
not dump out the ACL of the pg_catalog namespace itself (for instance,
when it hasn't been changed from the value set at initdb time).

Reviews by Alexander Korotkov, Jose Luis Tallon
parent a9f0e8e5
...@@ -1311,24 +1311,25 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt) ...@@ -1311,24 +1311,25 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt)
*/ */
if (table_include_oids.head != NULL) if (table_include_oids.head != NULL)
nsinfo->dobj.dump = DUMP_COMPONENT_NONE; nsinfo->dobj.dump_contains = 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_contains = nsinfo->dobj.dump =
simple_oid_list_member(&schema_include_oids,
nsinfo->dobj.catId.oid) ? nsinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; 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 = DUMP_COMPONENT_NONE; nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
else else
nsinfo->dobj.dump = DUMP_COMPONENT_ALL; nsinfo->dobj.dump_contains = 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
*/ */
if (nsinfo->dobj.dump && if (nsinfo->dobj.dump_contains &&
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 = DUMP_COMPONENT_NONE; nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
} }
/* /*
...@@ -1350,7 +1351,7 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt) ...@@ -1350,7 +1351,7 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt)
tbinfo->dobj.catId.oid) ? tbinfo->dobj.catId.oid) ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
else else
tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump; tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump_contains;
/* /*
* In any case, a table can be excluded by an exclusion switch * In any case, a table can be excluded by an exclusion switch
...@@ -1407,7 +1408,8 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt) ...@@ -1407,7 +1408,8 @@ 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 */
tyinfo->dobj.dump = tyinfo->dobj.namespace->dobj.dump; /* Dump based on if the contents of the namespace are being dumped */
tyinfo->dobj.dump = tyinfo->dobj.namespace->dobj.dump_contains;
} }
/* /*
...@@ -1424,6 +1426,7 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt) ...@@ -1424,6 +1426,7 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
/* Default ACLs can't be extension members */ /* Default ACLs can't be extension members */
if (dinfo->dobj.namespace) if (dinfo->dobj.namespace)
/* default ACLs are considered part of the 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 ?
...@@ -1530,7 +1533,7 @@ selectDumpableObject(DumpableObject *dobj, DumpOptions *dopt) ...@@ -1530,7 +1533,7 @@ selectDumpableObject(DumpableObject *dobj, DumpOptions *dopt)
* non-namespace-associated items, dump if we're dumping "everything". * non-namespace-associated items, dump if we're dumping "everything".
*/ */
if (dobj->namespace) if (dobj->namespace)
dobj->dump = dobj->namespace->dobj.dump; dobj->dump = dobj->namespace->dobj.dump_contains;
else else
dobj->dump = dopt->include_everything ? dobj->dump = dopt->include_everything ?
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
......
...@@ -101,6 +101,7 @@ typedef struct _dumpableObject ...@@ -101,6 +101,7 @@ typedef struct _dumpableObject
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 */
DumpComponents dump; /* bitmask of components to dump */ DumpComponents dump; /* bitmask of components to dump */
DumpComponents dump_contains; /* as above, but for contained objects */
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