Use macro atooid() for conversion of strings to oids, per suggestion
authorBruce Momjian <[email protected]>
Tue, 28 Sep 2010 22:11:21 +0000 (22:11 +0000)
committerBruce Momjian <[email protected]>
Tue, 28 Sep 2010 22:11:21 +0000 (22:11 +0000)
from Tom.

contrib/pg_upgrade/info.c
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/relfilenode.c

index e6cec15cfa0e9b5c1d0be95c6b6c9ebb5ce6d8c5..33ff52c68581f77c0226942306b8d68b5a4c105d 100644 (file)
@@ -242,7 +242,7 @@ get_db_infos(migratorContext *ctx, DbInfoArr *dbinfs_arr, Cluster whichCluster)
 
        for (tupnum = 0; tupnum < ntups; tupnum++)
        {
-               dbinfos[tupnum].db_oid = str2uint(PQgetvalue(res, tupnum, i_oid));
+               dbinfos[tupnum].db_oid = atooid(PQgetvalue(res, tupnum, i_oid));
 
                snprintf(dbinfos[tupnum].db_name, sizeof(dbinfos[tupnum].db_name), "%s",
                                 PQgetvalue(res, tupnum, i_datname));
@@ -360,7 +360,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
                RelInfo    *curr = &relinfos[num_rels++];
                const char *tblspace;
 
-               curr->reloid = str2uint(PQgetvalue(res, relnum, i_oid));
+               curr->reloid = atooid(PQgetvalue(res, relnum, i_oid));
 
                nspname = PQgetvalue(res, relnum, i_nspname);
                strlcpy(curr->nspname, nspname, sizeof(curr->nspname));
@@ -368,8 +368,8 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
                relname = PQgetvalue(res, relnum, i_relname);
                strlcpy(curr->relname, relname, sizeof(curr->relname));
 
-               curr->relfilenode = str2uint(PQgetvalue(res, relnum, i_relfilenode));
-               curr->toastrelid = str2uint(PQgetvalue(res, relnum, i_reltoastrelid));
+               curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode));
+               curr->toastrelid = atooid(PQgetvalue(res, relnum, i_reltoastrelid));
 
                tblspace = PQgetvalue(res, relnum, i_spclocation);
                /* if no table tablespace, use the database tablespace */
index 7949f367ec94a6b2c40359d7f9398c2044a78ce5..79a49bc052acdeb2f032f55be64f67289075e348 100644 (file)
@@ -52,6 +52,8 @@
 
 #define CLUSTERNAME(cluster)   ((cluster) == CLUSTER_OLD ? "old" : "new")
 
+#define atooid(x)  ((Oid) strtoul((x), NULL, 10))
+
 /* OID system catalog preservation added during PG 9.0 development */
 #define TABLE_SPACE_SUBDIRS 201001111
 
index 3c1b13a3fa96b6a598b41c60c4dee07f18fba527..de81053241e64614fe8c1f59c40d3aeb9cd565f7 100644 (file)
@@ -94,9 +94,9 @@ get_pg_database_relfilenode(migratorContext *ctx, Cluster whichCluster)
 
        i_relfile = PQfnumber(res, "relfilenode");
        if (whichCluster == CLUSTER_OLD)
-               ctx->old.pg_database_oid = str2uint(PQgetvalue(res, 0, i_relfile));
+               ctx->old.pg_database_oid = atooid(PQgetvalue(res, 0, i_relfile));
        else
-               ctx->new.pg_database_oid = str2uint(PQgetvalue(res, 0, i_relfile));
+               ctx->new.pg_database_oid = atooid(PQgetvalue(res, 0, i_relfile));
 
        PQclear(res);
        PQfinish(conn);