pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Simplify the general-purpose 64-bit integer parsing APIs
Date: Fri, 17 Dec 2021 05:44:59 +0000
Message-ID: <E1my639-0001RZ-34@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1my639-0001RZ-34@gemulon.postgresql.org>
Permalink:  ../E1my639-0001RZ-34@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1my639-0001RZ-34@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: Simplify the general-purpose 64-bit integer parsing APIs
  In-Reply-To: <E1my639-0001RZ-34@gemulon.postgresql.org>
  References: <E1my639-0001RZ-34@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox