Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb64cea

Browse files
committed
Remove durable_rename_excl()
A previous commit replaced all the calls to this function withdurable_rename() as ofdac1ff3, making it used nowhere in the tree.Using it in extension code is also risky based on the issues describedin this previous commit, so let's remove it. This makes possible theremoval of HAVE_WORKING_LINK.Author: Nathan BossartReviewed-by: Robert Haas, Kyotaro Horiguchi, Michael PaquierDiscussion:https://postgr.es/m/20220407182954.GA1231544@nathanxps13
1 parentdac1ff3 commiteb64cea

File tree

3 files changed

+0
-71
lines changed

3 files changed

+0
-71
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -807,69 +807,6 @@ durable_unlink(const char *fname, int elevel)
807807
return0;
808808
}
809809

810-
/*
811-
* durable_rename_excl -- rename a file in a durable manner.
812-
*
813-
* Similar to durable_rename(), except that this routine tries (but does not
814-
* guarantee) not to overwrite the target file.
815-
*
816-
* Note that a crash in an unfortunate moment can leave you with two links to
817-
* the target file.
818-
*
819-
* Log errors with the caller specified severity.
820-
*
821-
* On Windows, using a hard link followed by unlink() causes concurrency
822-
* issues, while a simple rename() does not cause that, so be careful when
823-
* changing the logic of this routine.
824-
*
825-
* Returns 0 if the operation succeeded, -1 otherwise. Note that errno is not
826-
* valid upon return.
827-
*/
828-
int
829-
durable_rename_excl(constchar*oldfile,constchar*newfile,intelevel)
830-
{
831-
/*
832-
* Ensure that, if we crash directly after the rename/link, a file with
833-
* valid contents is moved into place.
834-
*/
835-
if (fsync_fname_ext(oldfile, false, false,elevel)!=0)
836-
return-1;
837-
838-
#ifdefHAVE_WORKING_LINK
839-
if (link(oldfile,newfile)<0)
840-
{
841-
ereport(elevel,
842-
(errcode_for_file_access(),
843-
errmsg("could not link file \"%s\" to \"%s\": %m",
844-
oldfile,newfile)));
845-
return-1;
846-
}
847-
unlink(oldfile);
848-
#else
849-
if (rename(oldfile,newfile)<0)
850-
{
851-
ereport(elevel,
852-
(errcode_for_file_access(),
853-
errmsg("could not rename file \"%s\" to \"%s\": %m",
854-
oldfile,newfile)));
855-
return-1;
856-
}
857-
#endif
858-
859-
/*
860-
* Make change persistent in case of an OS crash, both the new entry and
861-
* its parent directory need to be flushed.
862-
*/
863-
if (fsync_fname_ext(newfile, false, false,elevel)!=0)
864-
return-1;
865-
866-
/* Same for parent directory */
867-
if (fsync_parent_path(newfile,elevel)!=0)
868-
return-1;
869-
870-
return0;
871-
}
872-
873810
/*
874811
* InitFileAccess --- initialize this module during backend startup
875812
*

‎src/include/pg_config_manual.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@
152152
#defineEXEC_BACKEND
153153
#endif
154154

155-
/*
156-
* Define this if your operating system supports link()
157-
*/
158-
#if !defined(WIN32)&& !defined(__CYGWIN__)
159-
#defineHAVE_WORKING_LINK 1
160-
#endif
161-
162155
/*
163156
* USE_POSIX_FADVISE controls whether Postgres will attempt to use the
164157
* posix_fadvise() kernel call. Usually the automatic configure tests are

‎src/include/storage/fd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ extern void fsync_fname(const char *fname, bool isdir);
187187
externintfsync_fname_ext(constchar*fname,boolisdir,boolignore_perm,intelevel);
188188
externintdurable_rename(constchar*oldfile,constchar*newfile,intloglevel);
189189
externintdurable_unlink(constchar*fname,intloglevel);
190-
externintdurable_rename_excl(constchar*oldfile,constchar*newfile,intloglevel);
191190
externvoidSyncDataDirectory(void);
192191
externintdata_sync_elevel(intelevel);
193192

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp