From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Subject: | 64 bit numbers vs format strings |
Date: | 2024-12-05 22:18:25 |
Message-ID: | CA+hUKGJc4s+Wyb3EFOQNN9VVK+Qv40r2LK41o9PkS9ThxviTvQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
0001-Use-PRI-64-instead-of-ll-in-format-strings.patch | text/x-patch | 90.0 KB |
0002-pgbench-Make-set_random_seed-64-bit-everywhere.patch | text/x-patch | 1.8 KB |
0003-pgbench-Rationalize-types-in-parseScriptWeight.patch | text/x-patch | 1.7 KB |
0004-pgbench-Modernize-integer-parsing-routine.patch | text/x-patch | 3.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Jelte Fennema-Nio | 2024-12-05 22:28:51 | Re: Proposal: Role Sandboxing for Secure Impersonation |
Previous Message | Tom Lane | 2024-12-05 22:09:14 | Re: Assert failure on running a completed portal again |