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

Commit2c7c6c4

Browse files
committed
More consistent behavior of GetDataDirectoryCreatePerm on Windows
On Windows, GetDataDirectoryCreatePerm() just did nothing. The waythe code in some callers is structured, this is the first functionthat tries to access the data directory. So it also ends up the placethat is responsible for reporting that a data directory does not existor similar. Therefore, on Windows, these scenarios end up onpotentially completely different code paths.To unify this, to make testing more consistent across platforms, haveGetDataDirectoryCreatePerm() run the stat() call on Windows as well,even though it won't do anything with the result. That way, filesystem errors are reporting to callers in the same way as onnon-Windows.Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>Discussion:https://www.postgresql.org/message-id/15a59bca-0383-183c-9383-0446da9b87e1%40eisentraut.org
1 parent151ffcf commit2c7c6c4

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

‎src/common/file_perm.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ SetDataDirectoryCreatePerm(int dataDirMode)
5959
* false is returned.
6060
*
6161
* Suppress when on Windows, because there may not be proper support for Unix-y
62-
* file permissions.
62+
* file permissions. But we still run stat() on the directory so that callers
63+
* get consistent behavior for example if the directory does not exist.
6364
*/
6465
bool
6566
GetDataDirectoryCreatePerm(constchar*dataDir)
6667
{
67-
#if !defined(WIN32)&& !defined(__CYGWIN__)
6868
structstatstatBuf;
6969

7070
/*
@@ -75,16 +75,12 @@ GetDataDirectoryCreatePerm(const char *dataDir)
7575
if (stat(dataDir,&statBuf)==-1)
7676
return false;
7777

78+
#if !defined(WIN32)&& !defined(__CYGWIN__)
7879
/* Set permissions */
7980
SetDataDirectoryCreatePerm(statBuf.st_mode);
80-
return true;
81-
#else/* !defined(WIN32) && !defined(__CYGWIN__) */
82-
/*
83-
* On Windows, we don't have anything to do here since they don't have
84-
* Unix-y permissions.
85-
*/
86-
return true;
8781
#endif
82+
83+
return true;
8884
}
8985

9086

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp