Skip to content

Commit d217b2c

Browse files
committed
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
1 parent a9f0e8e commit d217b2c

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/bin/pg_dump/pg_dump.c

+13-10
Original file line numberDiff line numberDiff line change
@@ -1311,24 +1311,25 @@ selectDumpableNamespace(NamespaceInfo *nsinfo, DumpOptions *dopt)
13111311
*/
13121312

13131313
if (table_include_oids.head != NULL)
1314-
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
1314+
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
13151315
else if (schema_include_oids.head != NULL)
1316-
nsinfo->dobj.dump = simple_oid_list_member(&schema_include_oids,
1317-
nsinfo->dobj.catId.oid) ?
1316+
nsinfo->dobj.dump_contains = nsinfo->dobj.dump =
1317+
simple_oid_list_member(&schema_include_oids,
1318+
nsinfo->dobj.catId.oid) ?
13181319
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
13191320
else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 ||
13201321
strcmp(nsinfo->dobj.name, "information_schema") == 0)
1321-
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
1322+
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
13221323
else
1323-
nsinfo->dobj.dump = DUMP_COMPONENT_ALL;
1324+
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_ALL;
13241325

13251326
/*
13261327
* In any case, a namespace can be excluded by an exclusion switch
13271328
*/
1328-
if (nsinfo->dobj.dump &&
1329+
if (nsinfo->dobj.dump_contains &&
13291330
simple_oid_list_member(&schema_exclude_oids,
13301331
nsinfo->dobj.catId.oid))
1331-
nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
1332+
nsinfo->dobj.dump_contains = nsinfo->dobj.dump = DUMP_COMPONENT_NONE;
13321333
}
13331334

13341335
/*
@@ -1350,7 +1351,7 @@ selectDumpableTable(TableInfo *tbinfo, DumpOptions *dopt)
13501351
tbinfo->dobj.catId.oid) ?
13511352
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;
13521353
else
1353-
tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump;
1354+
tbinfo->dobj.dump = tbinfo->dobj.namespace->dobj.dump_contains;
13541355

13551356
/*
13561357
* In any case, a table can be excluded by an exclusion switch
@@ -1407,7 +1408,8 @@ selectDumpableType(TypeInfo *tyinfo, DumpOptions *dopt)
14071408
if (checkExtensionMembership(&tyinfo->dobj, dopt))
14081409
return; /* extension membership overrides all else */
14091410

1410-
tyinfo->dobj.dump = tyinfo->dobj.namespace->dobj.dump;
1411+
/* Dump based on if the contents of the namespace are being dumped */
1412+
tyinfo->dobj.dump = tyinfo->dobj.namespace->dobj.dump_contains;
14111413
}
14121414

14131415
/*
@@ -1424,6 +1426,7 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
14241426
/* Default ACLs can't be extension members */
14251427

14261428
if (dinfo->dobj.namespace)
1429+
/* default ACLs are considered part of the namespace */
14271430
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
14281431
else
14291432
dinfo->dobj.dump = dopt->include_everything ?
@@ -1530,7 +1533,7 @@ selectDumpableObject(DumpableObject *dobj, DumpOptions *dopt)
15301533
* non-namespace-associated items, dump if we're dumping "everything".
15311534
*/
15321535
if (dobj->namespace)
1533-
dobj->dump = dobj->namespace->dobj.dump;
1536+
dobj->dump = dobj->namespace->dobj.dump_contains;
15341537
else
15351538
dobj->dump = dopt->include_everything ?
15361539
DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE;

src/bin/pg_dump/pg_dump.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ typedef struct _dumpableObject
100100
DumpId dumpId; /* assigned by AssignDumpId() */
101101
char *name; /* object name (should never be NULL) */
102102
struct _namespaceInfo *namespace; /* containing namespace, or NULL */
103-
DumpComponents dump; /* bitmask of components to dump */
103+
DumpComponents dump; /* bitmask of components to dump */
104+
DumpComponents dump_contains; /* as above, but for contained objects */
104105
bool ext_member; /* true if object is member of extension */
105106
DumpId *dependencies; /* dumpIds of objects this one depends on */
106107
int nDeps; /* number of valid dependencies */

0 commit comments

Comments
 (0)