Skip to content

Commit 807005c

Browse files
committed
Use macro atooid() for conversion of strings to oids, per suggestion
from Tom.
1 parent 5ac144d commit 807005c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

contrib/pg_upgrade/info.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ get_db_infos(migratorContext *ctx, DbInfoArr *dbinfs_arr, Cluster whichCluster)
242242

243243
for (tupnum = 0; tupnum < ntups; tupnum++)
244244
{
245-
dbinfos[tupnum].db_oid = str2uint(PQgetvalue(res, tupnum, i_oid));
245+
dbinfos[tupnum].db_oid = atooid(PQgetvalue(res, tupnum, i_oid));
246246

247247
snprintf(dbinfos[tupnum].db_name, sizeof(dbinfos[tupnum].db_name), "%s",
248248
PQgetvalue(res, tupnum, i_datname));
@@ -360,16 +360,16 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
360360
RelInfo *curr = &relinfos[num_rels++];
361361
const char *tblspace;
362362

363-
curr->reloid = str2uint(PQgetvalue(res, relnum, i_oid));
363+
curr->reloid = atooid(PQgetvalue(res, relnum, i_oid));
364364

365365
nspname = PQgetvalue(res, relnum, i_nspname);
366366
strlcpy(curr->nspname, nspname, sizeof(curr->nspname));
367367

368368
relname = PQgetvalue(res, relnum, i_relname);
369369
strlcpy(curr->relname, relname, sizeof(curr->relname));
370370

371-
curr->relfilenode = str2uint(PQgetvalue(res, relnum, i_relfilenode));
372-
curr->toastrelid = str2uint(PQgetvalue(res, relnum, i_reltoastrelid));
371+
curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode));
372+
curr->toastrelid = atooid(PQgetvalue(res, relnum, i_reltoastrelid));
373373

374374
tblspace = PQgetvalue(res, relnum, i_spclocation);
375375
/* if no table tablespace, use the database tablespace */

contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
#define CLUSTERNAME(cluster) ((cluster) == CLUSTER_OLD ? "old" : "new")
5454

55+
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
56+
5557
/* OID system catalog preservation added during PG 9.0 development */
5658
#define TABLE_SPACE_SUBDIRS 201001111
5759

contrib/pg_upgrade/relfilenode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ get_pg_database_relfilenode(migratorContext *ctx, Cluster whichCluster)
9494

9595
i_relfile = PQfnumber(res, "relfilenode");
9696
if (whichCluster == CLUSTER_OLD)
97-
ctx->old.pg_database_oid = str2uint(PQgetvalue(res, 0, i_relfile));
97+
ctx->old.pg_database_oid = atooid(PQgetvalue(res, 0, i_relfile));
9898
else
99-
ctx->new.pg_database_oid = str2uint(PQgetvalue(res, 0, i_relfile));
99+
ctx->new.pg_database_oid = atooid(PQgetvalue(res, 0, i_relfile));
100100

101101
PQclear(res);
102102
PQfinish(conn);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy