aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2007-04-13 10:30:30 +0000
committerMagnus Hagander <magnus@hagander.net>2007-04-13 10:30:30 +0000
commit15ebfeec2de8c29585ee4c976c089a7cd95331b2 (patch)
tree7c7621a23981be2dd865ab0f8b0ef5bfc9743678 /src
parent85bbf01e0891488e0a041d9a3595ca74a59d7827 (diff)
downloadpostgresql-15ebfeec2de8c29585ee4c976c089a7cd95331b2.tar.gz
postgresql-15ebfeec2de8c29585ee4c976c089a7cd95331b2.zip
Add O_DIRECT support on Windows.
ITAGAKI Takahiro
Diffstat (limited to 'src')
-rw-r--r--src/include/port.h3
-rw-r--r--src/port/open.c8
2 files changed, 6 insertions, 5 deletions
diff --git a/src/include/port.h b/src/include/port.h
index 147a4de53d3..1d33091f646 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* 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);
/* open() and fopen() replacements to allow deletion of open files and
* passing of other special options.
*/
+#define O_DIRECT 0x80000000
extern int pgwin32_open(const char *, int,...);
extern FILE *pgwin32_fopen(const char *, const char *);
diff --git a/src/port/open.c b/src/port/open.c
index f68b54cb6b3..88fedc8475c 100644
--- a/src/port/open.c
+++ b/src/port/open.c
@@ -6,7 +6,7 @@
*
* 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)
/*
* - file attribute setting, based on fileMode?
- * - handle other flags? (eg FILE_FLAG_NO_BUFFERING/FILE_FLAG_WRITE_THROUGH)
*/
int
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 */
assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND |
(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);
sa.nLength = sizeof(sa);
@@ -85,7 +84,8 @@ pgwin32_open(const char *fileName, int fileFlags,...)
((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) |
((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 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)
{
switch (GetLastError())