PG15: update integer parsing APIs.

Account for PG commits 3c6f8c011f and cfc7191dfe.
pull/5920/head
Jeff Davis 2022-04-09 21:34:39 -07:00 committed by jeff-davis
parent 70c915a0f2
commit 26f5e20580
9 changed files with 26 additions and 11 deletions

View File

@ -490,7 +490,7 @@ GetDistributionArgIndex(Oid functionOid, char *distributionArgumentName,
distributionArgumentName++;
/* throws error if the input is not an integer */
distributionArgumentIndex = pg_atoi(distributionArgumentName, 4, 0);
distributionArgumentIndex = pg_strtoint32(distributionArgumentName);
if (distributionArgumentIndex < 1 || distributionArgumentIndex > numberOfArgs)
{

View File

@ -171,7 +171,6 @@
#include "storage/fd.h"
#include "storage/latch.h"
#include "utils/builtins.h"
#include "utils/int8.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/syscache.h"
@ -4513,7 +4512,7 @@ ReceiveResults(WorkerSession *session, bool storeRows)
/* if there are multiple replicas, make sure to consider only one */
if (storeRows && *currentAffectedTupleString != '\0')
{
scanint8(currentAffectedTupleString, false, &currentAffectedTupleCount);
currentAffectedTupleCount = pg_strtoint64(currentAffectedTupleString);
Assert(currentAffectedTupleCount >= 0);
execution->rowsProcessed += currentAffectedTupleCount;
}

View File

@ -54,7 +54,6 @@
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/int8.h"
#include "utils/json.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
@ -1396,9 +1395,9 @@ GetShardStatistics(MultiConnection *connection, HTAB *shardIds)
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
char *shardIdString = PQgetvalue(result, rowIndex, 0);
uint64 shardId = pg_strtouint64(shardIdString, NULL, 10);
uint64 shardId = strtou64(shardIdString, NULL, 10);
char *sizeString = PQgetvalue(result, rowIndex, 1);
uint64 totalSize = pg_strtouint64(sizeString, NULL, 10);
uint64 totalSize = strtou64(sizeString, NULL, 10);
ShardStatistics *statistics =
hash_search(shardStatistics, &shardId, HASH_ENTER, NULL);

View File

@ -923,7 +923,7 @@ WorkerShardStats(ShardPlacement *placement, Oid relationId, const char *shardNam
}
errno = 0;
uint64 tableSize = pg_strtouint64(tableSizeString, &tableSizeStringEnd, 0);
uint64 tableSize = strtou64(tableSizeString, &tableSizeStringEnd, 0);
if (errno != 0 || (*tableSizeStringEnd) != '\0')
{
PQclear(queryResult);

View File

@ -28,7 +28,6 @@
#include "funcapi.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/int8.h"
#include "utils/json.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"

View File

@ -309,7 +309,7 @@ ParseIntField(PGresult *result, int rowIndex, int colIndex)
char *resultString = PQgetvalue(result, rowIndex, colIndex);
return pg_strtouint64(resultString, NULL, 10);
return strtou64(resultString, NULL, 10);
}

View File

@ -1408,7 +1408,7 @@ ParsePreparedTransactionName(char *preparedTransactionName,
/* step ahead of the current '_' character */
++currentCharPointer;
*transactionNumber = pg_strtouint64(currentCharPointer, NULL, 10);
*transactionNumber = strtou64(currentCharPointer, NULL, 10);
if ((*transactionNumber == 0 && errno != 0) ||
(*transactionNumber == ULLONG_MAX && errno == ERANGE))
{

View File

@ -387,7 +387,7 @@ ExtractShardIdFromTableName(const char *tableName, bool missingOk)
shardIdString++;
errno = 0;
uint64 shardId = pg_strtouint64(shardIdString, &shardIdStringEnd, 0);
uint64 shardId = strtou64(shardIdString, &shardIdStringEnd, 0);
if (errno != 0 || (*shardIdStringEnd != '\0'))
{

View File

@ -19,10 +19,28 @@
#else
#include "storage/smgr.h"
#include "utils/int8.h"
#include "utils/rel.h"
#ifdef HAVE_LONG_INT_64
#define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base))
#define strtou64(str, endptr, base) ((uint64) strtoul(str, endptr, base))
#else
#define strtoi64(str, endptr, base) ((int64) strtoll(str, endptr, base))
#define strtou64(str, endptr, base) ((uint64) strtoull(str, endptr, base))
#endif
#define RelationCreateStorage_compat(a, b, c) RelationCreateStorage(a, b)
static inline int64
pg_strtoint64(char *s)
{
int64 result;
(void) scanint8(s, false, &result);
return result;
}
static inline SMgrRelation
RelationGetSmgr(Relation rel)
{