aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c282
1 files changed, 67 insertions, 215 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e3240708284..7aec016a9ff 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4173,8 +4173,8 @@ dumpPolicy(Archive *fout, const PolicyInfo *polinfo)
* getPublications
* get information about publications
*/
-PublicationInfo *
-getPublications(Archive *fout, int *numPublications)
+void
+getPublications(Archive *fout)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
@@ -4194,10 +4194,7 @@ getPublications(Archive *fout, int *numPublications)
ntups;
if (dopt->no_publications || fout->remoteVersion < 100000)
- {
- *numPublications = 0;
- return NULL;
- }
+ return;
query = createPQExpBuffer();
@@ -4268,9 +4265,6 @@ getPublications(Archive *fout, int *numPublications)
PQclear(res);
destroyPQExpBuffer(query);
-
- *numPublications = ntups;
- return pubinfo;
}
/*
@@ -5547,13 +5541,10 @@ binary_upgrade_extension_member(PQExpBuffer upgrade_buffer,
/*
* getNamespaces:
- * read all namespaces in the system catalogs and return them in the
- * NamespaceInfo* structure
- *
- * numNamespaces is set to the number of namespaces read in
+ * get information about all namespaces in the system catalogs
*/
-NamespaceInfo *
-getNamespaces(Archive *fout, int *numNamespaces)
+void
+getNamespaces(Archive *fout)
{
PGresult *res;
int ntups;
@@ -5660,10 +5651,6 @@ getNamespaces(Archive *fout, int *numNamespaces)
PQclear(res);
destroyPQExpBuffer(query);
-
- *numNamespaces = ntups;
-
- return nsinfo;
}
/*
@@ -5755,16 +5742,13 @@ getExtensions(Archive *fout, int *numExtensions)
/*
* getTypes:
- * read all types in the system catalogs and return them in the
- * TypeInfo* structure
- *
- * numTypes is set to the number of types read in
+ * get information about all types in the system catalogs
*
* NB: this must run after getFuncs() because we assume we can do
* findFuncByOid().
*/
-TypeInfo *
-getTypes(Archive *fout, int *numTypes)
+void
+getTypes(Archive *fout)
{
PGresult *res;
int ntups;
@@ -5917,24 +5901,17 @@ getTypes(Archive *fout, int *numTypes)
}
}
- *numTypes = ntups;
-
PQclear(res);
destroyPQExpBuffer(query);
-
- return tyinfo;
}
/*
* getOperators:
- * read all operators in the system catalogs and return them in the
- * OprInfo* structure
- *
- * numOprs is set to the number of operators read in
+ * get information about all operators in the system catalogs
*/
-OprInfo *
-getOperators(Archive *fout, int *numOprs)
+void
+getOperators(Archive *fout)
{
PGresult *res;
int ntups;
@@ -5964,7 +5941,6 @@ getOperators(Archive *fout, int *numOprs)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numOprs = ntups;
oprinfo = (OprInfo *) pg_malloc(ntups * sizeof(OprInfo));
@@ -5996,19 +5972,14 @@ getOperators(Archive *fout, int *numOprs)
PQclear(res);
destroyPQExpBuffer(query);
-
- return oprinfo;
}
/*
* getCollations:
- * read all collations in the system catalogs and return them in the
- * CollInfo* structure
- *
- * numCollations is set to the number of collations read in
+ * get information about all collations in the system catalogs
*/
-CollInfo *
-getCollations(Archive *fout, int *numCollations)
+void
+getCollations(Archive *fout)
{
PGresult *res;
int ntups;
@@ -6036,7 +6007,6 @@ getCollations(Archive *fout, int *numCollations)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numCollations = ntups;
collinfo = (CollInfo *) pg_malloc(ntups * sizeof(CollInfo));
@@ -6064,19 +6034,14 @@ getCollations(Archive *fout, int *numCollations)
PQclear(res);
destroyPQExpBuffer(query);
-
- return collinfo;
}
/*
* getConversions:
- * read all conversions in the system catalogs and return them in the
- * ConvInfo* structure
- *
- * numConversions is set to the number of conversions read in
+ * get information about all conversions in the system catalogs
*/
-ConvInfo *
-getConversions(Archive *fout, int *numConversions)
+void
+getConversions(Archive *fout)
{
PGresult *res;
int ntups;
@@ -6104,7 +6069,6 @@ getConversions(Archive *fout, int *numConversions)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numConversions = ntups;
convinfo = (ConvInfo *) pg_malloc(ntups * sizeof(ConvInfo));
@@ -6132,19 +6096,14 @@ getConversions(Archive *fout, int *numConversions)
PQclear(res);
destroyPQExpBuffer(query);
-
- return convinfo;
}
/*
* getAccessMethods:
- * read all user-defined access methods in the system catalogs and return
- * them in the AccessMethodInfo* structure
- *
- * numAccessMethods is set to the number of access methods read in
+ * get information about all user-defined access methods
*/
-AccessMethodInfo *
-getAccessMethods(Archive *fout, int *numAccessMethods)
+void
+getAccessMethods(Archive *fout)
{
PGresult *res;
int ntups;
@@ -6159,10 +6118,7 @@ getAccessMethods(Archive *fout, int *numAccessMethods)
/* Before 9.6, there are no user-defined access methods */
if (fout->remoteVersion < 90600)
- {
- *numAccessMethods = 0;
- return NULL;
- }
+ return;
query = createPQExpBuffer();
@@ -6174,7 +6130,6 @@ getAccessMethods(Archive *fout, int *numAccessMethods)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numAccessMethods = ntups;
aminfo = (AccessMethodInfo *) pg_malloc(ntups * sizeof(AccessMethodInfo));
@@ -6202,20 +6157,15 @@ getAccessMethods(Archive *fout, int *numAccessMethods)
PQclear(res);
destroyPQExpBuffer(query);
-
- return aminfo;
}
/*
* getOpclasses:
- * read all opclasses in the system catalogs and return them in the
- * OpclassInfo* structure
- *
- * numOpclasses is set to the number of opclasses read in
+ * get information about all opclasses in the system catalogs
*/
-OpclassInfo *
-getOpclasses(Archive *fout, int *numOpclasses)
+void
+getOpclasses(Archive *fout)
{
PGresult *res;
int ntups;
@@ -6241,7 +6191,6 @@ getOpclasses(Archive *fout, int *numOpclasses)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numOpclasses = ntups;
opcinfo = (OpclassInfo *) pg_malloc(ntups * sizeof(OpclassInfo));
@@ -6269,19 +6218,14 @@ getOpclasses(Archive *fout, int *numOpclasses)
PQclear(res);
destroyPQExpBuffer(query);
-
- return opcinfo;
}
/*
* getOpfamilies:
- * read all opfamilies in the system catalogs and return them in the
- * OpfamilyInfo* structure
- *
- * numOpfamilies is set to the number of opfamilies read in
+ * get information about all opfamilies in the system catalogs
*/
-OpfamilyInfo *
-getOpfamilies(Archive *fout, int *numOpfamilies)
+void
+getOpfamilies(Archive *fout)
{
PGresult *res;
int ntups;
@@ -6309,7 +6253,6 @@ getOpfamilies(Archive *fout, int *numOpfamilies)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numOpfamilies = ntups;
opfinfo = (OpfamilyInfo *) pg_malloc(ntups * sizeof(OpfamilyInfo));
@@ -6337,19 +6280,14 @@ getOpfamilies(Archive *fout, int *numOpfamilies)
PQclear(res);
destroyPQExpBuffer(query);
-
- return opfinfo;
}
/*
* getAggregates:
- * read all the user-defined aggregates in the system catalogs and
- * return them in the AggInfo* structure
- *
- * numAggs is set to the number of aggregates read in
+ * get information about all user-defined aggregates in the system catalogs
*/
-AggInfo *
-getAggregates(Archive *fout, int *numAggs)
+void
+getAggregates(Archive *fout)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
@@ -6431,7 +6369,6 @@ getAggregates(Archive *fout, int *numAggs)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numAggs = ntups;
agginfo = (AggInfo *) pg_malloc(ntups * sizeof(AggInfo));
@@ -6484,19 +6421,14 @@ getAggregates(Archive *fout, int *numAggs)
PQclear(res);
destroyPQExpBuffer(query);
-
- return agginfo;
}
/*
* getFuncs:
- * read all the user-defined functions in the system catalogs and
- * return them in the FuncInfo* structure
- *
- * numFuncs is set to the number of functions read in
+ * get information about all user-defined functions in the system catalogs
*/
-FuncInfo *
-getFuncs(Archive *fout, int *numFuncs)
+void
+getFuncs(Archive *fout)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
@@ -6629,8 +6561,6 @@ getFuncs(Archive *fout, int *numFuncs)
ntups = PQntuples(res);
- *numFuncs = ntups;
-
finfo = (FuncInfo *) pg_malloc0(ntups * sizeof(FuncInfo));
i_tableoid = PQfnumber(res, "tableoid");
@@ -6683,8 +6613,6 @@ getFuncs(Archive *fout, int *numFuncs)
PQclear(res);
destroyPQExpBuffer(query);
-
- return finfo;
}
/*
@@ -7985,11 +7913,9 @@ getDomainConstraints(Archive *fout, TypeInfo *tyinfo)
/*
* getRules
* get basic information about every rule in the system
- *
- * numRules is set to the number of rules read in
*/
-RuleInfo *
-getRules(Archive *fout, int *numRules)
+void
+getRules(Archive *fout)
{
PGresult *res;
int ntups;
@@ -8015,8 +7941,6 @@ getRules(Archive *fout, int *numRules)
ntups = PQntuples(res);
- *numRules = ntups;
-
ruleinfo = (RuleInfo *) pg_malloc(ntups * sizeof(RuleInfo));
i_tableoid = PQfnumber(res, "tableoid");
@@ -8078,8 +8002,6 @@ getRules(Archive *fout, int *numRules)
PQclear(res);
destroyPQExpBuffer(query);
-
- return ruleinfo;
}
/*
@@ -8285,8 +8207,8 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
* getEventTriggers
* get information about event triggers
*/
-EventTriggerInfo *
-getEventTriggers(Archive *fout, int *numEventTriggers)
+void
+getEventTriggers(Archive *fout)
{
int i;
PQExpBuffer query;
@@ -8304,10 +8226,7 @@ getEventTriggers(Archive *fout, int *numEventTriggers)
/* Before 9.3, there are no event triggers */
if (fout->remoteVersion < 90300)
- {
- *numEventTriggers = 0;
- return NULL;
- }
+ return;
query = createPQExpBuffer();
@@ -8325,8 +8244,6 @@ getEventTriggers(Archive *fout, int *numEventTriggers)
ntups = PQntuples(res);
- *numEventTriggers = ntups;
-
evtinfo = (EventTriggerInfo *) pg_malloc(ntups * sizeof(EventTriggerInfo));
i_tableoid = PQfnumber(res, "tableoid");
@@ -8359,21 +8276,17 @@ getEventTriggers(Archive *fout, int *numEventTriggers)
PQclear(res);
destroyPQExpBuffer(query);
-
- return evtinfo;
}
/*
* getProcLangs
* get basic information about every procedural language in the system
*
- * numProcLangs is set to the number of langs read in
- *
* NB: this must run after getFuncs() because we assume we can do
* findFuncByOid().
*/
-ProcLangInfo *
-getProcLangs(Archive *fout, int *numProcLangs)
+void
+getProcLangs(Archive *fout)
{
PGresult *res;
int ntups;
@@ -8405,8 +8318,6 @@ getProcLangs(Archive *fout, int *numProcLangs)
ntups = PQntuples(res);
- *numProcLangs = ntups;
-
planginfo = (ProcLangInfo *) pg_malloc(ntups * sizeof(ProcLangInfo));
i_tableoid = PQfnumber(res, "tableoid");
@@ -8449,21 +8360,17 @@ getProcLangs(Archive *fout, int *numProcLangs)
PQclear(res);
destroyPQExpBuffer(query);
-
- return planginfo;
}
/*
* getCasts
* get basic information about most casts in the system
*
- * numCasts is set to the number of casts read in
- *
* Skip casts from a range to its multirange, since we'll create those
* automatically.
*/
-CastInfo *
-getCasts(Archive *fout, int *numCasts)
+void
+getCasts(Archive *fout)
{
PGresult *res;
int ntups;
@@ -8503,8 +8410,6 @@ getCasts(Archive *fout, int *numCasts)
ntups = PQntuples(res);
- *numCasts = ntups;
-
castinfo = (CastInfo *) pg_malloc(ntups * sizeof(CastInfo));
i_tableoid = PQfnumber(res, "tableoid");
@@ -8551,8 +8456,6 @@ getCasts(Archive *fout, int *numCasts)
PQclear(res);
destroyPQExpBuffer(query);
-
- return castinfo;
}
static char *
@@ -8575,11 +8478,9 @@ get_language_name(Archive *fout, Oid langid)
/*
* getTransforms
* get basic information about every transform in the system
- *
- * numTransforms is set to the number of transforms read in
*/
-TransformInfo *
-getTransforms(Archive *fout, int *numTransforms)
+void
+getTransforms(Archive *fout)
{
PGresult *res;
int ntups;
@@ -8595,10 +8496,7 @@ getTransforms(Archive *fout, int *numTransforms)
/* Transforms didn't exist pre-9.5 */
if (fout->remoteVersion < 90500)
- {
- *numTransforms = 0;
- return NULL;
- }
+ return;
query = createPQExpBuffer();
@@ -8611,8 +8509,6 @@ getTransforms(Archive *fout, int *numTransforms)
ntups = PQntuples(res);
- *numTransforms = ntups;
-
transforminfo = (TransformInfo *) pg_malloc(ntups * sizeof(TransformInfo));
i_tableoid = PQfnumber(res, "tableoid");
@@ -8658,8 +8554,6 @@ getTransforms(Archive *fout, int *numTransforms)
PQclear(res);
destroyPQExpBuffer(query);
-
- return transforminfo;
}
/*
@@ -9239,13 +9133,10 @@ shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
/*
* getTSParsers:
- * read all text search parsers in the system catalogs and return them
- * in the TSParserInfo* structure
- *
- * numTSParsers is set to the number of parsers read in
+ * get information about all text search parsers in the system catalogs
*/
-TSParserInfo *
-getTSParsers(Archive *fout, int *numTSParsers)
+void
+getTSParsers(Archive *fout)
{
PGresult *res;
int ntups;
@@ -9277,7 +9168,6 @@ getTSParsers(Archive *fout, int *numTSParsers)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numTSParsers = ntups;
prsinfo = (TSParserInfo *) pg_malloc(ntups * sizeof(TSParserInfo));
@@ -9313,19 +9203,14 @@ getTSParsers(Archive *fout, int *numTSParsers)
PQclear(res);
destroyPQExpBuffer(query);
-
- return prsinfo;
}
/*
* getTSDictionaries:
- * read all text search dictionaries in the system catalogs and return them
- * in the TSDictInfo* structure
- *
- * numTSDicts is set to the number of dictionaries read in
+ * get information about all text search dictionaries in the system catalogs
*/
-TSDictInfo *
-getTSDictionaries(Archive *fout, int *numTSDicts)
+void
+getTSDictionaries(Archive *fout)
{
PGresult *res;
int ntups;
@@ -9350,7 +9235,6 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numTSDicts = ntups;
dictinfo = (TSDictInfo *) pg_malloc(ntups * sizeof(TSDictInfo));
@@ -9385,19 +9269,14 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
PQclear(res);
destroyPQExpBuffer(query);
-
- return dictinfo;
}
/*
* getTSTemplates:
- * read all text search templates in the system catalogs and return them
- * in the TSTemplateInfo* structure
- *
- * numTSTemplates is set to the number of templates read in
+ * get information about all text search templates in the system catalogs
*/
-TSTemplateInfo *
-getTSTemplates(Archive *fout, int *numTSTemplates)
+void
+getTSTemplates(Archive *fout)
{
PGresult *res;
int ntups;
@@ -9420,7 +9299,6 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numTSTemplates = ntups;
tmplinfo = (TSTemplateInfo *) pg_malloc(ntups * sizeof(TSTemplateInfo));
@@ -9450,19 +9328,14 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
PQclear(res);
destroyPQExpBuffer(query);
-
- return tmplinfo;
}
/*
* getTSConfigurations:
- * read all text search configurations in the system catalogs and return
- * them in the TSConfigInfo* structure
- *
- * numTSConfigs is set to the number of configurations read in
+ * get information about all text search configurations
*/
-TSConfigInfo *
-getTSConfigurations(Archive *fout, int *numTSConfigs)
+void
+getTSConfigurations(Archive *fout)
{
PGresult *res;
int ntups;
@@ -9485,7 +9358,6 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numTSConfigs = ntups;
cfginfo = (TSConfigInfo *) pg_malloc(ntups * sizeof(TSConfigInfo));
@@ -9515,19 +9387,14 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
PQclear(res);
destroyPQExpBuffer(query);
-
- return cfginfo;
}
/*
* getForeignDataWrappers:
- * read all foreign-data wrappers in the system catalogs and return
- * them in the FdwInfo* structure
- *
- * numForeignDataWrappers is set to the number of fdws read in
+ * get information about all foreign-data wrappers in the system catalogs
*/
-FdwInfo *
-getForeignDataWrappers(Archive *fout, int *numForeignDataWrappers)
+void
+getForeignDataWrappers(Archive *fout)
{
PGresult *res;
int ntups;
@@ -9563,7 +9430,6 @@ getForeignDataWrappers(Archive *fout, int *numForeignDataWrappers)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numForeignDataWrappers = ntups;
fdwinfo = (FdwInfo *) pg_malloc(ntups * sizeof(FdwInfo));
@@ -9605,19 +9471,14 @@ getForeignDataWrappers(Archive *fout, int *numForeignDataWrappers)
PQclear(res);
destroyPQExpBuffer(query);
-
- return fdwinfo;
}
/*
* getForeignServers:
- * read all foreign servers in the system catalogs and return
- * them in the ForeignServerInfo * structure
- *
- * numForeignServers is set to the number of servers read in
+ * get information about all foreign servers in the system catalogs
*/
-ForeignServerInfo *
-getForeignServers(Archive *fout, int *numForeignServers)
+void
+getForeignServers(Archive *fout)
{
PGresult *res;
int ntups;
@@ -9652,7 +9513,6 @@ getForeignServers(Archive *fout, int *numForeignServers)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numForeignServers = ntups;
srvinfo = (ForeignServerInfo *) pg_malloc(ntups * sizeof(ForeignServerInfo));
@@ -9699,19 +9559,14 @@ getForeignServers(Archive *fout, int *numForeignServers)
PQclear(res);
destroyPQExpBuffer(query);
-
- return srvinfo;
}
/*
* getDefaultACLs:
- * read all default ACL information in the system catalogs and return
- * them in the DefaultACLInfo structure
- *
- * numDefaultACLs is set to the number of ACLs read in
+ * get information about all default ACL information in the system catalogs
*/
-DefaultACLInfo *
-getDefaultACLs(Archive *fout, int *numDefaultACLs)
+void
+getDefaultACLs(Archive *fout)
{
DumpOptions *dopt = fout->dopt;
DefaultACLInfo *daclinfo;
@@ -9756,7 +9611,6 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs)
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
- *numDefaultACLs = ntups;
daclinfo = (DefaultACLInfo *) pg_malloc(ntups * sizeof(DefaultACLInfo));
@@ -9801,8 +9655,6 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs)
PQclear(res);
destroyPQExpBuffer(query);
-
- return daclinfo;
}
/*