8000 pg_upgrade: fix CopyFile() on Windows to fail on file existence · home201448/postgres@6638c9a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6638c9a

Browse files
committed
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
1 parent 0e61852 commit 6638c9a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

contrib/pg_upgrade/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
3737
#ifndef WIN32
3838
if (copy_file(src, dst, force) == -1)
3939
#else
40-
if (CopyFile(src, dst, force) == 0)
40+
if (CopyFile(src, dst, !force) == 0)
4141
#endif
4242
return getErrorText(errno);
4343
else

contrib/pg_upgrade/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ getErrorText(int errNum)
226226
{
227227
#ifdef WIN32
228228
_dosmaperr(GetLastError());
229+
/* _dosmaperr sets errno, so we copy errno here */
230+
errNum = errno;
229231
#endif
230232
return pg_strdup(strerror(errNum));
231233
}

0 commit comments

Comments
 (0)
0