From 30af754d2da46b0bc2af7f6805e529d4d30dac6b Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Sun, 20 Sep 2026 09:39:56 +0800 Subject: [PATCH v1 1/2] Fix inaccurate LSN validation messages in pg_walinspect Commit 5c1b6628075a changed the LSN validation checks to allow an input LSN to equal the current LSN and a start LSN to equal the end LSN. However, the corresponding error messages continued to say that the LSNs had to be less than those bounds. This was an oversight in 5c1b6628. Adjust the messages to say "less than or equal to", matching the actual validation conditions. Author: Chao Li --- contrib/pg_walinspect/expected/oldextversions.out | 4 ++-- contrib/pg_walinspect/expected/pg_walinspect.out | 14 +++++++------- contrib/pg_walinspect/pg_walinspect.c | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/contrib/pg_walinspect/expected/oldextversions.out b/contrib/pg_walinspect/expected/oldextversions.out index 89953af3d0e..fd65ed149c6 100644 --- a/contrib/pg_walinspect/expected/oldextversions.out +++ b/contrib/pg_walinspect/expected/oldextversions.out @@ -43,9 +43,9 @@ SELECT COUNT(*) >= 1 AS ok FROM pg_get_wal_stats_till_end_of_wal(:'wal_lsn1'); -- Failures with start LSNs. SELECT * FROM pg_get_wal_records_info_till_end_of_wal('FFFFFFFF/FFFFFFFF'); -ERROR: WAL start LSN must be less than current LSN +ERROR: WAL start LSN must be less than or equal to current LSN SELECT * FROM pg_get_wal_stats_till_end_of_wal('FFFFFFFF/FFFFFFFF'); -ERROR: WAL start LSN must be less than current LSN +ERROR: WAL start LSN must be less than or equal to current LSN -- Move to new version 1.1. ALTER EXTENSION pg_walinspect UPDATE TO '1.1'; -- List what version 1.1 contains. diff --git a/contrib/pg_walinspect/expected/pg_walinspect.out b/contrib/pg_walinspect/expected/pg_walinspect.out index f955ff5d3c5..b9abeeebdfd 100644 --- a/contrib/pg_walinspect/expected/pg_walinspect.out +++ b/contrib/pg_walinspect/expected/pg_walinspect.out @@ -29,14 +29,14 @@ SELECT * FROM pg_get_wal_block_info('0/0', :'wal_lsn1'); ERROR: could not read WAL at LSN 0/00000000 -- Start LSN > End LSN. SELECT * FROM pg_get_wal_records_info(:'wal_lsn2', :'wal_lsn1'); -ERROR: WAL start LSN must be less than end LSN +ERROR: WAL start LSN must be less than or equal to end LSN SELECT * FROM pg_get_wal_stats(:'wal_lsn2', :'wal_lsn1'); -ERROR: WAL start LSN must be less than end LSN +ERROR: WAL start LSN must be less than or equal to end LSN SELECT * FROM pg_get_wal_block_info(:'wal_lsn2', :'wal_lsn1'); -ERROR: WAL start LSN must be less than end LSN +ERROR: WAL start LSN must be less than or equal to end LSN -- LSNs with the highest value possible. SELECT * FROM pg_get_wal_record_info('FFFFFFFF/FFFFFFFF'); -ERROR: WAL input LSN must be less than current LSN +ERROR: WAL input LSN must be less than or equal to current LSN -- Success with end LSNs. SELECT COUNT(*) >= 1 AS ok FROM pg_get_wal_records_info(:'wal_lsn1', 'FFFFFFFF/FFFFFFFF'); ok @@ -58,11 +58,11 @@ SELECT COUNT(*) >= 1 AS ok FROM pg_get_wal_block_info(:'wal_lsn1', 'FFFFFFFF/FFF -- Failures with start LSNs. SELECT * FROM pg_get_wal_records_info('FFFFFFFF/FFFFFFFE', 'FFFFFFFF/FFFFFFFF'); -ERROR: WAL start LSN must be less than current LSN +ERROR: WAL start LSN must be less than or equal to current LSN SELECT * FROM pg_get_wal_stats('FFFFFFFF/FFFFFFFE', 'FFFFFFFF/FFFFFFFF'); -ERROR: WAL start LSN must be less than current LSN +ERROR: WAL start LSN must be less than or equal to current LSN SELECT * FROM pg_get_wal_block_info('FFFFFFFF/FFFFFFFE', 'FFFFFFFF/FFFFFFFF'); -ERROR: WAL start LSN must be less than current LSN +ERROR: WAL start LSN must be less than or equal to current LSN -- =================================================================== -- Tests for all function executions -- =================================================================== diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c index a172f9e2b40..6edd6f8cb35 100644 --- a/contrib/pg_walinspect/pg_walinspect.c +++ b/contrib/pg_walinspect/pg_walinspect.c @@ -488,7 +488,7 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS) if (lsn > curr_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("WAL input LSN must be less than current LSN"), + errmsg("WAL input LSN must be less than or equal to current LSN"), errdetail("Current WAL LSN on the database system is at %X/%08X.", LSN_FORMAT_ARGS(curr_lsn)))); @@ -530,14 +530,14 @@ ValidateInputLSNs(XLogRecPtr start_lsn, XLogRecPtr *end_lsn) if (start_lsn > curr_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("WAL start LSN must be less than current LSN"), + errmsg("WAL start LSN must be less than or equal to current LSN"), errdetail("Current WAL LSN on the database system is at %X/%08X.", LSN_FORMAT_ARGS(curr_lsn)))); if (start_lsn > *end_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("WAL start LSN must be less than end LSN"))); + errmsg("WAL start LSN must be less than or equal to end LSN"))); if (*end_lsn > curr_lsn) *end_lsn = curr_lsn; @@ -836,7 +836,7 @@ pg_get_wal_records_info_till_end_of_wal(PG_FUNCTION_ARGS) if (start_lsn > end_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("WAL start LSN must be less than current LSN"), + errmsg("WAL start LSN must be less than or equal to current LSN"), errdetail("Current WAL LSN on the database system is at %X/%08X.", LSN_FORMAT_ARGS(end_lsn)))); @@ -855,7 +855,7 @@ pg_get_wal_stats_till_end_of_wal(PG_FUNCTION_ARGS) if (start_lsn > end_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("WAL start LSN must be less than current LSN"), + errmsg("WAL start LSN must be less than or equal to current LSN"), errdetail("Current WAL LSN on the database system is at %X/%08X.", LSN_FORMAT_ARGS(end_lsn)))); -- 2.50.1 (Apple Git-155)