mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
pg_dump: Fix some minor memory leaks
Although we often don't care about freeing all memory in pg_dump, these functions already freed the same memory in other code paths, so we might as well do it consistently. found by Coverity
This commit is contained in:
parent
5cd72c7a7c
commit
acfaa596cc
@ -3169,7 +3169,7 @@ getCollations(Archive *fout, int *numCollations)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
int i;
|
int i;
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query;
|
||||||
CollInfo *collinfo;
|
CollInfo *collinfo;
|
||||||
int i_tableoid;
|
int i_tableoid;
|
||||||
int i_oid;
|
int i_oid;
|
||||||
@ -3184,6 +3184,8 @@ getCollations(Archive *fout, int *numCollations)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find all collations, including builtin collations; we filter out
|
* find all collations, including builtin collations; we filter out
|
||||||
* system-defined collations at dump-out time.
|
* system-defined collations at dump-out time.
|
||||||
@ -6167,7 +6169,7 @@ getTSParsers(Archive *fout, int *numTSParsers)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
int i;
|
int i;
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query;
|
||||||
TSParserInfo *prsinfo;
|
TSParserInfo *prsinfo;
|
||||||
int i_tableoid;
|
int i_tableoid;
|
||||||
int i_oid;
|
int i_oid;
|
||||||
@ -6186,6 +6188,8 @@ getTSParsers(Archive *fout, int *numTSParsers)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find all text search objects, including builtin ones; we filter out
|
* find all text search objects, including builtin ones; we filter out
|
||||||
* system-defined objects at dump-out time.
|
* system-defined objects at dump-out time.
|
||||||
@ -6257,7 +6261,7 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
int i;
|
int i;
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query;
|
||||||
TSDictInfo *dictinfo;
|
TSDictInfo *dictinfo;
|
||||||
int i_tableoid;
|
int i_tableoid;
|
||||||
int i_oid;
|
int i_oid;
|
||||||
@ -6274,6 +6278,8 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/* Make sure we are in proper schema */
|
/* Make sure we are in proper schema */
|
||||||
selectSourceSchema(fout, "pg_catalog");
|
selectSourceSchema(fout, "pg_catalog");
|
||||||
|
|
||||||
@ -6340,7 +6346,7 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
int i;
|
int i;
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query;
|
||||||
TSTemplateInfo *tmplinfo;
|
TSTemplateInfo *tmplinfo;
|
||||||
int i_tableoid;
|
int i_tableoid;
|
||||||
int i_oid;
|
int i_oid;
|
||||||
@ -6356,6 +6362,8 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/* Make sure we are in proper schema */
|
/* Make sure we are in proper schema */
|
||||||
selectSourceSchema(fout, "pg_catalog");
|
selectSourceSchema(fout, "pg_catalog");
|
||||||
|
|
||||||
@ -6415,7 +6423,7 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
int ntups;
|
||||||
int i;
|
int i;
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query;
|
||||||
TSConfigInfo *cfginfo;
|
TSConfigInfo *cfginfo;
|
||||||
int i_tableoid;
|
int i_tableoid;
|
||||||
int i_oid;
|
int i_oid;
|
||||||
@ -6431,6 +6439,8 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/* Make sure we are in proper schema */
|
/* Make sure we are in proper schema */
|
||||||
selectSourceSchema(fout, "pg_catalog");
|
selectSourceSchema(fout, "pg_catalog");
|
||||||
|
|
||||||
@ -9467,16 +9477,18 @@ dumpCast(Archive *fout, CastInfo *cast)
|
|||||||
appendPQExpBuffer(defqry, "WITH INOUT");
|
appendPQExpBuffer(defqry, "WITH INOUT");
|
||||||
break;
|
break;
|
||||||
case COERCION_METHOD_FUNCTION:
|
case COERCION_METHOD_FUNCTION:
|
||||||
|
{
|
||||||
|
char *fsig = format_function_signature(fout, funcInfo, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Always qualify the function name, in case it is not in
|
* Always qualify the function name, in case it is not in
|
||||||
* pg_catalog schema (format_function_signature won't qualify it).
|
* pg_catalog schema (format_function_signature won't qualify it).
|
||||||
*/
|
*/
|
||||||
appendPQExpBuffer(defqry, "WITH FUNCTION %s.",
|
appendPQExpBuffer(defqry, "WITH FUNCTION %s.%s",
|
||||||
fmtId(funcInfo->dobj.namespace->dobj.name));
|
fmtId(funcInfo->dobj.namespace->dobj.name), fsig);
|
||||||
appendPQExpBuffer(defqry, "%s",
|
free(fsig);
|
||||||
format_function_signature(fout, funcInfo, true));
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
write_msg(NULL, "WARNING: bogus value in pg_cast.castmethod field\n");
|
write_msg(NULL, "WARNING: bogus value in pg_cast.castmethod field\n");
|
||||||
}
|
}
|
||||||
|
@ -1525,12 +1525,17 @@ makeAlterConfigCommand(PGconn *conn, const char *arrayitem,
|
|||||||
{
|
{
|
||||||
char *pos;
|
char *pos;
|
||||||
char *mine;
|
char *mine;
|
||||||
PQExpBuffer buf = createPQExpBuffer();
|
PQExpBuffer buf;
|
||||||
|
|
||||||
mine = pg_strdup(arrayitem);
|
mine = pg_strdup(arrayitem);
|
||||||
pos = strchr(mine, '=');
|
pos = strchr(mine, '=');
|
||||||
if (pos == NULL)
|
if (pos == NULL)
|
||||||
|
{
|
||||||
|
free(mine);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = createPQExpBuffer();
|
||||||
|
|
||||||
*pos = 0;
|
*pos = 0;
|
||||||
appendPQExpBuffer(buf, "ALTER %s %s ", type, fmtId(name));
|
appendPQExpBuffer(buf, "ALTER %s %s ", type, fmtId(name));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user