mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
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
This commit is contained in:
@@ -281,7 +281,7 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
|
||||
}
|
||||
|
||||
AppendToManifest(manifest,
|
||||
"%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }",
|
||||
"%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%08X\", \"End-LSN\": \"%X/%08X\" }",
|
||||
first_wal_range ? "" : ",\n",
|
||||
entry->tli,
|
||||
LSN_FORMAT_ARGS(tl_beginptr),
|
||||
|
||||
@@ -361,7 +361,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
|
||||
tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual);
|
||||
|
||||
/* Data row */
|
||||
values[0] = CStringGetTextDatum(psprintf("%X/%X", LSN_FORMAT_ARGS(ptr)));
|
||||
values[0] = CStringGetTextDatum(psprintf("%X/%08X", LSN_FORMAT_ARGS(ptr)));
|
||||
values[1] = Int64GetDatum(tli);
|
||||
do_tup_output(tstate, values, nulls);
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
|
||||
if (range->start_lsn < tlep[i]->begin)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("manifest requires WAL from initial timeline %u starting at %X/%X, but that timeline begins at %X/%X",
|
||||
errmsg("manifest requires WAL from initial timeline %u starting at %X/%08X, but that timeline begins at %X/%08X",
|
||||
range->tli,
|
||||
LSN_FORMAT_ARGS(range->start_lsn),
|
||||
LSN_FORMAT_ARGS(tlep[i]->begin))));
|
||||
@@ -419,7 +419,7 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
|
||||
if (range->start_lsn != tlep[i]->begin)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("manifest requires WAL from continuation timeline %u starting at %X/%X, but that timeline begins at %X/%X",
|
||||
errmsg("manifest requires WAL from continuation timeline %u starting at %X/%08X, but that timeline begins at %X/%08X",
|
||||
range->tli,
|
||||
LSN_FORMAT_ARGS(range->start_lsn),
|
||||
LSN_FORMAT_ARGS(tlep[i]->begin))));
|
||||
@@ -430,7 +430,7 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
|
||||
if (range->end_lsn > backup_state->startpoint)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("manifest requires WAL from final timeline %u ending at %X/%X, but this backup starts at %X/%X",
|
||||
errmsg("manifest requires WAL from final timeline %u ending at %X/%08X, but this backup starts at %X/%08X",
|
||||
range->tli,
|
||||
LSN_FORMAT_ARGS(range->end_lsn),
|
||||
LSN_FORMAT_ARGS(backup_state->startpoint)),
|
||||
@@ -441,7 +441,7 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
|
||||
if (range->end_lsn != tlep[i]->end)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("manifest requires WAL from non-final timeline %u ending at %X/%X, but this server switched timelines at %X/%X",
|
||||
errmsg("manifest requires WAL from non-final timeline %u ending at %X/%08X, but this server switched timelines at %X/%08X",
|
||||
range->tli,
|
||||
LSN_FORMAT_ARGS(range->end_lsn),
|
||||
LSN_FORMAT_ARGS(tlep[i]->end))));
|
||||
@@ -522,18 +522,18 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
|
||||
if (XLogRecPtrIsInvalid(tli_missing_lsn))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("WAL summaries are required on timeline %u from %X/%X to %X/%X, but no summaries for that timeline and LSN range exist",
|
||||
errmsg("WAL summaries are required on timeline %u from %X/%08X to %X/%08X, but no summaries for that timeline and LSN range exist",
|
||||
tle->tli,
|
||||
LSN_FORMAT_ARGS(tli_start_lsn),
|
||||
LSN_FORMAT_ARGS(tli_end_lsn))));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("WAL summaries are required on timeline %u from %X/%X to %X/%X, but the summaries for that timeline and LSN range are incomplete",
|
||||
errmsg("WAL summaries are required on timeline %u from %X/%08X to %X/%08X, but the summaries for that timeline and LSN range are incomplete",
|
||||
tle->tli,
|
||||
LSN_FORMAT_ARGS(tli_start_lsn),
|
||||
LSN_FORMAT_ARGS(tli_end_lsn)),
|
||||
errdetail("The first unsummarized LSN in this range is %X/%X.",
|
||||
errdetail("The first unsummarized LSN in this range is %X/%08X.",
|
||||
LSN_FORMAT_ARGS(tli_missing_lsn))));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user