From 23a27b039d94ba359286694831eafe03cd970eef Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 12 Mar 2016 16:05:10 -0500 Subject: Widen query numbers-of-tuples-processed counters to uint64. This patch widens SPI_processed, EState's es_processed field, PortalData's portalPos field, FuncCallContext's call_cntr and max_calls fields, ExecutorRun's count argument, PortalRunFetch's result, and the max number of rows in a SPITupleTable to uint64, and deals with (I hope) all the ensuing fallout. Some of these values were declared uint32 before, and others "long". I also removed PortalData's posOverflow field, since that logic seems pretty useless given that portalPos is now always 64 bits. The user-visible results are that command tags for SELECT etc will correctly report tuple counts larger than 4G, as will plpgsql's GET GET DIAGNOSTICS ... ROW_COUNT command. Queries processing more tuples than that are still not exactly the norm, but they're becoming more common. Most values associated with FETCH/MOVE distances, such as PortalRun's count argument and the count argument of most SPI functions that have one, remain declared as "long". It's not clear whether it would be worth promoting those to int64; but it would definitely be a large dollop of additional API churn on top of this, and it would only help 32-bit platforms which seem relatively less likely to see any benefit. Andreas Scherbaum, reviewed by Christian Ullrich, additional hacking by me --- src/backend/utils/adt/numutils.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/backend/utils/adt/numutils.c') diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index 6b105964bd1..da100f7c0f2 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -388,3 +388,25 @@ pg_ltostr(char *str, int32 value) return end; } + +/* + * pg_strtouint64 + * Converts 'str' into an unsigned 64-bit integer. + * + * This has the identical API to strtoul(3), except that it will handle + * 64-bit ints even where "long" is narrower than that. + * + * For the moment it seems sufficient to assume that the platform has + * such a function somewhere; let's not roll our own. + */ +uint64 +pg_strtouint64(const char *str, char **endptr, int base) +{ +#ifdef WIN32 + return _strtoui64(str, endptr, base); +#elif defined(HAVE_STRTOULL) && SIZEOF_LONG < 8 + return strtoull(str, endptr, base); +#else + return strtoul(str, endptr, base); +#endif +} -- cgit v1.2.3