64 bit numbers vs format strings
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Peter Eisentraut <peter@eisentraut.org>
Date: 2024-12-05T22:18:25Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Cast result of i64abs() back to int64
- 2247281c4705 18.0 landed
Attachments
- 0001-Use-PRI-64-instead-of-ll-in-format-strings.patch (text/x-patch) patch 0001
- 0002-pgbench-Make-set_random_seed-64-bit-everywhere.patch (text/x-patch) patch 0002
- 0003-pgbench-Rationalize-types-in-parseScriptWeight.patch (text/x-patch) patch 0003
- 0004-pgbench-Modernize-integer-parsing-routine.patch (text/x-patch) patch 0004
Hi,
Having learned some things about gettext based on clues[1] from Peter
E, I decided to see what it would take to expunge all (long long) and
similar casts now that we're using the standard types with system
support.
The short version is tha given uint64 x:
Old: errmsg("hello %llu", (unsigned long long) x)
New: errmsg("hello %" PRIu64, x)
(And all other printf-like interfaces). That d can be x, X, u, etc
and you can put the usual stuff between % and the macro, so it's cut
up slightly differently than our own macros for that stuff.
You can't make your own macros for this, if you want to localise it at
least, because gettext() and the tools that scan your source tree only
treat the ones from <inttypes.h> specially.
65 files changed, 358 insertions(+), 367 deletions(-)
(Not counting the pgbench bits, that's non mechanical.)
Thoughts? I know it's a fair bit of code churn, but not quite as bad
as I was expecting. It would create an occasional back-patching
speed-bump, but it's mechanical at least. I wonder how often bug
fixes could conflict with this stuff. And no doubt .po file churn ...
I don't know what tooling is used for that sort of stuff but I imagine
that automated replacement might go a long way.
[1] https://postgr.es/m/b936d2fb-590d-49c3-a615-92c3a88c6c19%40eisentraut.org