9.0 beta2 pg_upgrade: malloc 0 bytes patch - Mailing list pgsql-hackers

From Steve Singer
Subject 9.0 beta2 pg_upgrade: malloc 0 bytes patch
Date
Msg-id 4C18EBB6.6020700@ca.afilias.info
Whole thread Raw
Responses Re: 9.0 beta2 pg_upgrade: malloc 0 bytes patch  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Running pg_upgrade against an unmodified (the output of initdb) cluster
on AIX is giving me  "pg_alloc: Out of memory" errors.

On some non-linux platforms (including AIX) malloc(0) returns 0.

with the attached patch to pg_upgrade I am now able to get pg_upgrade to
convert an 8.3 database consisting of a single table to 9.0 on an AIX
server.




--
Steve Singer
Afilias Canada
Data Services Developer
416-673-1142
diff --git a/contrib/pg_upgrade/tablespace.c b/contrib/pg_upgrade/tablespace.c
index 302eb0d..99a97e4 100644
--- a/contrib/pg_upgrade/tablespace.c
+++ b/contrib/pg_upgrade/tablespace.c
@@ -49,7 +49,10 @@ get_tablespace_paths(migratorContext *ctx)
                             "        spcname != 'pg_global'");

     ctx->num_tablespaces = ntups = PQntuples(res);
-    ctx->tablespaces = (char **) pg_malloc(ctx, ntups * sizeof(char *));
+    if( ntups > 0 )
+        ctx->tablespaces = (char **) pg_malloc(ctx, ntups * sizeof(char *));
+    else
+        ctx->tablespaces=0;

     i_spclocation = PQfnumber(res, "spclocation");

--
1.6.3.3


pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Patch to show individual statement latencies in pgbench output
Next
From: "Joshua D. Drake"
Date:
Subject: Re: ANNOUNCE list (was Re: New PGXN Extension site)