diff options
author | Stephen Frost <sfrost@snowman.net> | 2016-04-06 21:45:32 -0400 |
---|---|---|
committer | Stephen Frost <sfrost@snowman.net> | 2016-04-06 21:45:32 -0400 |
commit | d217b2c360cb9a746b4ef122c568bdfedb6d726e (patch) | |
tree | 6fc3892fbee08146f67c627bb43902c0209c3ecc | |
parent | a9f0e8e5a2e779a888988cb64479a6723f668c84 (diff) | |
download | postgresql-d217b2c360cb9a746b4ef122c568bdfedb6d726e.tar.gz postgresql-d217b2c360cb9a746b4ef122c568bdfedb6d726e.zip |
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
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 23 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_dump.h | 3 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index cfd53f1838b..e3360bc4d56 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1311,24 +1311,25 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt) */ 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) - nsinfo->dobj.dump = simple_oid_list_member(&schema_include_oids, - nsinfo->dobj.catId.oid) ? + nsinfo->dobj.dump_contains = nsinfo->dobj.dump = + simple_oid_list_member(&schema_include_oids, + 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 = DUMP_COMPONENT_NONE; + nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE; 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 */ - if (nsinfo->dobj.dump && + if (nsinfo->dobj.dump_contains && simple_oid_list_member(&schema_exclude_oids, 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) tbinfo->dobj.catId.oid) ? DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; 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 @@ -1407,7 +1408,8 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt) if (checkExtensionMembership(&tyinfo->dobj, dopt)) 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) /* Default ACLs can't be extension members */ if (dinfo->dobj.namespace) + /* default ACLs are considered part of the namespace */ dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump; else dinfo->dobj.dump = dopt->include_everything ? @@ -1530,7 +1533,7 @@ selectDumpableObject(DumpableObject *dobj, DumpOptions *dopt) * non-namespace-associated items, dump if we're dumping "everything". */ if (dobj->namespace) - dobj->dump = dobj->namespace->dobj.dump; + dobj->dump = dobj->namespace->dobj.dump_contains; else dobj->dump = dopt->include_everything ? DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index f479c06d26c..85f9f480ba5 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -100,7 +100,8 @@ typedef struct _dumpableObject DumpId dumpId; /* assigned by AssignDumpId() */ char *name; /* object name (should never be 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 */ DumpId *dependencies; /* dumpIds of objects this one depends on */ int nDeps; /* number of valid dependencies */ |