summaryrefslogtreecommitdiff
path: root/src/bin/pg_upgrade/file.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2020-03-04 08:05:33 +0100
committerPeter Eisentraut <peter@eisentraut.org>2020-03-04 08:22:54 +0100
commit0ad6f848eef267489d4aee7306c16f96454b7a64 (patch)
tree225eeb4e2e6162d3b4664b47695f980cc50cf2c5 /src/bin/pg_upgrade/file.c
parentd67755049388526cd8673aa826dc794b97345eb3 (diff)
Move pg_upgrade's Windows link() implementation to AC_REPLACE_FUNCS
This way we can make use of it in other components as well, and it fits better with the rest of the build system. Discussion: https://www.postgresql.org/message-id/flat/72fff73f-dc9c-4ef4-83e8-d2e60c98df48%402ndquadrant.com
Diffstat (limited to 'src/bin/pg_upgrade/file.c')
-rw-r--r--src/bin/pg_upgrade/file.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 09bf886ed71..cc8a675d009 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -26,10 +26,6 @@
#include "storage/checksum.h"
#include "storage/checksum_impl.h"
-#ifdef WIN32
-static int win32_pghardlink(const char *src, const char *dst);
-#endif
-
/*
* cloneFile()
@@ -151,7 +147,7 @@ void
linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName)
{
- if (pg_link_file(src, dst) < 0)
+ if (link(src, dst) < 0)
pg_fatal("error while creating link for relation \"%s.%s\" (\"%s\" to \"%s\"): %s\n",
schemaName, relName, src, dst, strerror(errno));
}
@@ -369,29 +365,10 @@ check_hard_link(void)
snprintf(new_link_file, sizeof(new_link_file), "%s/PG_VERSION.linktest", new_cluster.pgdata);
unlink(new_link_file); /* might fail */
- if (pg_link_file(existing_file, new_link_file) < 0)
+ if (link(existing_file, new_link_file) < 0)
pg_fatal("could not create hard link between old and new data directories: %s\n"
"In link mode the old and new data directories must be on the same file system.\n",
strerror(errno));
unlink(new_link_file);
}
-
-#ifdef WIN32
-/* implementation of pg_link_file() on Windows */
-static int
-win32_pghardlink(const char *src, const char *dst)
-{
- /*
- * CreateHardLinkA returns zero for failure
- * https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createhardlinka
- */
- if (CreateHardLinkA(dst, src, NULL) == 0)
- {
- _dosmaperr(GetLastError());
- return -1;
- }
- else
- return 0;
-}
-#endif