aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-09-14 10:30:08 +0900
committerMichael Paquier <michael@paquier.xyz>2023-09-14 10:30:08 +0900
commita0d87bcd9b57d85ec99eb2b2a2150bc60e5ca842 (patch)
tree4009662bcc2863c3882cef6fcafd166cfc9de784 /src
parentb8f44a47794588329cec280ee16eb0be17e1816e (diff)
downloadpostgresql-a0d87bcd9b57d85ec99eb2b2a2150bc60e5ca842.tar.gz
postgresql-a0d87bcd9b57d85ec99eb2b2a2150bc60e5ca842.zip
Improve error message on snapshot import in snapmgr.c
When a snapshot file fails to be read in ImportSnapshot(), it would issue an ERROR as "invalid snapshot identifier" when opening a stream for it in read-only mode. This error message is reworded to be the same as all the other messages used in this case on failure, which is useful when debugging this area. Thinko introduced by bb446b689b66 where snapshot imports have been added. A backpatch down to 11 is done as this can improve any work related to snapshot imports in older branches. Author: Bharath Rupireddy Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CALj2ACWmr=3KdxDkm8h7Zn1XxBoF6hdzq8WQyMn2y1OL5RYFrg@mail.gmail.com Backpatch-through: 11
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/time/snapmgr.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index b20440ee21f..65230811c02 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))