summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2015-11-24 17:18:27 -0500
committerBruce Momjian <bruce@momjian.us>2015-11-24 17:18:27 -0500
commit0ca3c51e5520b423b17f498f6390129659ef68e0 (patch)
treeecf461aa455f3eba74f85787fa9b83175bf427bb
parent05c9bc0635e95119558820d4910a228934fc4bd5 (diff)
pg_upgrade: fix CopyFile() on Windows to fail on file existence
Also fix getErrorText() to return the right error string on failure. This behavior now matches that of other operating systems. Report by Noah Misch Backpatch through 9.1
-rw-r--r--contrib/pg_upgrade/file.c2
-rw-r--r--contrib/pg_upgrade/util.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c
index 40463c61369..a1b0176590a 100644
--- a/contrib/pg_upgrade/file.c
+++ b/contrib/pg_upgrade/file.c
@@ -37,7 +37,7 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
#ifndef WIN32
if (copy_file(src, dst, force) == -1)
#else
- if (CopyFile(src, dst, force) == 0)
+ if (CopyFile(src, dst, !force) == 0)
#endif
return getErrorText(errno);
else
diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c
index c0d9deebca4..d323045deb3 100644
--- a/contrib/pg_upgrade/util.c
+++ b/contrib/pg_upgrade/util.c
@@ -253,6 +253,8 @@ getErrorText(int errNum)
{
#ifdef WIN32
_dosmaperr(GetLastError());
+ /* _dosmaperr sets errno, so we copy errno here */
+ errNum = errno;
#endif
return pg_strdup(strerror(errNum));
}