OSDN Git Service

Add O_DIRECT support on Windows.
authorMagnus Hagander <magnus@hagander.net>
Fri, 13 Apr 2007 10:30:30 +0000 (10:30 +0000)
committerMagnus Hagander <magnus@hagander.net>
Fri, 13 Apr 2007 10:30:30 +0000 (10:30 +0000)
ITAGAKI Takahiro

src/include/port.h
src/port/open.c

index 147a4de..1d33091 100644 (file)
@@ -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 *);
 
index f68b54c..88fedc8 100644 (file)
@@ -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())