| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Add common LSN parser for user-supplied locations |
| Date: | 2026-08-12 08:08:34 |
| Message-ID: | E1wu40n-00000000Edx-25Bm@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Add common LSN parser for user-supplied locations
pg_waldump (--start/--end), pg_recvlogical (--startpos/--endpos), and
pg_receivewal (--endpos) parsed user-supplied WAL locations with
sscanf("%X/%08X"). That accepts several forms rejected by pg_lsn input
and can proceed with a different location than the user specified:
overlong components, trailing characters, leading whitespace, signs, and
0x prefixes.
Add pg_parse_lsn() to src/common and use it for those command-line
options. The helper accepts the pg_lsn text syntax only: one to eight
hexadecimal digits, a slash, one to eight hexadecimal digits, and no
trailing characters. Each frontend tool keeps its existing error
message.
Use the same helper from pg_lsn_in_safe(), leaving only backend-specific
soft error reporting there. This keeps frontend command-line validation
and backend pg_lsn input tied to one parser.
Bug: #19598
Reported-by: Michael Malis <malis(at)pgrust(dot)com>
Author: Zexin Li <lizi(dot)openmind(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/19598-aa67c8f4331611b4@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d6bf0ab1704c62f94875d25dd71c4baa1feac5be
Modified Files
--------------
src/backend/utils/adt/pg_lsn.c | 24 ++----------
src/bin/pg_basebackup/pg_receivewal.c | 6 +--
src/bin/pg_basebackup/pg_recvlogical.c | 9 ++---
src/bin/pg_basebackup/t/020_pg_receivewal.pl | 8 ++++
src/bin/pg_basebackup/t/030_pg_recvlogical.pl | 16 ++++++++
src/bin/pg_waldump/pg_waldump.c | 10 ++---
src/bin/pg_waldump/t/001_basic.pl | 16 ++++++++
src/common/Makefile | 1 +
src/common/meson.build | 1 +
src/common/pg_parse_lsn.c | 55 +++++++++++++++++++++++++++
src/include/common/pg_parse_lsn.h | 20 ++++++++++
11 files changed, 128 insertions(+), 38 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-08-12 09:55:08 | pgsql: Fix stale comments/signature after commit 28d534e2ae0a |
| Previous Message | Daniel Gustafsson | 2026-08-12 07:43:51 | pgsql: Use per-query timeout in subscription test |