mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-05 19:09:58 +08:00
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
This commit is contained in:
parent
0e6185283c
commit
6638c9aaf8
@ -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
|
||||
|
@ -226,6 +226,8 @@ getErrorText(int errNum)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_dosmaperr(GetLastError());
|
||||
/* _dosmaperr sets errno, so we copy errno here */
|
||||
errNum = errno;
|
||||
#endif
|
||||
return pg_strdup(strerror(errNum));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user