Thread: pgsql: Simplify the general-purpose 64-bit integer parsing APIs

pgsql: Simplify the general-purpose 64-bit integer parsing APIs

From
Peter Eisentraut
Date:
Simplify the general-purpose 64-bit integer parsing APIs

pg_strtouint64() is a wrapper around strtoull/strtoul/_strtoui64, but
it seems no longer necessary to have this indirection.
msvc/Solution.pm claims HAVE_STRTOULL, so the "MSVC only" part seems
unnecessary.  Also, we have code in c.h to substitute alternatives for
strtoull() if not found, and that would appear to cover all currently
supported platforms, so having a further fallback in pg_strtouint64()
seems unnecessary.

Therefore, we could remove pg_strtouint64(), and use strtoull()
directly in all call sites.  However, it seems useful to keep a
separate notation for parsing exactly 64-bit integers, matching the
type definition int64/uint64.  For that, add new macros strtoi64() and
strtou64() in c.h as thin wrappers around strtol()/strtoul() or
strtoll()/stroull().  This makes these functions available everywhere
instead of just in the server code, and it makes the function naming
notably different from the pg_strtointNN() functions in numutils.c,
which have a different API.

Discussion: https://www.postgresql.org/message-id/flat/a3df47c9-b1b4-29f2-7e91-427baf8b75a3%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3c6f8c011f85df7b35c32f4ccaac5c86c9064a4a

Modified Files
--------------
src/backend/nodes/readfuncs.c     |  2 +-
src/backend/utils/adt/numutils.c  | 22 ----------------------
src/backend/utils/adt/xid.c       |  2 +-
src/backend/utils/adt/xid8funcs.c |  6 +++---
src/backend/utils/misc/guc.c      |  2 +-
src/include/c.h                   | 13 +++++++++++++
src/include/utils/builtins.h      |  1 -
7 files changed, 19 insertions(+), 29 deletions(-)