We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentf25e5e5 commit1aa1175Copy full SHA for 1aa1175
contrib/pg_upgrade/tablespace.c
@@ -38,7 +38,6 @@ get_tablespace_paths(migratorContext *ctx)
38
{
39
PGconn*conn=connectToServer(ctx,"template1",CLUSTER_OLD);
40
PGresult*res;
41
-intntups;
42
inttblnum;
43
inti_spclocation;
44
@@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx)
48
47
"WHEREspcname != 'pg_default' AND "
49
"spcname != 'pg_global'");
50
51
-ctx->num_tablespaces=ntups=PQntuples(res);
52
-ctx->tablespaces= (char**)pg_malloc(ctx,ntups*sizeof(char*));
+if ((ctx->num_tablespaces=PQntuples(res))!=0)
+ctx->tablespaces= (char**)pg_malloc(ctx,
+ctx->num_tablespaces*sizeof(char*));
53
+else
54
+ctx->tablespaces=NULL;
55
56
i_spclocation=PQfnumber(res,"spclocation");
57
-for (tblnum=0;tblnum<ntups;tblnum++)
58
+for (tblnum=0;tblnum<ctx->num_tablespaces;tblnum++)
59
ctx->tablespaces[tblnum]=pg_strdup(ctx,
60
PQgetvalue(res,tblnum,i_spclocation));
61