Skip to content

Commit 15ebfee

Browse files
committed
Add O_DIRECT support on Windows.
ITAGAKI Takahiro
1 parent 85bbf01 commit 15ebfee

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/include/port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.110 2007/02/07 00:28:55 petere Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.111 2007/04/13 10:30:30 mha Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -277,6 +277,7 @@ extern bool rmtree(char *path, bool rmtopdir);
277277
/* open() and fopen() replacements to allow deletion of open files and
278278
* passing of other special options.
279279
*/
280+
#define O_DIRECT 0x80000000
280281
extern int pgwin32_open(const char *, int,...);
281282
extern FILE *pgwin32_fopen(const char *, const char *);
282283

src/port/open.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
*
9-
* $PostgreSQL: pgsql/src/port/open.c,v 1.19 2007/02/13 02:06:22 momjian Exp $
9+
* $PostgreSQL: pgsql/src/port/open.c,v 1.20 2007/04/13 10:30:30 mha Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -53,7 +53,6 @@ openFlagsToCreateFileFlags(int openFlags)
5353

5454
/*
5555
* - file attribute setting, based on fileMode?
56-
* - handle other flags? (eg FILE_FLAG_NO_BUFFERING/FILE_FLAG_WRITE_THROUGH)
5756
*/
5857
int
5958
pgwin32_open(const char *fileName, int fileFlags,...)
@@ -65,7 +64,7 @@ pgwin32_open(const char *fileName, int fileFlags,...)
6564
/* Check that we can handle the request */
6665
assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND |
6766
(O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) |
68-
_O_SHORT_LIVED | O_DSYNC |
67+
_O_SHORT_LIVED | O_DSYNC | O_DIRECT |
6968
(O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags);
7069

7170
sa.nLength = sizeof(sa);
@@ -85,7 +84,8 @@ pgwin32_open(const char *fileName, int fileFlags,...)
8584
((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) |
8685
((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) |
8786
((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0) |
88-
((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
87+
((fileFlags & O_DIRECT) ? FILE_FLAG_NO_BUFFERING : 0) |
88+
((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
8989
NULL)) == INVALID_HANDLE_VALUE)
9090
{
9191
switch (GetLastError())

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy