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)
38
38
{
39
39
PGconn * conn = connectToServer (ctx , "template1" , CLUSTER_OLD );
40
40
PGresult * res ;
41
- int ntups ;
42
41
int tblnum ;
43
42
int i_spclocation ;
44
43
@@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx)
48
47
"WHERE spcname != 'pg_default' AND "
49
48
" spcname != 'pg_global'" );
50
49
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 ;
53
55
54
56
i_spclocation = PQfnumber (res , "spclocation" );
55
57
56
- for (tblnum = 0 ; tblnum < ntups ; tblnum ++ )
58
+ for (tblnum = 0 ; tblnum < ctx -> num_tablespaces ; tblnum ++ )
57
59
ctx -> tablespaces [tblnum ] = pg_strdup (ctx ,
58
60
PQgetvalue (res , tblnum , i_spclocation ));
59
61
You can’t perform that action at this time.
0 commit comments