agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add common LSN parser for user-supplied locations
Date: Wed, 12 Aug 2026 08:08:34 +0000
Message-ID: <E1wu40n-00000000Edx-25Bm@gemulon.postgresql.org> (raw)
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@pgrust.com>
Author: Zexin Li <lizi.openmind@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.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(-)
Message-ID: <E1wu40n-00000000Edx-25Bm@gemulon.postgresql.org>
Permalink: ../E1wu40n-00000000Edx-25Bm@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wu40n-00000000Edx-25Bm@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Add common LSN parser for user-supplied locations
In-Reply-To: <E1wu40n-00000000Edx-25Bm@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox