Re: 64 bit numbers vs format strings

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Wolfgang Walther <walther(at)technowledgy(dot)de>
Subject: Re: 64 bit numbers vs format strings
Date: 2025-11-03 11:54:35
Message-ID: CA+hUKG+pp==d-3LVhdNOvOAzwQN0vP4gBSxtHkmxnmfQD3NY=w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 18, 2025 at 4:48 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> > On Mon, Mar 17, 2025 at 8:09 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> Hmm, I find that comment fairly scary. How do we know that the
> >> runtime library actually gets this right on every supported platform?
>
> > I don't know too much about libintl and its history other than what
> > I've looked up for these discussions, but I can't find any other
> > implementations other than Sun's, GNU's and NetBSD's. Sun/Oracle and
> > NetBSD went out of their way to understand these and other GNUisms.
>
> Okay, that reduces the size of the problem considerably.

For the record, I found one more hiding on Alpine Linux. It has two
implementations available:

1. You can install the regular GNU library and tools with "gettext"
and "gettext-dev". Then I assume this all just works.

2. There is a cleanroom implementation reachable with "musl-libintl".
It supplies a different /usr/include/libintl.h that activates an
implementation inside musl itself, and IIRC "gettext-tiny" gives you
msgfmt etc. I bet this new 64-bit stuff doesn't work though: they do
support %<PRIu64> etc, but the lookup table[1] seems a little on the
short side for our usage. gettext-tiny's README.md also explains that
they pre-chew them in msgfmt, so GNU/non-GNU combinations probably
break once you start using these macros, if they ever worked.

It looks like the packages and docker scripts people use to run
PostgreSQL on Alpine don't enable nls anyway, so I doubt we'll hear
anything about this from the field. It might still be interesting to
know which msgfmt/libintl pair the BF animals are using (CC Wolfgang),
and whether this stuff actually works. If not, installing "gettext"
and "gettext-dev" would likely be the solution, though if the musl
version already works for %<PRIu64>, perhaps a small PR could get the
other variants to work too?

[1] https://github.com/sabotage-linux/gettext-tiny/blob/master/src/poparser.c

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mahendra Singh Thalor 2025-11-03 11:54:37 Re: Non-text mode for pg_dumpall
Previous Message Akshay Joshi 2025-11-03 11:47:40 Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement