mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Remove HAVE_WORKING_LINK
Previously, hard links were not used on Windows and Cygwin, but they support them just fine in currently supported OS versions, so we can use them there as well. Since all supported platforms now support hard links, we can remove the alternative code paths. Rename durable_link_or_rename() to durable_rename_excl() to make the purpose more clear without referencing the implementation details. Discussion: https://www.postgresql.org/message-id/flat/72fff73f-dc9c-4ef4-83e8-d2e60c98df48%402ndquadrant.com
This commit is contained in:
@@ -765,10 +765,11 @@ durable_unlink(const char *fname, int elevel)
|
||||
}
|
||||
|
||||
/*
|
||||
* durable_link_or_rename -- rename a file in a durable manner.
|
||||
* durable_rename_excl -- rename a file in a durable manner, without
|
||||
* overwriting an existing target file
|
||||
*
|
||||
* Similar to durable_rename(), except that this routine tries (but does not
|
||||
* guarantee) not to overwrite the target file.
|
||||
* Similar to durable_rename(), except that this routine will fail if the
|
||||
* target file already exists.
|
||||
*
|
||||
* Note that a crash in an unfortunate moment can leave you with two links to
|
||||
* the target file.
|
||||
@@ -779,7 +780,7 @@ durable_unlink(const char *fname, int elevel)
|
||||
* valid upon return.
|
||||
*/
|
||||
int
|
||||
durable_link_or_rename(const char *oldfile, const char *newfile, int elevel)
|
||||
durable_rename_excl(const char *oldfile, const char *newfile, int elevel)
|
||||
{
|
||||
/*
|
||||
* Ensure that, if we crash directly after the rename/link, a file with
|
||||
@@ -788,7 +789,6 @@ durable_link_or_rename(const char *oldfile, const char *newfile, int elevel)
|
||||
if (fsync_fname_ext(oldfile, false, false, elevel) != 0)
|
||||
return -1;
|
||||
|
||||
#ifdef HAVE_WORKING_LINK
|
||||
if (link(oldfile, newfile) < 0)
|
||||
{
|
||||
ereport(elevel,
|
||||
@@ -798,17 +798,6 @@ durable_link_or_rename(const char *oldfile, const char *newfile, int elevel)
|
||||
return -1;
|
||||
}
|
||||
unlink(oldfile);
|
||||
#else
|
||||
/* XXX: Add racy file existence check? */
|
||||
if (rename(oldfile, newfile) < 0)
|
||||
{
|
||||
ereport(elevel,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not rename file \"%s\" to \"%s\": %m",
|
||||
oldfile, newfile)));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make change persistent in case of an OS crash, both the new entry and
|
||||
|
Reference in New Issue
Block a user