Recognize ERROR_SHARING_VIOLATION (translate to EACCES), increase log
authorTom Lane
Fri, 7 Oct 2005 16:34:48 +0000 (16:34 +0000)
committerTom Lane
Fri, 7 Oct 2005 16:34:48 +0000 (16:34 +0000)
level for unrecognized win32 error codes to LOG, and make messages
conform to style guide.  Per old suggestion from Qingqing Zhou, which
seems to have gotten lost in the shuffle.

src/backend/port/win32/error.c

index 426eecbf69bee799c43bb81a4fdd007f0b411a8d..c7f0a24f1028726efffde573aa637a1a570b7158 100644 (file)
@@ -6,14 +6,14 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.4 2004/12/31 22:00:37 pgsql Exp $
+ *   $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.5 2005/10/07 16:34:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "postgres.h"
 
-static struct
+static const struct
 {
    DWORD       winerr;
    int         doserr;
@@ -74,6 +74,9 @@ static struct
    {
        ERROR_LOCK_VIOLATION, EACCES
    },
+   {
+       ERROR_SHARING_VIOLATION, EACCES
+   },
    {
        ERROR_BAD_NETPATH, ENOENT
    },
@@ -168,21 +171,21 @@ _dosmaperr(unsigned long e)
        return;
    }
 
-   for (i = 0; i < sizeof(doserrors) / sizeof(doserrors[0]); i++)
+   for (i = 0; i < lengthof(doserrors); i++)
    {
        if (doserrors[i].winerr == e)
        {
            errno = doserrors[i].doserr;
            ereport(DEBUG5,
-                   (errmsg_internal("Mapped win32 error code %i to %i",
-                                    (int) e, errno)));
+                   (errmsg_internal("mapped win32 error code %lu to %d",
+                                     e, errno)));
            return;
        }
    }
 
-   ereport(DEBUG4,
-           (errmsg_internal("Unknown win32 error code: %i",
-                            (int) e)));
+   ereport(LOG,
+           (errmsg_internal("unrecognized win32 error code: %lu",
+                            e)));
    errno = EINVAL;
    return;
 }