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

Commitaaa3aed

Browse files
committed
Remove HAVE_WORKING_LINK
Previously, hard links were not used on Windows and Cygwin, but theysupport them just fine in currently supported OS versions, so we canuse them there as well.Since all supported platforms now support hard links, we can removethe alternative code paths.Rename durable_link_or_rename() to durable_rename_excl() to make thepurpose more clear without referencing the implementation details.Discussion:https://www.postgresql.org/message-id/flat/72fff73f-dc9c-4ef4-83e8-d2e60c98df48%402ndquadrant.com
1 parentd114cc5 commitaaa3aed

File tree

5 files changed

+10
-28
lines changed

5 files changed

+10
-28
lines changed

‎src/backend/access/transam/timeline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
429429
* Perform the rename using link if available, paranoidly trying to avoid
430430
* overwriting an existing file (there shouldn't be one).
431431
*/
432-
durable_link_or_rename(tmppath,path,ERROR);
432+
durable_rename_excl(tmppath,path,ERROR);
433433

434434
/* The history file can be archived immediately. */
435435
if (XLogArchivingActive())
@@ -507,7 +507,7 @@ writeTimeLineHistoryFile(TimeLineID tli, char *content, int size)
507507
* Perform the rename using link if available, paranoidly trying to avoid
508508
* overwriting an existing file (there shouldn't be one).
509509
*/
510-
durable_link_or_rename(tmppath,path,ERROR);
510+
durable_rename_excl(tmppath,path,ERROR);
511511
}
512512

513513
/*

‎src/backend/access/transam/xlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3591,11 +3591,11 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
35913591
* Perform the rename using link if available, paranoidly trying to avoid
35923592
* overwriting an existing file (there shouldn't be one).
35933593
*/
3594-
if (durable_link_or_rename(tmppath,path,LOG)!=0)
3594+
if (durable_rename_excl(tmppath,path,LOG)!=0)
35953595
{
35963596
if (use_lock)
35973597
LWLockRelease(ControlFileLock);
3598-
/*durable_link_or_rename already emitted log message */
3598+
/*durable_rename_excl already emitted log message */
35993599
return false;
36003600
}
36013601

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,11 @@ durable_unlink(const char *fname, int elevel)
765765
}
766766

767767
/*
768-
* durable_link_or_rename -- rename a file in a durable manner.
768+
* durable_rename_excl -- rename a file in a durable manner, without
769+
* overwriting an existing target file
769770
*
770-
* Similar to durable_rename(), except that this routinetries (but does not
771-
*guarantee) not to overwrite thetarget file.
771+
* Similar to durable_rename(), except that this routinewill fail if the
772+
* target file already exists.
772773
*
773774
* Note that a crash in an unfortunate moment can leave you with two links to
774775
* the target file.
@@ -779,7 +780,7 @@ durable_unlink(const char *fname, int elevel)
779780
* valid upon return.
780781
*/
781782
int
782-
durable_link_or_rename(constchar*oldfile,constchar*newfile,intelevel)
783+
durable_rename_excl(constchar*oldfile,constchar*newfile,intelevel)
783784
{
784785
/*
785786
* 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)
788789
if (fsync_fname_ext(oldfile, false, false,elevel)!=0)
789790
return-1;
790791

791-
#ifdefHAVE_WORKING_LINK
792792
if (link(oldfile,newfile)<0)
793793
{
794794
ereport(elevel,
@@ -798,17 +798,6 @@ durable_link_or_rename(const char *oldfile, const char *newfile, int elevel)
798798
return-1;
799799
}
800800
unlink(oldfile);
801-
#else
802-
/* XXX: Add racy file existence check? */
803-
if (rename(oldfile,newfile)<0)
804-
{
805-
ereport(elevel,
806-
(errcode_for_file_access(),
807-
errmsg("could not rename file \"%s\" to \"%s\": %m",
808-
oldfile,newfile)));
809-
return-1;
810-
}
811-
#endif
812801

813802
/*
814803
* Make change persistent in case of an OS crash, both the new entry and

‎src/include/pg_config_manual.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@
129129
#undef HAVE_UNIX_SOCKETS
130130
#endif
131131

132-
/*
133-
* Define this if your operating system supports link()
134-
*/
135-
#if !defined(WIN32)&& !defined(__CYGWIN__)
136-
#defineHAVE_WORKING_LINK 1
137-
#endif
138-
139132
/*
140133
* USE_POSIX_FADVISE controls whether Postgres will attempt to use the
141134
* posix_fadvise() kernel call. Usually the automatic configure tests are

‎src/include/storage/fd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ extern void fsync_fname(const char *fname, bool isdir);
157157
externintfsync_fname_ext(constchar*fname,boolisdir,boolignore_perm,intelevel);
158158
externintdurable_rename(constchar*oldfile,constchar*newfile,intloglevel);
159159
externintdurable_unlink(constchar*fname,intloglevel);
160-
externintdurable_link_or_rename(constchar*oldfile,constchar*newfile,intloglevel);
160+
externintdurable_rename_excl(constchar*oldfile,constchar*newfile,intloglevel);
161161
externvoidSyncDataDirectory(void);
162162
externintdata_sync_elevel(intelevel);
163163

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp