File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ get_tablespace_paths(migratorContext *ctx)
3838{
3939 PGconn * conn = connectToServer (ctx , "template1" , CLUSTER_OLD );
4040 PGresult * res ;
41- int ntups ;
4241 int tblnum ;
4342 int i_spclocation ;
4443
@@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx)
4847 "WHERE spcname != 'pg_default' AND "
4948 " spcname != 'pg_global'" );
5049
51- ctx -> num_tablespaces = ntups = PQntuples (res );
52- ctx -> tablespaces = (char * * ) pg_malloc (ctx , ntups * sizeof (char * ));
50+ if ((ctx -> num_tablespaces = PQntuples (res )) != 0 )
51+ ctx -> tablespaces = (char * * ) pg_malloc (ctx ,
52+ ctx -> num_tablespaces * sizeof (char * ));
53+ else
54+ ctx -> tablespaces = NULL ;
5355
5456 i_spclocation = PQfnumber (res , "spclocation" );
5557
56- for (tblnum = 0 ; tblnum < ntups ; tblnum ++ )
58+ for (tblnum = 0 ; tblnum < ctx -> num_tablespaces ; tblnum ++ )
5759 ctx -> tablespaces [tblnum ] = pg_strdup (ctx ,
5860 PQgetvalue (res , tblnum , i_spclocation ));
5961
You can’t perform that action at this time.
0 commit comments