]> granicus.if.org Git - postgresql/commitdiff
pg_upgrade: properly detect file copy failure on Windows
authorBruce Momjian <bruce@momjian.us>
Sat, 14 Nov 2015 16:47:11 +0000 (11:47 -0500)
committerBruce Momjian <bruce@momjian.us>
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 de23dedbf2b17c6cd25bf89c7fe405cf8f34f992..2aa48f049adbec048bd55bd3a4cba3e28459cd52 100644 (file)
@@ -38,7 +38,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 0b3a83b9ef3ff2288b34ceb829841e5ff30ec7d3..72e2e6acafc1169d63857185b9571ba727ad0b99 100644 (file)
@@ -35,7 +35,6 @@
 #define DB_DUMP_FILE           "pg_upgrade_dump_db.sql"
 
 #ifndef WIN32
-#define pg_copy_file           copy_file
 #define pg_mv_file                     rename
 #define pg_link_file           link
 #define PATH_SEPARATOR      '/'
@@ -43,7 +42,6 @@
 #define RMDIR_CMD                      "rm -rf"
 #define SCRIPT_EXT                     "sh"
 #else
-#define pg_copy_file           CopyFile
 #define pg_mv_file                     pgrename
 #define pg_link_file           win32_pghardlink
 #define sleep(x)                       Sleep(x * 1000)