diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-08-01 16:39:16 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-08-01 16:39:16 +0900 |
commit | 07abcd9ab712b843568e2f9a00006dd25797dc02 (patch) | |
tree | ec68f0044fd29856cf1595cd9460348b515fcea2 | |
parent | feae5c0cba8088fb85d9365348e59047d1c2919a (diff) | |
download | postgresql-07abcd9ab712b843568e2f9a00006dd25797dc02.tar.gz postgresql-07abcd9ab712b843568e2f9a00006dd25797dc02.zip |
Fix error reporting after ioctl() call with pg_upgrade --clone
errno was not reported correctly after attempting to clone a file,
leading to incorrect error reports. While scanning through the code, I
have not noticed any similar mistakes.
Error introduced in 3a769d8.
Author: Justin Pryzby
Discussion: https://postgr.es/m/20220731134135.GY15006@telsasoft.com
Backpatch-through: 12
-rw-r--r-- | src/bin/pg_upgrade/file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c index b84868c7510..e16c2e009eb 100644 --- a/src/bin/pg_upgrade/file.c +++ b/src/bin/pg_upgrade/file.c @@ -57,9 +57,11 @@ cloneFile(const char *src, const char *dst, if (ioctl(dest_fd, FICLONE, src_fd) < 0) { + int save_errno = errno; + unlink(dst); pg_fatal("error while cloning relation \"%s.%s\" (\"%s\" to \"%s\"): %s\n", - schemaName, relName, src, dst, strerror(errno)); + schemaName, relName, src, dst, strerror(save_errno)); } close(src_fd); |