Re: Translation of the NextOID message in pg_controldata

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Translation of the NextOID message in pg_controldata
Date: 2026-09-14 06:00:17
Message-ID: aqeNcd4403BGVZqc@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 14, 2026 at 12:32:18AM -0400, Tom Lane wrote:
> Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> writes:
> > Commit cb298616463 changed the following line:
>
> > - printf(_("Latest checkpoint's NextOID: %u\n"),
> > + printf(_("Latest checkpoint's NextOID: " OID8_FORMAT "\n"),

Oops, sorry about that. I can see the breakage with some update-po.

>> It appears that xgettext does not recognize PostgreSQL's OID8_FORMAT
>> macro and therefore extracts only the preceding string literal as the
>> msgid. In contrast, PRIu64, which is used in the same file, is
>> correctly extracted as %<PRIu64>. Therefore, shouldn't we use "%"
>> PRIu64 instead of OID8_FORMAT here as well?

Yes, it's not the first time that 64-bit values show this problem with
translatable strings.

> That would be fairly sad, because it means hard-wiring the fact that
> Oid8 is the same as uint64 in a bunch of non-obvious places.
> Admittedly, we've lived with formatting Oid as %u for a long time.
> But can we fix this some other way?

The proposed patch to use the Pri markers would work with gettext().
Just note that, I have.. cough.. also broken pg_resetwal in two
places.

The other places switched recently (amcheck, backend) only relate to
internal errors and places without po files, so they're out of the
picture, fine with the OID8_FORMAT markers.

Anyway, I really want to keep this code greppable with the Oid8
markers, so I don't think that the proposed patch is what I would do.
The magic solution I can think of is to remove the markers from the
translatable strings, and replace them with a set of %s, as of the
attached patch, then use a pre-built string that itself uses
OID8_FORMAT. I am pretty sure we have used this method in other
places of the tree, but I cannot pinpoint where, on top of my mind.

The idea of documenting this trick or equivalent in c.h is interesting
in the long term, for sure. Any suggestions how to word this
requirement close to the OID8_FORMAT declaration?

Thoughts?
--
Michael

Attachment Content-Type Size
0001-Fix-translation-of-pg_resetwal-and-pg_controldata-s-.patch text/plain 3.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-09-14 06:24:51 Re: [PATCH] validate inherited check constraints when enabling enforcement
Previous Message Amit Kapila 2026-09-14 05:43:02 Re: Review items for EXCEPT TABLE publication