pgsql: Use pg_parse_lsn() for timeline history switchpoints

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use pg_parse_lsn() for timeline history switchpoints
Date: 2026-10-22 08:36:43
Message-ID: E1xJoHz-00000000Iy0-2qhn@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use pg_parse_lsn() for timeline history switchpoints

readTimeLineHistory() previously parsed WAL switchpoints in timeline
history files using sscanf("%X/%08X") into uint32 values. An
overlong high component could overflow, while an overlong low component
was truncated to its first eight digits. Trailing characters were also
ignored.

Extract the switchpoint token and use pg_parse_lsn() to validate and
convert it, requiring one to eight hexadecimal digits per component
with no trailing characters, as for pg_lsn input. This matches the
change to pg_rewind's history file parser in commit f31d6fbc31d.

Author: Jan Nidzwetzki <jan(at)planetscale(dot)com>
Reviewed-by: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/8b1abbd0-7335-4e68-93ec-91cdbbfd9568@planetscale.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5ffb8c7409385c58e5c1abaa22ee77ba4c1b5c33

Modified Files
--------------
src/backend/access/transam/timeline.c | 37 +++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-22 16:26:29 pgsql: Clear async.c's isAdvancing flag when a notify read is aborted.
Previous Message Michael Paquier 2026-10-22 08:18:34 pgsql: pg_stat_statements: Add tests for SQL/JSON query patterns