From fb7b86fa14d024a6871a5b2efade2fef8311f505 Mon Sep 17 00:00:00 2001 From: Brian Cloutier Date: Mon, 20 Nov 2017 19:04:38 -0800 Subject: [PATCH] Replace strtoull with pg_strtouint64 The macro we were using to detect strtoull isn't set on Windows, and just in case there are differences use a portable function from PG instead of calling strtoull directly. --- src/backend/distributed/master/master_stage_protocol.c | 2 +- src/backend/distributed/utils/citus_readfuncs.c | 3 ++- .../distributed/worker/worker_data_fetch_protocol.c | 7 +------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/backend/distributed/master/master_stage_protocol.c b/src/backend/distributed/master/master_stage_protocol.c index 2f964d603..d39b46446 100644 --- a/src/backend/distributed/master/master_stage_protocol.c +++ b/src/backend/distributed/master/master_stage_protocol.c @@ -839,7 +839,7 @@ WorkerShardStats(ShardPlacement *placement, Oid relationId, char *shardName, } errno = 0; - tableSize = strtoull(tableSizeString, &tableSizeStringEnd, 0); + tableSize = pg_strtouint64(tableSizeString, &tableSizeStringEnd, 0); if (errno != 0 || (*tableSizeStringEnd) != '\0') { PQclear(queryResult); diff --git a/src/backend/distributed/utils/citus_readfuncs.c b/src/backend/distributed/utils/citus_readfuncs.c index 4e8ddb1ef..a06577477 100644 --- a/src/backend/distributed/utils/citus_readfuncs.c +++ b/src/backend/distributed/utils/citus_readfuncs.c @@ -19,6 +19,7 @@ #include "distributed/multi_server_executor.h" #include "nodes/parsenodes.h" #include "nodes/readfuncs.h" +#include "utils/builtins.h" /* @@ -158,7 +159,7 @@ CitusSetTag(Node *node, int tag) #define atooid(x) ((Oid) strtoul((x), NULL, 10)) /* XXX: Citus */ -#define atoull(x) ((uint64) strtoull((x), NULL, 10)) +#define atoull(x) ((uint64) pg_strtouint64((x), NULL, 10)) #define strtobool(x) ((*(x) == 't') ? true : false) diff --git a/src/backend/distributed/worker/worker_data_fetch_protocol.c b/src/backend/distributed/worker/worker_data_fetch_protocol.c index fdb82c56c..41b1c8635 100644 --- a/src/backend/distributed/worker/worker_data_fetch_protocol.c +++ b/src/backend/distributed/worker/worker_data_fetch_protocol.c @@ -784,19 +784,14 @@ ExtractShardId(const char *tableName) } shardIdString++; -#ifdef HAVE_STRTOULL errno = 0; - shardId = strtoull(shardIdString, &shardIdStringEnd, 0); + shardId = pg_strtouint64(shardIdString, &shardIdStringEnd, 0); if (errno != 0 || (*shardIdStringEnd != '\0')) { ereport(ERROR, (errmsg("could not extract shardId from table name \"%s\"", tableName))); } -#else - ereport(ERROR, (errmsg("could not extract shardId from table name"), - errhint("Your platform does not support strtoull()"))); -#endif return shardId; }