diff options
author | Álvaro Herrera <alvherre@kurilemu.de> | 2025-07-07 13:57:43 +0200 |
---|---|---|
committer | Álvaro Herrera <alvherre@kurilemu.de> | 2025-07-07 13:57:43 +0200 |
commit | 2633dae2e4876a9b7cb90ba025e930a553e5107f (patch) | |
tree | 9eff715f0db067c8454a9edf60588e03795f0c2f /src/backend/access/transam/timeline.c | |
parent | 62a17a92833d1eaa60d8ea372663290942a1e8eb (diff) | |
download | postgresql-2633dae2e4876a9b7cb90ba025e930a553e5107f.tar.gz postgresql-2633dae2e4876a9b7cb90ba025e930a553e5107f.zip |
Standardize LSN formatting by zero padding
This commit standardizes the output format for LSNs to ensure consistent
representation across various tools and messages. Previously, LSNs were
inconsistently printed as `%X/%X` in some contexts, while others used
zero-padding. This often led to confusion when comparing.
To address this, the LSN format is now uniformly set to `%X/%08X`,
ensuring the lower 32-bit part is always zero-padded to eight
hexadecimal digits.
Author: Japin Li <japinli@hotmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/ME0P300MB0445CA53CA0E4B8C1879AF84B641A@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
Diffstat (limited to 'src/backend/access/transam/timeline.c')
-rw-r--r-- | src/backend/access/transam/timeline.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c index a27f27cc037..186eb91f609 100644 --- a/src/backend/access/transam/timeline.c +++ b/src/backend/access/transam/timeline.c @@ -154,7 +154,7 @@ readTimeLineHistory(TimeLineID targetTLI) if (*ptr == '\0' || *ptr == '#') continue; - nfields = sscanf(fline, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo); + nfields = sscanf(fline, "%u\t%X/%08X", &tli, &switchpoint_hi, &switchpoint_lo); if (nfields < 1) { @@ -399,7 +399,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, * parent file failed to end with one. */ snprintf(buffer, sizeof(buffer), - "%s%u\t%X/%X\t%s\n", + "%s%u\t%X/%08X\t%s\n", (srcfd < 0) ? "" : "\n", parentTLI, LSN_FORMAT_ARGS(switchpoint), |