Skip to content

Commit 87cdfeb

Browse files
committed
pg_upgrade: properly detect file copy failure on Windows
Previously, file copy failures were ignored on Windows due to an incorrect return value check. Report by Manu Joye Backpatch through 9.1
1 parent 40879a9 commit 87cdfeb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

contrib/pg_upgrade/file.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
3434
{
3535
if (pageConverter == NULL)
3636
{
37-
if (pg_copy_file(src, dst, force) == -1)
37+
#ifndef WIN32
38+
if (copy_file(src, dst, force) == -1)
39+
#else
40+
if (CopyFile(src, dst, force) == 0)
41+
#endif
3842
return getErrorText(errno);
3943
else
4044
return NULL;

contrib/pg_upgrade/pg_upgrade.h

-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ extern char *output_files[];
7070

7171

7272
#ifndef WIN32
73-
#define pg_copy_file copy_file
7473
#define pg_mv_file rename
7574
#define pg_link_file link
7675
#define PATH_SEPARATOR '/'
@@ -80,7 +79,6 @@ extern char *output_files[];
8079
#define ECHO_QUOTE "'"
8180
#define ECHO_BLANK ""
8281
#else
83-
#define pg_copy_file CopyFile
8482
#define pg_mv_file pgrename
8583
#define pg_link_file win32_pghardlink
8684
#define PATH_SEPARATOR '\\'

0 commit comments

Comments
 (0)