From 5cf457e61367ca8420406b3d14c40708bd922707 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Wed, 13 Sep 2023 06:04:48 +0000 Subject: [PATCH v1] Have better wording for snapshot file reading failure When a snapshot file reading fails in ImportSnapshot(), it errors out with "invalid snapshot identifier". This message better suits for snapshot identifier parsing errors which is being done just before the file reading. This commit adds a generic file reading error message with path to help distinguish if the issue is with snapshot identifier parsing or file reading. --- src/backend/utils/time/snapmgr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index b20440ee21..65230811c0 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -1391,8 +1391,9 @@ ImportSnapshot(const char *idstr) f = AllocateFile(path, PG_BINARY_R); if (!f) ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid snapshot identifier: \"%s\"", idstr))); + (errcode_for_file_access(), + errmsg("could not open file \"%s\" for reading: %m", + path))); /* get the size of the file so that we know how much memory we need */ if (fstat(fileno(f), &stat_buf)) -- 2.34.1