diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-07-05 12:54:25 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-07-05 12:54:25 +0900 |
commit | eb64ceac7ec3422f2370b8824dce62ee8fe52dca (patch) | |
tree | 63917652b45362f3de03b38d8d0c1f4c50d9faa3 /src/backend/storage/file/fd.c | |
parent | dac1ff30906b9cef7859380905d038892b32968b (diff) | |
download | postgresql-eb64ceac7ec3422f2370b8824dce62ee8fe52dca.tar.gz postgresql-eb64ceac7ec3422f2370b8824dce62ee8fe52dca.zip |
Remove durable_rename_excl()
A previous commit replaced all the calls to this function with
durable_rename() as of dac1ff3, making it used nowhere in the tree.
Using it in extension code is also risky based on the issues described
in this previous commit, so let's remove it. This makes possible the
removal of HAVE_WORKING_LINK.
Author: Nathan Bossart
Reviewed-by: Robert Haas, Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/20220407182954.GA1231544@nathanxps13
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r-- | src/backend/storage/file/fd.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 24704b6a023..f904f60c086 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -808,69 +808,6 @@ durable_unlink(const char *fname, int elevel) } /* - * durable_rename_excl -- rename a file in a durable manner. - * - * Similar to durable_rename(), except that this routine tries (but does not - * guarantee) not to overwrite the target file. - * - * Note that a crash in an unfortunate moment can leave you with two links to - * the target file. - * - * Log errors with the caller specified severity. - * - * On Windows, using a hard link followed by unlink() causes concurrency - * issues, while a simple rename() does not cause that, so be careful when - * changing the logic of this routine. - * - * Returns 0 if the operation succeeded, -1 otherwise. Note that errno is not - * valid upon return. - */ -int -durable_rename_excl(const char *oldfile, const char *newfile, int elevel) -{ - /* - * Ensure that, if we crash directly after the rename/link, a file with - * valid contents is moved into place. - */ - if (fsync_fname_ext(oldfile, false, false, elevel) != 0) - return -1; - -#ifdef HAVE_WORKING_LINK - if (link(oldfile, newfile) < 0) - { - ereport(elevel, - (errcode_for_file_access(), - errmsg("could not link file \"%s\" to \"%s\": %m", - oldfile, newfile))); - return -1; - } - unlink(oldfile); -#else - 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 - * its parent directory need to be flushed. - */ - if (fsync_fname_ext(newfile, false, false, elevel) != 0) - return -1; - - /* Same for parent directory */ - if (fsync_parent_path(newfile, elevel) != 0) - return -1; - - return 0; -} - -/* * InitFileAccess --- initialize this module during backend startup * * This is called during either normal or standalone backend start. |