pg_upgrade: properly detect file copy failure on Windows
authorBruce Momjian
Sat, 14 Nov 2015 16:47:11 +0000 (11:47 -0500)
committerBruce Momjian
Sat, 14 Nov 2015 16:47:11 +0000 (11:47 -0500)
Previously, file copy failures were ignored on Windows due to an
incorrect return value check.

Report by Manu Joye

Backpatch through 9.1

contrib/pg_upgrade/file.c
contrib/pg_upgrade/pg_upgrade.h

index c198e91ce15dd61fdd852454bbeb6a1d390f7e56..36dee3eae7bd0522560cdcdbbc5f9e591acedbd3 100644 (file)
@@ -34,7 +34,11 @@ copyAndUpdateFile(pageCnvCtx *pageConverter,
 {
    if (pageConverter == NULL)
    {
-       if (pg_copy_file(src, dst, force) == -1)
+#ifndef WIN32
+       if (copy_file(src, dst, force) == -1)
+#else
+       if (CopyFile(src, dst, force) == 0)
+#endif
            return getErrorText(errno);
        else
            return NULL;
index 85c737932dfe56b03f7fdf27626f7b2329b63ff6..876a0d16bae1816c9fe276e742291b7126d460cb 100644 (file)
@@ -70,7 +70,6 @@ extern char *output_files[];
 
 
 #ifndef WIN32
-#define pg_copy_file       copy_file
 #define pg_mv_file         rename
 #define pg_link_file       link
 #define PATH_SEPARATOR     '/'
@@ -80,7 +79,6 @@ extern char *output_files[];
 #define ECHO_QUOTE "'"
 #define ECHO_BLANK ""
 #else
-#define pg_copy_file       CopyFile
 #define pg_mv_file         pgrename
 #define pg_link_file       win32_pghardlink
 #define sleep(x)           Sleep(x * 1000)