Commit 15ebfeec authored by Magnus Hagander's avatar Magnus Hagander

Add O_DIRECT support on Windows.

ITAGAKI Takahiro
parent 85bbf01e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.110 2007/02/07 00:28:55 petere Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.111 2007/04/13 10:30:30 mha Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -277,6 +277,7 @@ extern bool rmtree(char *path, bool rmtopdir); ...@@ -277,6 +277,7 @@ extern bool rmtree(char *path, bool rmtopdir);
/* open() and fopen() replacements to allow deletion of open files and /* open() and fopen() replacements to allow deletion of open files and
* passing of other special options. * passing of other special options.
*/ */
#define O_DIRECT 0x80000000
extern int pgwin32_open(const char *, int,...); extern int pgwin32_open(const char *, int,...);
extern FILE *pgwin32_fopen(const char *, const char *); extern FILE *pgwin32_fopen(const char *, const char *);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/port/open.c,v 1.19 2007/02/13 02:06:22 momjian Exp $ * $PostgreSQL: pgsql/src/port/open.c,v 1.20 2007/04/13 10:30:30 mha Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,7 +53,6 @@ openFlagsToCreateFileFlags(int openFlags) ...@@ -53,7 +53,6 @@ openFlagsToCreateFileFlags(int openFlags)
/* /*
* - file attribute setting, based on fileMode? * - file attribute setting, based on fileMode?
* - handle other flags? (eg FILE_FLAG_NO_BUFFERING/FILE_FLAG_WRITE_THROUGH)
*/ */
int int
pgwin32_open(const char *fileName, int fileFlags,...) pgwin32_open(const char *fileName, int fileFlags,...)
...@@ -65,7 +64,7 @@ pgwin32_open(const char *fileName, int fileFlags,...) ...@@ -65,7 +64,7 @@ pgwin32_open(const char *fileName, int fileFlags,...)
/* Check that we can handle the request */ /* Check that we can handle the request */
assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND | assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND |
(O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) | (O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) |
_O_SHORT_LIVED | O_DSYNC | _O_SHORT_LIVED | O_DSYNC | O_DIRECT |
(O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags); (O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags);
sa.nLength = sizeof(sa); sa.nLength = sizeof(sa);
...@@ -85,7 +84,8 @@ pgwin32_open(const char *fileName, int fileFlags,...) ...@@ -85,7 +84,8 @@ pgwin32_open(const char *fileName, int fileFlags,...)
((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) | ((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) |
((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) | ((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) |
((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0) | ((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0) |
((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0), ((fileFlags & O_DIRECT) ? FILE_FLAG_NO_BUFFERING : 0) |
((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
NULL)) == INVALID_HANDLE_VALUE) NULL)) == INVALID_HANDLE_VALUE)
{ {
switch (GetLastError()) switch (GetLastError())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment