Refactor pg_dump's tracking of object components to be dumped.
Split the DumpableObject.dump bitmask field into separate bitmasks tracking which components are requested to be dumped (in the existing "dump" field) and which components exist for the particular object (in the new "components" field). This gets rid of some klugy and easily-broken logic that involved setting bits and later clearing them. More importantly, it restores the originally intended behavior that pg_dump's secondary data-gathering queries should not be executed for objects we have no interest in dumping. That optimization got broken when the dump flag was turned into a bitmask, because irrelevant bits tended to remain set in many cases. Since the "components" field starts from a minimal set of bits and is added onto as needed, ANDing it with "dump" provides a reliable indicator of what we actually have to dump, without having to complicate the logic that manages the request bits. This makes a significant difference in the number of queries needed when, for example, there are many functions in extensions. Discussion: https://postgr.es/m/2273648.1634764485@sss.pgh.pa.us Discussion: https://postgr.es/m/7d7eb6128f40401d81b3b7a898b6b4de@W2012-02.nidsa.loc
This commit is contained in:
parent
e9e63b7022
commit
5209c0ba0b
@ -584,6 +584,8 @@ AssignDumpId(DumpableObject *dobj)
|
|||||||
dobj->namespace = NULL; /* may be set later */
|
dobj->namespace = NULL; /* may be set later */
|
||||||
dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
|
dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
|
||||||
dobj->dump_contains = DUMP_COMPONENT_ALL; /* default assumption */
|
dobj->dump_contains = DUMP_COMPONENT_ALL; /* default assumption */
|
||||||
|
/* All objects have definitions; we may set more components bits later */
|
||||||
|
dobj->components = DUMP_COMPONENT_DEFINITION;
|
||||||
dobj->ext_member = false; /* default assumption */
|
dobj->ext_member = false; /* default assumption */
|
||||||
dobj->depends_on_ext = false; /* default assumption */
|
dobj->depends_on_ext = false; /* default assumption */
|
||||||
dobj->dependencies = NULL;
|
dobj->dependencies = NULL;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -85,8 +85,13 @@ typedef enum
|
|||||||
DO_SUBSCRIPTION
|
DO_SUBSCRIPTION
|
||||||
} DumpableObjectType;
|
} DumpableObjectType;
|
||||||
|
|
||||||
/* component types of an object which can be selected for dumping */
|
/*
|
||||||
typedef uint32 DumpComponents; /* a bitmask of dump object components */
|
* DumpComponents is a bitmask of the potentially dumpable components of
|
||||||
|
* a database object: its core definition, plus optional attributes such
|
||||||
|
* as ACL, comments, etc. The NONE and ALL symbols are convenient
|
||||||
|
* shorthands.
|
||||||
|
*/
|
||||||
|
typedef uint32 DumpComponents;
|
||||||
#define DUMP_COMPONENT_NONE (0)
|
#define DUMP_COMPONENT_NONE (0)
|
||||||
#define DUMP_COMPONENT_DEFINITION (1 << 0)
|
#define DUMP_COMPONENT_DEFINITION (1 << 0)
|
||||||
#define DUMP_COMPONENT_DATA (1 << 1)
|
#define DUMP_COMPONENT_DATA (1 << 1)
|
||||||
@ -131,8 +136,9 @@ 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 */
|
||||||
DumpComponents dump; /* bitmask of components to dump */
|
DumpComponents dump; /* bitmask of components requested to dump */
|
||||||
DumpComponents dump_contains; /* as above, but for contained objects */
|
DumpComponents dump_contains; /* as above, but for contained objects */
|
||||||
|
DumpComponents components; /* bitmask of components available to dump */
|
||||||
bool ext_member; /* true if object is member of extension */
|
bool ext_member; /* true if object is member of extension */
|
||||||
bool depends_on_ext; /* true if object depends on an extension */
|
bool depends_on_ext; /* true if object depends on an extension */
|
||||||
DumpId *dependencies; /* dumpIds of objects this one depends on */
|
DumpId *dependencies; /* dumpIds of objects this one depends on */
|
||||||
@ -289,6 +295,7 @@ typedef struct _tableInfo
|
|||||||
uint32 toast_frozenxid; /* toast table's relfrozenxid, if any */
|
uint32 toast_frozenxid; /* toast table's relfrozenxid, if any */
|
||||||
uint32 toast_minmxid; /* toast table's relminmxid */
|
uint32 toast_minmxid; /* toast table's relminmxid */
|
||||||
int ncheck; /* # of CHECK expressions */
|
int ncheck; /* # of CHECK expressions */
|
||||||
|
Oid reltype; /* OID of table's composite type, if any */
|
||||||
char *reloftype; /* underlying type for typed table */
|
char *reloftype; /* underlying type for typed table */
|
||||||
Oid foreign_server; /* foreign server oid, if applicable */
|
Oid foreign_server; /* foreign server oid, if applicable */
|
||||||
/* these two are set only if table is a sequence owned by a column: */
|
/* these two are set only if table is a sequence owned by a column: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user