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 <[email protected]>
Author: Zexin Li <[email protected]>
Reviewed-by: Ayush Tiwari <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/[email protected]
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(-)