*** pgsql/contrib/pg_upgrade/tablespace.c 2010/05/12 02:19:11 1.1 --- pgsql/contrib/pg_upgrade/tablespace.c 2010/06/16 19:43:11 1.2 *************** get_tablespace_paths(migratorContext *ct *** 38,44 **** { PGconn *conn = connectToServer(ctx, "template1", CLUSTER_OLD); PGresult *res; - int ntups; int tblnum; int i_spclocation; --- 38,43 ---- *************** get_tablespace_paths(migratorContext *ct *** 48,59 **** "WHERE spcname != 'pg_default' AND " " spcname != 'pg_global'"); ! ctx->num_tablespaces = ntups = PQntuples(res); ! ctx->tablespaces = (char **) pg_malloc(ctx, ntups * sizeof(char *)); i_spclocation = PQfnumber(res, "spclocation"); ! for (tblnum = 0; tblnum < ntups; tblnum++) ctx->tablespaces[tblnum] = pg_strdup(ctx, PQgetvalue(res, tblnum, i_spclocation)); --- 47,61 ---- "WHERE spcname != 'pg_default' AND " " spcname != 'pg_global'"); ! if ((ctx->num_tablespaces = PQntuples(res)) != 0) ! ctx->tablespaces = (char **) pg_malloc(ctx, ! ctx->num_tablespaces * sizeof(char *)); ! else ! ctx->tablespaces = NULL; i_spclocation = PQfnumber(res, "spclocation"); ! for (tblnum = 0; tblnum < ctx->num_tablespaces; tblnum++) ctx->tablespaces[tblnum] = pg_strdup(ctx, PQgetvalue(res, tblnum, i_spclocation));