Commit 3b157cf2 authored by Robert Haas's avatar Robert Haas

pg_dump: Remove global Archive pointer.

Instead, everything that needs the Archive object now gets it as a
parameter.  This is necessary infrastructure for parallel pg_dump,
but is also amply justified by the ugliness of the current code
(though a lot more than this is needed to fix that problem).
parent 622f8628
...@@ -76,7 +76,7 @@ static int strInArray(const char *pattern, char **arr, int arr_size); ...@@ -76,7 +76,7 @@ static int strInArray(const char *pattern, char **arr, int arr_size);
* Collect information about all potentially dumpable objects * Collect information about all potentially dumpable objects
*/ */
TableInfo * TableInfo *
getSchemaData(int *numTablesPtr) getSchemaData(Archive *fout, int *numTablesPtr)
{ {
ExtensionInfo *extinfo; ExtensionInfo *extinfo;
InhInfo *inhinfo; InhInfo *inhinfo;
...@@ -101,7 +101,7 @@ getSchemaData(int *numTablesPtr) ...@@ -101,7 +101,7 @@ getSchemaData(int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading schemas\n"); write_msg(NULL, "reading schemas\n");
getNamespaces(&numNamespaces); getNamespaces(fout, &numNamespaces);
/* /*
* getTables should be done as soon as possible, so as to minimize the * getTables should be done as soon as possible, so as to minimize the
...@@ -111,94 +111,94 @@ getSchemaData(int *numTablesPtr) ...@@ -111,94 +111,94 @@ getSchemaData(int *numTablesPtr)
*/ */
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined tables\n"); write_msg(NULL, "reading user-defined tables\n");
tblinfo = getTables(&numTables); tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading extensions\n"); write_msg(NULL, "reading extensions\n");
extinfo = getExtensions(&numExtensions); extinfo = getExtensions(fout, &numExtensions);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined functions\n"); write_msg(NULL, "reading user-defined functions\n");
funinfo = getFuncs(&numFuncs); funinfo = getFuncs(fout, &numFuncs);
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo)); funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
/* this must be after getTables and getFuncs */ /* this must be after getTables and getFuncs */
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined types\n"); write_msg(NULL, "reading user-defined types\n");
typinfo = getTypes(&numTypes); typinfo = getTypes(fout, &numTypes);
typinfoindex = buildIndexArray(typinfo, numTypes, sizeof(TypeInfo)); typinfoindex = buildIndexArray(typinfo, numTypes, sizeof(TypeInfo));
/* this must be after getFuncs, too */ /* this must be after getFuncs, too */
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading procedural languages\n"); write_msg(NULL, "reading procedural languages\n");
getProcLangs(&numProcLangs); getProcLangs(fout, &numProcLangs);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined aggregate functions\n"); write_msg(NULL, "reading user-defined aggregate functions\n");
getAggregates(&numAggregates); getAggregates(fout, &numAggregates);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined operators\n"); write_msg(NULL, "reading user-defined operators\n");
oprinfo = getOperators(&numOperators); oprinfo = getOperators(fout, &numOperators);
oprinfoindex = buildIndexArray(oprinfo, numOperators, sizeof(OprInfo)); oprinfoindex = buildIndexArray(oprinfo, numOperators, sizeof(OprInfo));
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined operator classes\n"); write_msg(NULL, "reading user-defined operator classes\n");
getOpclasses(&numOpclasses); getOpclasses(fout, &numOpclasses);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined operator families\n"); write_msg(NULL, "reading user-defined operator families\n");
getOpfamilies(&numOpfamilies); getOpfamilies(fout, &numOpfamilies);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined text search parsers\n"); write_msg(NULL, "reading user-defined text search parsers\n");
getTSParsers(&numTSParsers); getTSParsers(fout, &numTSParsers);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined text search templates\n"); write_msg(NULL, "reading user-defined text search templates\n");
getTSTemplates(&numTSTemplates); getTSTemplates(fout, &numTSTemplates);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined text search dictionaries\n"); write_msg(NULL, "reading user-defined text search dictionaries\n");
getTSDictionaries(&numTSDicts); getTSDictionaries(fout, &numTSDicts);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined text search configurations\n"); write_msg(NULL, "reading user-defined text search configurations\n");
getTSConfigurations(&numTSConfigs); getTSConfigurations(fout, &numTSConfigs);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined foreign-data wrappers\n"); write_msg(NULL, "reading user-defined foreign-data wrappers\n");
getForeignDataWrappers(&numForeignDataWrappers); getForeignDataWrappers(fout, &numForeignDataWrappers);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined foreign servers\n"); write_msg(NULL, "reading user-defined foreign servers\n");
getForeignServers(&numForeignServers); getForeignServers(fout, &numForeignServers);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading default privileges\n"); write_msg(NULL, "reading default privileges\n");
getDefaultACLs(&numDefaultACLs); getDefaultACLs(fout, &numDefaultACLs);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined collations\n"); write_msg(NULL, "reading user-defined collations\n");
collinfo = getCollations(&numCollations); collinfo = getCollations(fout, &numCollations);
collinfoindex = buildIndexArray(collinfo, numCollations, sizeof(CollInfo)); collinfoindex = buildIndexArray(collinfo, numCollations, sizeof(CollInfo));
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined conversions\n"); write_msg(NULL, "reading user-defined conversions\n");
getConversions(&numConversions); getConversions(fout, &numConversions);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading type casts\n"); write_msg(NULL, "reading type casts\n");
getCasts(&numCasts); getCasts(fout, &numCasts);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading table inheritance information\n"); write_msg(NULL, "reading table inheritance information\n");
inhinfo = getInherits(&numInherits); inhinfo = getInherits(fout, &numInherits);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading rewrite rules\n"); write_msg(NULL, "reading rewrite rules\n");
getRules(&numRules); getRules(fout, &numRules);
/* /*
* Identify extension member objects and mark them as not to be dumped. * Identify extension member objects and mark them as not to be dumped.
...@@ -207,7 +207,7 @@ getSchemaData(int *numTablesPtr) ...@@ -207,7 +207,7 @@ getSchemaData(int *numTablesPtr)
*/ */
if (g_verbose) if (g_verbose)
write_msg(NULL, "finding extension members\n"); write_msg(NULL, "finding extension members\n");
getExtensionMembership(extinfo, numExtensions); getExtensionMembership(fout, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */ /* Link tables to parents, mark parents of target tables interesting */
if (g_verbose) if (g_verbose)
...@@ -216,7 +216,7 @@ getSchemaData(int *numTablesPtr) ...@@ -216,7 +216,7 @@ getSchemaData(int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading column info for interesting tables\n"); write_msg(NULL, "reading column info for interesting tables\n");
getTableAttrs(tblinfo, numTables); getTableAttrs(fout, tblinfo, numTables);
if (g_verbose) if (g_verbose)
write_msg(NULL, "flagging inherited columns in subtables\n"); write_msg(NULL, "flagging inherited columns in subtables\n");
...@@ -224,15 +224,15 @@ getSchemaData(int *numTablesPtr) ...@@ -224,15 +224,15 @@ getSchemaData(int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading indexes\n"); write_msg(NULL, "reading indexes\n");
getIndexes(tblinfo, numTables); getIndexes(fout, tblinfo, numTables);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading constraints\n"); write_msg(NULL, "reading constraints\n");
getConstraints(tblinfo, numTables); getConstraints(fout, tblinfo, numTables);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading triggers\n"); write_msg(NULL, "reading triggers\n");
getTriggers(tblinfo, numTables); getTriggers(fout, tblinfo, numTables);
*numTablesPtr = numTables; *numTablesPtr = numTables;
return tblinfo; return tblinfo;
......
...@@ -81,7 +81,7 @@ typedef enum ...@@ -81,7 +81,7 @@ typedef enum
* We may want to have some more user-readable data, but in the mean * We may want to have some more user-readable data, but in the mean
* time this gives us some abstraction and type checking. * time this gives us some abstraction and type checking.
*/ */
typedef struct _Archive struct Archive
{ {
int verbose; int verbose;
char *remoteVersionStr; /* server's version string */ char *remoteVersionStr; /* server's version string */
...@@ -99,7 +99,7 @@ typedef struct _Archive ...@@ -99,7 +99,7 @@ typedef struct _Archive
int n_errors; /* number of errors (if no die) */ int n_errors; /* number of errors (if no die) */
/* The rest is private */ /* The rest is private */
} Archive; };
typedef int (*DataDumperPtr) (Archive *AH, void *userArg); typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
......
This diff is collapsed.
...@@ -493,7 +493,10 @@ extern char g_opaque_type[10]; /* name for the opaque type */ ...@@ -493,7 +493,10 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions * common utility functions
*/ */
extern TableInfo *getSchemaData(int *numTablesPtr); struct Archive;
typedef struct Archive Archive;
extern TableInfo *getSchemaData(Archive *, int *numTablesPtr);
typedef enum _OidOptions typedef enum _OidOptions
{ {
...@@ -535,32 +538,35 @@ extern void sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs); ...@@ -535,32 +538,35 @@ extern void sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs);
/* /*
* version specific routines * version specific routines
*/ */
extern NamespaceInfo *getNamespaces(int *numNamespaces); extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
extern ExtensionInfo *getExtensions(int *numExtensions); extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions);
extern TypeInfo *getTypes(int *numTypes); extern TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(int *numFuncs); extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
extern AggInfo *getAggregates(int *numAggregates); extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
extern OprInfo *getOperators(int *numOperators); extern OprInfo *getOperators(Archive *fout, int *numOperators);
extern OpclassInfo *getOpclasses(int *numOpclasses); extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
extern OpfamilyInfo *getOpfamilies(int *numOpfamilies); extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(int *numCollations); extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(int *numConversions); extern ConvInfo *getConversions(Archive *fout, int *numConversions);
extern TableInfo *getTables(int *numTables); extern TableInfo *getTables(Archive *fout, int *numTables);
extern InhInfo *getInherits(int *numInherits); extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(TableInfo tblinfo[], int numTables); extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
extern void getConstraints(TableInfo tblinfo[], int numTables); extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables);
extern RuleInfo *getRules(int *numRules); extern RuleInfo *getRules(Archive *fout, int *numRules);
extern void getTriggers(TableInfo tblinfo[], int numTables); extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
extern ProcLangInfo *getProcLangs(int *numProcLangs); extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs);
extern CastInfo *getCasts(int *numCasts); extern CastInfo *getCasts(Archive *fout, int *numCasts);
extern void getTableAttrs(TableInfo *tbinfo, int numTables); extern void getTableAttrs(Archive *fout, TableInfo *tbinfo, int numTables);
extern TSParserInfo *getTSParsers(int *numTSParsers); extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
extern TSDictInfo *getTSDictionaries(int *numTSDicts); extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
extern TSTemplateInfo *getTSTemplates(int *numTSTemplates); extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
extern TSConfigInfo *getTSConfigurations(int *numTSConfigs); extern TSConfigInfo *getTSConfigurations(Archive *fout, int *numTSConfigs);
extern FdwInfo *getForeignDataWrappers(int *numForeignDataWrappers); extern FdwInfo *getForeignDataWrappers(Archive *fout,
extern ForeignServerInfo *getForeignServers(int *numForeignServers); int *numForeignDataWrappers);
extern DefaultACLInfo *getDefaultACLs(int *numDefaultACLs); extern ForeignServerInfo *getForeignServers(Archive *fout,
extern void getExtensionMembership(ExtensionInfo extinfo[], int numExtensions); int *numForeignServers);
extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions);
#endif /* PG_DUMP_H */ #endif /* PG_DUMP_H */
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