From 6439f5ed5b9cb6524c307f06a43c9c54f51d3b86 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Mon, 29 Aug 2022 21:08:25 +1200 Subject: [PATCH v2 2/3] Improve xlogrecovery.c/xlogreader.c boundary. Create a function XLogReaderResetError() to clobber the error message inside an XLogReaderState, instead of doing it directly from xlogrecovery.c. This is older code from commit 0668719801, but commit 5dc0418f probably should have tidied this up because it leaves the internal state a bit out of sync (not a live bug, but a little confusing). --- src/backend/access/transam/xlogreader.c | 10 ++++++++++ src/backend/access/transam/xlogrecovery.c | 2 +- src/include/access/xlogreader.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index e883ade607..c100e18333 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1325,6 +1325,16 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, return true; } +/* + * Forget about an error produced by XLogReaderValidatePageHeader(). + */ +void +XLogReaderResetError(XLogReaderState *state) +{ + state->errormsg_buf[0] = '\0'; + state->errormsg_deferred = false; +} + /* * Find the first record with an lsn >= RecPtr. * diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index a59a0e826b..422322cf5a 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -3335,7 +3335,7 @@ retry: (errmsg_internal("%s", xlogreader->errormsg_buf))); /* reset any error XLogReaderValidatePageHeader() might have set */ - xlogreader->errormsg_buf[0] = '\0'; + XLogReaderResetError(xlogreader); goto next_record_is_invalid; } diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index 87ff00feb7..97b6f00114 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -373,6 +373,9 @@ extern DecodedXLogRecord *XLogReadAhead(XLogReaderState *state, extern bool XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, char *phdr); +/* Forget error produced by XLogReaderValidatePageHeader(). */ +extern void XLogReaderResetError(XLogReaderState *state); + /* * Error information from WALRead that both backend and frontend caller can * process. Currently only errors from pread can be reported. -- 2.30.2