]> granicus.if.org Git - postgresql/blobdiff - src/port/open.c
Centralize single quote escaping in src/port/quotes.c
[postgresql] / src / port / open.c
index f9b703aff6aef81ae03650fda90549c3d2c49d8a..e91641d2a7c3c08edb34786baa4fb7e2c5e54ff0 100644 (file)
@@ -4,9 +4,9 @@
  *        Win32 open() replacement
  *
  *
- * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/port/open.c,v 1.25 2007/12/28 12:32:56 petere Exp $
+ * src/port/open.c
  *
  *-------------------------------------------------------------------------
  */
@@ -82,24 +82,25 @@ pgwin32_open(const char *fileName, int fileFlags,...)
                                         ((fileFlags & O_WRONLY) ? GENERIC_WRITE : GENERIC_READ),
        /* These flags allow concurrent rename/unlink */
                                        (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
-                                               &sa,
-                                               openFlagsToCreateFileFlags(fileFlags),
-                                               FILE_ATTRIBUTE_NORMAL |
+                                                  &sa,
+                                                  openFlagsToCreateFileFlags(fileFlags),
+                                                  FILE_ATTRIBUTE_NORMAL |
                                         ((fileFlags & O_RANDOM) ? FILE_FLAG_RANDOM_ACCESS : 0) |
                           ((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_DIRECT) ? FILE_FLAG_NO_BUFFERING : 0) |
-                                               ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
-                                               NULL)) == INVALID_HANDLE_VALUE)
+                                          ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
+                                                  NULL)) == INVALID_HANDLE_VALUE)
        {
                /*
                 * Sharing violation or locking error can indicate antivirus, backup
-                * or similar software that's locking the file. Try again for 30 seconds
-                * before giving up.
+                * or similar software that's locking the file. Try again for 30
+                * seconds before giving up.
                 */
-               DWORD err = GetLastError();
-               if (err == ERROR_SHARING_VIOLATION || 
+               DWORD           err = GetLastError();
+
+               if (err == ERROR_SHARING_VIOLATION ||
                        err == ERROR_LOCK_VIOLATION)
                {
                        pg_usleep(100000);
@@ -108,10 +109,10 @@ pgwin32_open(const char *fileName, int fileFlags,...)
 #ifndef FRONTEND
                        if (loops == 50)
                                ereport(LOG,
-                                   (errmsg("could not open file \"%s\": %s", fileName, 
-                                         (err == ERROR_SHARING_VIOLATION)?_("sharing violation"):_("lock violation")),
-                                        errdetail("Continuing to retry for 30 seconds."),
-                                        errhint("You might have antivirus, backup, or similar software interfering with the database system.")));
+                                               (errmsg("could not open file \"%s\": %s", fileName,
+                                                               (err == ERROR_SHARING_VIOLATION) ? _("sharing violation") : _("lock violation")),
+                                                errdetail("Continuing to retry for 30 seconds."),
+                                                errhint("You might have antivirus, backup, or similar software interfering with the database system.")));
 #endif
 
                        if (loops < 300)
@@ -123,7 +124,7 @@ pgwin32_open(const char *fileName, int fileFlags,...)
        }
 
        /* _open_osfhandle will, on error, set errno accordingly */
-       if ((fd = _open_osfhandle((long) h, fileFlags & O_APPEND)) < 0)
+       if ((fd = _open_osfhandle((intptr_t) h, fileFlags & O_APPEND)) < 0)
                CloseHandle(h);                 /* will not affect errno */
        else if (fileFlags & (O_TEXT | O_BINARY) &&
                         _setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0)