From 00a59f976130a1bb569dce94a9f2ab32692a9c76 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Mon, 14 Sep 2026 14:47:48 +0900 Subject: [PATCH] Fix translation of pg_resetwal and pg_controldata's NextOID output xgettext() drops OID8_FORMAT and therefore extracts an incomplete message. Let's use %s in these translatable strings, with a pre-built buffer that relies on OID8_FORMAT. Reported-by: Kyotaro Horiguchi --- src/bin/pg_controldata/pg_controldata.c | 6 ++++-- src/bin/pg_resetwal/pg_resetwal.c | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index b785f7f40701..31dba74f5996 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -101,6 +101,7 @@ main(int argc, char *argv[]) char pgctime_str[128]; char ckpttime_str[128]; char mock_auth_nonce_str[MOCK_AUTH_NONCE_LEN * 2 + 1]; + char nextoid_str[32]; const char *strftime_fmt = "%c"; const char *progname; char xlogfilename[MAXFNAMELEN]; @@ -269,8 +270,9 @@ main(int argc, char *argv[]) printf(_("Latest checkpoint's NextXID: %u:%u\n"), EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid), XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)); - printf(_("Latest checkpoint's NextOID: " OID8_FORMAT "\n"), - ControlFile->checkPointCopy.nextOid); + snprintf(nextoid_str, sizeof(nextoid_str), OID8_FORMAT, + ControlFile->checkPointCopy.nextOid); + printf(_("Latest checkpoint's NextOID: %s\n"), nextoid_str); printf(_("Latest checkpoint's NextMultiXactId: %u\n"), ControlFile->checkPointCopy.nextMulti); printf(_("Latest checkpoint's NextMultiOffset: %" PRIu64 "\n"), diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 63e4381e03f0..45146df30a56 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -757,6 +757,8 @@ GuessControlValues(void) static void PrintControlValues(bool guessed) { + char nextoid_str[32]; + if (guessed) printf(_("Guessed pg_control values:\n\n")); else @@ -775,8 +777,9 @@ PrintControlValues(bool guessed) printf(_("Latest checkpoint's NextXID: %u:%u\n"), EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid), XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid)); - printf(_("Latest checkpoint's NextOID: " OID8_FORMAT "\n"), - ControlFile.checkPointCopy.nextOid); + snprintf(nextoid_str, sizeof(nextoid_str), OID8_FORMAT, + ControlFile.checkPointCopy.nextOid); + printf(_("Latest checkpoint's NextOID: %s\n"), nextoid_str); printf(_("Latest checkpoint's NextMultiXactId: %u\n"), ControlFile.checkPointCopy.nextMulti); printf(_("Latest checkpoint's NextMultiOffset: %" PRIu64 "\n"), @@ -835,6 +838,7 @@ static void PrintNewControlValues(void) { char fname[MAXFNAMELEN]; + char nextoid_str[32]; /* This will be always printed in order to keep format same. */ printf(_("\n\nValues to be changed:\n\n")); @@ -861,8 +865,9 @@ PrintNewControlValues(void) if (next_oid_given) { - printf(_("NextOID: " OID8_FORMAT "\n"), - ControlFile.checkPointCopy.nextOid); + snprintf(nextoid_str, sizeof(nextoid_str), OID8_FORMAT, + ControlFile.checkPointCopy.nextOid); + printf(_("NextOID: %s\n"), nextoid_str); } if (next_xid_given) -- 2.55.0