mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Fix pg_upgrade to remove malloc(0) call.
This commit is contained in:
parent
f25e5e5d47
commit
1aa117506d
@ -38,7 +38,6 @@ get_tablespace_paths(migratorContext *ctx)
|
|||||||
{
|
{
|
||||||
PGconn *conn = connectToServer(ctx, "template1", CLUSTER_OLD);
|
PGconn *conn = connectToServer(ctx, "template1", CLUSTER_OLD);
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
int ntups;
|
|
||||||
int tblnum;
|
int tblnum;
|
||||||
int i_spclocation;
|
int i_spclocation;
|
||||||
|
|
||||||
@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx)
|
|||||||
"WHERE spcname != 'pg_default' AND "
|
"WHERE spcname != 'pg_default' AND "
|
||||||
" spcname != 'pg_global'");
|
" spcname != 'pg_global'");
|
||||||
|
|
||||||
ctx->num_tablespaces = ntups = PQntuples(res);
|
if ((ctx->num_tablespaces = PQntuples(res)) != 0)
|
||||||
ctx->tablespaces = (char **) pg_malloc(ctx, ntups * sizeof(char *));
|
ctx->tablespaces = (char **) pg_malloc(ctx,
|
||||||
|
ctx->num_tablespaces * sizeof(char *));
|
||||||
|
else
|
||||||
|
ctx->tablespaces = NULL;
|
||||||
|
|
||||||
i_spclocation = PQfnumber(res, "spclocation");
|
i_spclocation = PQfnumber(res, "spclocation");
|
||||||
|
|
||||||
for (tblnum = 0; tblnum < ntups; tblnum++)
|
for (tblnum = 0; tblnum < ctx->num_tablespaces; tblnum++)
|
||||||
ctx->tablespaces[tblnum] = pg_strdup(ctx,
|
ctx->tablespaces[tblnum] = pg_strdup(ctx,
|
||||||
PQgetvalue(res, tblnum, i_spclocation));
|
PQgetvalue(res, tblnum, i_spclocation));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user