Re: Inconsistent LSN format in pg_waldump output
Álvaro Herrera <alvherre@kurilemu.de>
From: Álvaro Herrera <alvherre@kurilemu.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, Japin Li <japinli@hotmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-03T08:19:52Z
Lists: pgsql-hackers
On 2025-Jul-03, Michael Paquier wrote: > Yep. If you do not want this new policy to be forgotten by new paths, > I'd suggested to standarize that with something like that, close to > the existing LSN_FORMAT_ARGS(): > #define LSN_FORMAT "%X/%08X" Well, the reason we didn't use a macro in the format string is that translatability suffers quite a bit, and it's quite annoying. You can still use it in strings that aren't going to be translated -- for instance in all the xlog *_desc routines, in elog(), errmsg_internal(), errdetail_internal(). But for translatable messages such as errmsg(), errdetail, it's going to break. For example, one particular message in twophase.c was originally msgid "could not read two-phase state from WAL at %X/%X" after this patch, it becomes msgid "could not read two-phase state from WAL at " which is obviously broken. (You can test this by running "make update-po" and looking at the src/backend/po/*.po.new files. No idea hwo to do this under Meson, it doesn't seem documented.) Eyeballing the patch I think a majority of the messages are not translatable, so I'm still okay with adding and using the macro. But we need a revision to go back to literal %X/%08X in errmsg(), errdetail(), report_invalid_record(). I'd also add a comment next to the macro indicating that the macro MUST NOT be used for translatable strings, as it otherwise results in a bug that's only visible if you're running a version in a language other than English. I bet we're still going to get hackers use it badly, but not often. The GNU gettext manual suggests you can print the value to a string variable and then use %s to include that in the translatable string, but I doubt that's an improvement over just using %X/%08X directly. Bottom of this page here: https://www.gnu.org/software/gettext/manual/html_node/No-string-concatenation.html -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Commits
-
Fix a couple more places in docs for pg_lsn change
- aa39b4e35ac6 19 (unreleased) landed
-
Adapt pg_upgrade test to pg_lsn output format difference
- 3adcf9fbd8ba 19 (unreleased) landed
-
Standardize LSN formatting by zero padding
- 2633dae2e487 19 (unreleased) landed