* Most changes are to fix warnings issued when compiling win32
authorBruce Momjian <bruce@momjian.us>
Mon, 19 Apr 2004 17:42:59 +0000 (17:42 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 19 Apr 2004 17:42:59 +0000 (17:42 +0000)
* removed a few redundant defines
* get_user_name safe under win32
* rationalized pipe read EOF for win32 (UPDATED PATCH USED)
* changed all backend instances of sleep() to pg_usleep

    - except for the SLEEP_ON_ASSERT in assert.c, as it would exceed a
32-bit long [Note to patcher: If a SLEEP_ON_ASSERT of 2000 seconds is
acceptable, please replace with pg_usleep(2000000000L)]

I added a comment to that part of the code:

    /*
     *  It would be nice to use pg_usleep() here, but only does 2000 sec
     *  or 33 minutes, which seems too short.
     */
    sleep(1000000);

Claudio Natoli

29 files changed:
src/backend/access/transam/xlog.c
src/backend/commands/dbcommands.c
src/backend/libpq/md5.c
src/backend/main/main.c
src/backend/port/sysv_shmem.c
src/backend/port/win32/shmem.c
src/backend/port/win32/timer.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/postmaster.c
src/backend/storage/smgr/md.c
src/backend/tcop/postgres.c
src/backend/utils/error/assert.c
src/backend/utils/hash/dynahash.c
src/backend/utils/init/miscinit.c
src/bin/psql/common.h
src/bin/psql/copy.c
src/bin/psql/startup.c
src/bin/scripts/common.c
src/include/port.h
src/include/port/win32.h
src/include/storage/ipc.h
src/interfaces/libpq/Makefile
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/win32.c
src/interfaces/libpq/win32.h
src/port/open.c
src/port/pipe.c
src/port/rand.c
src/port/sprompt.c

index d07f9edaecc568858e53a6b4a857ea48ec5bbfe4..6a1ccef8ec50d3ed6dbfa92f4437e935c73f6eb7 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.138 2004/03/22 04:16:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.139 2004/04/19 17:42:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2830,7 +2830,7 @@ StartupXLOG(void)
        /* This is just to allow attaching to startup process with a debugger */
 #ifdef XLOG_REPLAY_DELAY
        if (ControlFile->state != DB_SHUTDOWNED)
-               sleep(60);
+               pg_usleep(60000000L);
 #endif
 
        /*
@@ -3360,7 +3360,7 @@ CreateCheckPoint(bool shutdown, bool force)
        while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
        {
                CHECK_FOR_INTERRUPTS();
-               sleep(1);
+               pg_usleep(1000000L);
        }
 
        /*
index 85f49537efce589c7722f5d7491e455b232ce2dd..038db4de70e22d042a07c4bafc31ce24b5b67f55 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.131 2004/02/10 01:55:25 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.132 2004/04/19 17:42:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,9 @@ createdb(const CreatedbStmt *stmt)
        char       *alt_loc;
        char       *target_dir;
        char            src_loc[MAXPGPATH];
+#ifndef WIN32
        char            buf[2 * MAXPGPATH + 100];
+#endif
        Oid                     src_dboid;
        AclId           src_owner;
        int                     src_encoding;
index 4c194dde05fb10010fa2e55b60149351a1ee6fac..b9a11cbf5cf2492d6fde3c73ace83c63fb791e0a 100644 (file)
@@ -14,7 +14,7 @@
  *     Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.23 2004/03/24 03:44:58 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.24 2004/04/19 17:42:57 momjian Exp $
  */
 
 
@@ -33,9 +33,7 @@
 
 #ifdef FRONTEND
 #include "postgres_fe.h"
-#ifndef WIN32
 #include "libpq/crypt.h"
-#endif   /* WIN32 */
 #endif   /* FRONTEND */
 
 #ifdef MD5_ODBC
index b2557572184399831c85120073488c77b6b4bd00..b0b394fe8b9f3a51d6e8f7f7ea462afd037fa0ae 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/main/main.c,v 1.77 2004/04/19 17:42:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -50,7 +50,9 @@ int
 main(int argc, char *argv[])
 {
        int                     len;
+#ifndef WIN32
        struct passwd *pw;
+#endif
        char       *pw_name_persist;
 
        /*
index 72d693f5f21f6e82cac652a3693df62c6c3ed59b..1c03fe4866b4df56a8b0c4004244b4cf018eabf1 100644 (file)
@@ -10,7 +10,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.32 2004/02/25 19:41:22 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.33 2004/04/19 17:42:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -259,7 +259,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
                PGSharedMemoryDetach();
                UsedShmemSegAddr = origUsedShmemSegAddr;
 #endif
-               elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
+               elog(DEBUG3,"Attaching to %p",UsedShmemSegAddr);
                hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
                if (hdr == NULL)
                        elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",
index 7992268438dab3b6c9f6caa7a5ae783228bfdf6b..89bcadc8cdc9c905ccc1bcccc749974dc2c12a1f 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.4 2004/02/12 20:37:34 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.5 2004/04/19 17:42:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,7 @@ static DWORD s_segsize = 0;
 int
 shmdt(const void *shmaddr)
 {
-       if (UnmapViewOfFile(shmaddr))
+       if (UnmapViewOfFile((LPCVOID*)shmaddr))
                return 0;
        else
                return -1;
index 8202efe3c4bd99fbcb52708433d9b09210894210..b905799875a0cc88fe58b8ded1c5f83750f7b3f0 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.1 2004/02/18 16:25:12 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.2 2004/04/19 17:42:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -43,9 +43,9 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
                timerHandle = CreateWaitableTimer(NULL, TRUE, NULL);
                if (timerHandle == NULL)
                        ereport(FATAL,
-                                       (errmsg_internal("failed to create waitable timer: %i",GetLastError())));
+                                       (errmsg_internal("failed to create waitable timer: %i",(int)GetLastError())));
        }
-       
+
        if (value->it_value.tv_sec == 0 &&
                value->it_value.tv_usec == 0) {
                /* Turn timer off */
@@ -55,11 +55,11 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
 
        /* Negative time to SetWaitableTimer means relative time */
        dueTime.QuadPart = -(value->it_value.tv_usec*10 + value->it_value.tv_sec*10000000L);
-       
+
        /* Turn timer on, or change timer */
-       if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE)) 
+       if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
                ereport(FATAL,
-                               (errmsg_internal("failed to set waitable timer: %i",GetLastError())));
+                               (errmsg_internal("failed to set waitable timer: %i",(int)GetLastError())));
 
        return 0;
 }
index 87c9d09fcd9159712dd94ce2fb9e72c586e6717c..1267acbbcbe7bfd06dcd866e4fb5034927d328f3 100644 (file)
@@ -13,7 +13,7 @@
  *
  *     Copyright (c) 2001-2003, PostgreSQL Global Development Group
  *
- *     $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.66 2004/04/12 16:19:18 momjian Exp $
+ *     $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.67 2004/04/19 17:42:58 momjian Exp $
  * ----------
  */
 #include "postgres.h"
@@ -1730,13 +1730,6 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
                                {
                                        if (errno == EINTR)
                                                continue;
-#ifdef WIN32
-                                       if (WSAGetLastError() == WSAECONNRESET) /* EOF on the pipe! (win32 socket based implementation) */
-                                       {
-                                               pipeEOF = true;
-                                               break;
-                                       }
-#endif
                                        ereport(LOG,
                                                        (errcode_for_socket_access(),
                                                         errmsg("could not read from statistics collector pipe: %m")));
index 6876044a6a9aa533bbd0262c4bcfc64e2f0e1ce4..3cbd40f3db63914fc2be994e389a643132189cb5 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.380 2004/04/12 16:19:18 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.381 2004/04/19 17:42:58 momjian Exp $
  *
  * NOTES
  *
@@ -314,8 +314,6 @@ static unsigned long tmpBackendFileNum = 0;
 void read_backend_variables(unsigned long id, Port *port);
 static bool write_backend_variables(Port *port);
 
-size_t                 ShmemBackendArraySize(void);
-void           ShmemBackendArrayAllocation(void);
 static void    ShmemBackendArrayAdd(Backend *bn);
 static void ShmemBackendArrayRemove(pid_t pid);
 #endif
@@ -2561,7 +2559,7 @@ BackendRun(Port *port)
         * PGOPTIONS, but it is not honored until after authentication.)
         */
        if (PreAuthDelay > 0)
-               sleep(PreAuthDelay);
+               pg_usleep(PreAuthDelay*1000000L);
 
        /* Will exit on failure */
        BackendInit(port);
@@ -3455,8 +3453,8 @@ static void ShmemBackendArrayAdd(Backend *bn)
                }
        }
 
-       /* FIXME: [fork/exec] some sort of error */
-       abort();
+       ereport(FATAL,
+                       (errmsg_internal("unable to add backend entry")));
 }
 
 static void ShmemBackendArrayRemove(pid_t pid)
@@ -3472,7 +3470,6 @@ static void ShmemBackendArrayRemove(pid_t pid)
                }
        }
 
-       /* Something stronger than WARNING here? */
        ereport(WARNING,
                        (errmsg_internal("unable to find backend entry with pid %d",
                                                         pid)));
@@ -3565,8 +3562,9 @@ static void win32_AddChild(pid_t pid, HANDLE handle)
                ++win32_numChildren;
        }
        else
-               /* FIXME: [fork/exec] some sort of error */
-               abort();
+               ereport(FATAL,
+                               (errmsg_internal("unable to add child entry with pid %lu",
+                                                                pid)));
 }
 
 static void win32_RemoveChild(pid_t pid)
@@ -3588,7 +3586,6 @@ static void win32_RemoveChild(pid_t pid)
                }
        }
 
-       /* Something stronger than WARNING here? */
        ereport(WARNING,
                        (errmsg_internal("unable to find child entry with pid %lu",
                                                         pid)));
index 7d27b9bde9dd34524a09d5e412839ed58479f6d8..2122a243207b12049b5d655e3a01305e70b3aade 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.103 2004/02/11 22:55:25 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.104 2004/04/19 17:42:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -607,7 +607,7 @@ mdsync(void)
 {
        sync();
        if (IsUnderPostmaster)
-               sleep(2);
+               pg_usleep(2000000L);
        sync();
        return true;
 }
index 09fc57b6ea1f095032cb545200a8ed7ccfa98afc..1affe7d49b9f8c3cf0f0a6cd379b30589e755a3e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.399 2004/04/11 00:54:44 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.400 2004/04/19 17:42:58 momjian Exp $
  *
  * NOTES
  *       this is the "main" module of the postgres backend and
@@ -2456,7 +2456,7 @@ PostgresMain(int argc, char *argv[], const char *username)
                                /*
                                 * wait N seconds to allow attach from a debugger
                                 */
-                               sleep(atoi(optarg));
+                               pg_usleep(atoi(optarg)*1000000L);
                                break;
 
                        case 'x':
index afd30b081f23a7e0c0db9466119487b78b48edf1..f35636e9fecdf6a9d436bd7dde5b9fd589f13425 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.25 2003/11/29 19:52:01 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.26 2004/04/19 17:42:58 momjian Exp $
  *
  * NOTE
  *       This should eventually work with elog()
@@ -40,7 +40,11 @@ ExceptionalCondition(char *conditionName,
        }
 
 #ifdef SLEEP_ON_ASSERT
-       sleep(1000000);
+       /*
+        *      It would be nice to use pg_usleep() here, but only does 2000 sec
+        *      or 33 minutes, which seems too short.
+        */      
+       sleep(1000000); 
 #endif
 
        abort();
index c58359ccb8212f8b2940c3c2381663a8a7019f26..e72800f3a79802f768af43a807b0e2a0e610b083 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.50 2003/12/29 23:54:22 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.51 2004/04/19 17:42:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -85,6 +85,7 @@ DynaHashAlloc(Size size)
 }
 
 #define MEM_ALLOC              DynaHashAlloc
+#undef         MEM_FREE        /* already in windows header files */
 #define MEM_FREE               pfree
 
 
index 075269b4ad07cbea0b2c8a57c043ee2ead6308d6..75cc07a518d163ac3936677542c4ca6e12f00e47 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.123 2004/02/10 01:55:26 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.124 2004/04/19 17:42:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -213,11 +213,11 @@ SetDataDir(const char *dir)
         * generating funny-looking paths to individual files.
         */
        newlen = strlen(new);
-       if (newlen > 1 && new[newlen - 1] == '/'
+       if (newlen > 1 && (new[newlen - 1] == '/'
 #ifdef WIN32
                || new[newlen - 1] == '\\'
 #endif
-               )
+               ))
                new[newlen - 1] = '\0';
 
        if (DataDir)
index 43045240c25f2729bf0393f7ca3e8c0f6ca79ea6..99510dcb8c91d1e5a76a1cda88d35d0d80a8d77c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.34 2004/01/25 03:07:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.35 2004/04/19 17:42:58 momjian Exp $
  */
 #ifndef COMMON_H
 #define COMMON_H
@@ -60,12 +60,6 @@ extern const char *session_username(void);
  */
 extern char parse_char(char **buf);
 
-/* Used for all Win32 popen/pclose calls */
-#ifdef WIN32
-#define popen(x,y) _popen(x,y)
-#define pclose(x) _pclose(x)
-#endif
-
 extern char *expand_tilde(char **filename);
 
 #endif   /* COMMON_H */
index e01afb821423491b989d0c754faa7adc01509155..0241b8eda27f708f0ea87e6320f785170b27202e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.44 2004/04/19 17:22:31 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.45 2004/04/19 17:42:58 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "copy.h"
@@ -26,7 +26,7 @@
 #include "prompt.h"
 #include "stringutils.h"
 
-#ifdef WIN32
+#if defined(WIN32) && (!defined(__MINGW32__))
 #define strcasecmp(x,y) stricmp(x,y)
 #define __S_ISTYPE(mode, mask) (((mode) & S_IFMT) == (mask))
 #define S_ISDIR(mode)   __S_ISTYPE((mode), S_IFDIR)
index 4991c7b7456a7dfad316366c2d271c92abfbf27c..3d321b79921788ff83697454db604285deeb0373 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.87 2004/03/24 03:10:29 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.88 2004/04/19 17:42:58 momjian Exp $
  */
 #include "postgres_fe.h"
 
@@ -573,8 +573,8 @@ process_psqlrc(void)
        char       *psqlrc;
        char       *home;
 
-#ifdef WIN32
-#define R_OK 0
+#if defined(WIN32) && (!defined(__MINGW32__))
+#define R_OK 4
 #endif
 
        /* Look for one in the home dir */
index 63204ece3d71a02e29380082ea5f87f51d5d57e5..f14e0b206e18ab4a67f7a8a99d9761b1e1873341 100644 (file)
@@ -5,7 +5,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.6 2003/11/29 19:52:07 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.7 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,10 +35,15 @@ get_user_name(const char *progname)
        return pw->pw_name;
 #else
        static char username[128];      /* remains after function exit */
+       DWORD len = sizeof(username)-1;
 
-       GetUserName(username, sizeof(username)-1);
+       if (!GetUserName(username, &len))
+       {
+               perror(progname);
+               exit(1);
+       }
        return username;
-#endif 
+#endif
 }
 
 
index e539d1f25db141b654aed2c0f8f1d0420edae56a..93b549503fd0c121ab05e9e066b568889905f06d 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/port.h,v 1.24 2004/04/05 03:16:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.25 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,7 +48,7 @@ extern off_t ftello(FILE *stream);
 #define pipewrite(a,b,c)       write(a,b,c)
 #else
 extern int pgpipe(int handles[2]);
-#define piperead(a,b,c)                recv(a,b,c,0)
+extern int piperead(int s, char* buf, int len);
 #define pipewrite(a,b,c)       send(a,b,c,0)
 #endif
 
@@ -70,6 +70,11 @@ extern int   win32_open(const char*,int,...);
 #define        open(a,b,...)   win32_open(a,b,##__VA_ARGS__)
 #endif
 
+#ifndef __BORLANDC__
+#define popen(a,b) _popen(a,b)
+#define pclose(a) _pclose(a)
+#endif
+
 extern int     copydir(char *fromdir, char *todir);
 
 /* Missing rand functions */
index d1e55725b9fe6ca3580611f2fa09659824b646af..fb91e66468bc08c7f98927ffcec68b9c0ea84cf8 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.21 2004/04/12 16:19:18 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.22 2004/04/19 17:42:59 momjian Exp $ */
 
 /* undefine and redefine after #include */
 #undef mkdir
@@ -6,6 +6,7 @@
 #undef ERROR
 #include <windows.h>
 #include <winsock.h>
+#include <process.h>
 #undef near
 
 /* Must be here to avoid conflicting with prototype in windows.h */
@@ -192,14 +193,6 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
  */
 #define lstat slat
 
-#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
-#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
-
-#define S_IRUSR _S_IREAD
-#define S_IWUSR _S_IWRITE
-#define S_IXUSR _S_IEXEC
-#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
-
 /*
  * Supplement to <errno.h>.
  */
index 899198447f245766f1714a1b8c6de601475c02ab..3dcfe41bfc1085b783c4f95e6f8b59035c7acdd3 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.65 2004/02/25 19:41:23 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/ipc.h,v 1.66 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,4 +32,11 @@ extern void on_exit_reset(void);
 extern void CreateSharedMemoryAndSemaphores(bool makePrivate,
                                                                                        int maxBackends,
                                                                                        int port);
+
+#ifdef EXEC_BACKEND
+/* postmaster.c */
+extern size_t  ShmemBackendArraySize(void);
+extern void            ShmemBackendArrayAllocation(void);
+#endif
+
 #endif   /* IPC_H */
index f9031e79b2553bb459dde9bd3ce44ad3eca89894..3842fe6e131bb614de8def887c9898358f719592 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.100 2004/03/24 03:54:16 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.101 2004/04/19 17:42:59 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -78,4 +78,4 @@ uninstall: uninstall-lib
        rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
 
 clean distclean maintainer-clean: clean-lib
-       rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
+       rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c snprintf.c strerror.c open.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
index 9afa1294e6f3fc7d4f35988a1f3ea0cbfce678e3..64b53fda3ab1b959f26f45d1efd33951db7742b3 100644 (file)
@@ -10,7 +10,7 @@
  * didn't really belong there.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.50 2004/01/09 02:02:43 momjian Exp $
+ *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.51 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -183,11 +183,7 @@ PQprint(FILE *fout,
                                  - (po->header != 0) * 2               /* row count and newline */
                                  )))
                        {
-#ifdef WIN32
-                               fout = _popen(pagerenv, "w");
-#else
                                fout = popen(pagerenv, "w");
-#endif
                                if (fout)
                                {
                                        usePipe = 1;
index 96097bca5970e0aa16bf20ad8f2fea4b68332a1b..c0bdf58ffdac94d90f610b4916a95f2a574ab0f3 100644 (file)
@@ -309,14 +309,14 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
        }
 
        if (!success)
-               sprintf(strerrbuf, "Unknown socket error (0x%08X/%lu)", err, err);
+               sprintf(strerrbuf, "Unknown socket error (0x%08X/%i)", err, err);
        else
        {
                strerrbuf[buflen - 1] = '\0';
                offs = strlen(strerrbuf);
                if (offs > (int)buflen - 64)
                        offs = buflen - 64;
-               sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
+               sprintf(strerrbuf + offs, " (0x%08X/%i)", err, err);
        }
        return strerrbuf;
 }
index 9d4557fc0d51d8e52468fdc15fa0f08915ae0c81..350b350b48d88d486f1f49517965b516751a4578 100644 (file)
@@ -22,8 +22,6 @@
 #define write(a,b,c) _write(a,b,c)
 #endif
 
-#define popen(a,b) _popen(a,b)
-#define pclose(a) _pclose(a)
 #define vsnprintf(a,b,c,d) _vsnprintf(a,b,c,d)
 #define snprintf _snprintf
 
index ccd2a15b1de6be7bdda592a8056f4f84528216b7..627922b600e4739d90a2ab5d1d4cecdea2c0ea61 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/port/open.c,v 1.1 2004/03/24 03:54:16 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/open.c,v 1.2 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,8 @@
 #include <errno.h>
 #include <assert.h>
 
-int openFlagsToCreateFileFlags(int openFlags)
+static int
+openFlagsToCreateFileFlags(int openFlags)
 {
        switch (openFlags & (O_CREAT|O_TRUNC|O_EXCL))
        {
index fe94c091113d85d0991bf303596a889a989d0d5f..4a707f7335c677a6d30a0fb21452391581833c50 100644 (file)
@@ -10,7 +10,7 @@
  *     must be replaced with recv/send.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/port/pipe.c,v 1.1 2004/01/09 04:58:09 momjian Exp $
+ *       $PostgreSQL: pgsql/src/port/pipe.c,v 1.2 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,3 +53,13 @@ pgpipe(int handles[2])
        closesocket(s);
        return 0;
 }
+
+
+int piperead(int s, char* buf, int len)
+{
+       int ret = recv(s,buf,len,0);
+       if (ret < 0 && WSAGetLastError() == WSAECONNRESET)
+               /* EOF on the pipe! (win32 socket based implementation) */
+               ret = 0;
+       return ret;
+}
index faeec88b289f539705d2597d0512a76b8d0250b0..7fc3094decb3dc75c879fbc146996001d8efe5a4 100644 (file)
@@ -5,6 +5,7 @@
  *
  *-------------------------------------------------------------------------
  */
+#include "c.h"
 
 /*
  * Copyright (c) 1993 Martin Birgmeier
@@ -38,7 +39,7 @@ unsigned short _rand48_mult[3] = {
 };
 unsigned short _rand48_add = RAND48_ADD;
 
-void
+static void
 _dorand48(unsigned short xseed[3])
 {
        unsigned long accu;
index e771b5ebbc725c6cb7b3a2475d07ec961f77970b..664d4bc606e530fc6e48d4ac66d395c76a096633 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/port/sprompt.c,v 1.4 2003/11/29 19:52:13 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/port/sprompt.c,v 1.5 2004/04/19 17:42:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,8 +54,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
 
 #else
 #ifdef WIN32
-       HANDLE          t;
-       LPDWORD         t_orig;
+       HANDLE          t = NULL;
+       LPDWORD         t_orig  = NULL;
 #endif
 #endif