sysv_shmem.c patch is to correct a bug that prevents the postmaster
authorBruce Momjian <bruce@momjian.us>
Thu, 6 May 2004 19:23:25 +0000 (19:23 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 6 May 2004 19:23:25 +0000 (19:23 +0000)
recovering from an unexpected backend termination.

The remaining patches are to allow whitespace in db/install directory
names.

Claudio Natoli

src/backend/port/sysv_shmem.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/postmaster.c

index 1c03fe4866b4df56a8b0c4004244b4cf018eabf1..1aca81f68b8b96528d14c438b9c1b14054afa178 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.33 2004/04/19 17:42:58 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.34 2004/05/06 19:23:25 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -250,7 +250,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
 
 #ifdef EXEC_BACKEND
        /* If Exec case, just attach and return the pointer */
-       if (UsedShmemSegAddr != NULL && !makePrivate)
+       if (UsedShmemSegAddr != NULL && !makePrivate && IsUnderPostmaster)
        {
                void* origUsedShmemSegAddr = UsedShmemSegAddr;
 
index 1267acbbcbe7bfd06dcd866e4fb5034927d328f3..65a37fd6a38b0001a03ddd3ad4d16611dfb447aa 100644 (file)
@@ -13,7 +13,7 @@
  *
  *     Copyright (c) 2001-2003, PostgreSQL Global Development Group
  *
- *     $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.67 2004/04/19 17:42:58 momjian Exp $
+ *     $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.68 2004/05/06 19:23:25 momjian Exp $
  * ----------
  */
 #include "postgres.h"
@@ -485,11 +485,10 @@ pgstat_forkexec(STATS_PROCESS_TYPE procType)
        snprintf(pgstatBuf[bufc++],MAXPGPATH,"%d",MaxBackends);
 
        /* + the pstat file names, and postgres pathname */
-       /* FIXME: [fork/exec] whitespaces in directories? */
-       snprintf(pgstatBuf[bufc++],MAXPGPATH,"%s",pgStat_tmpfname);
-       snprintf(pgstatBuf[bufc++],MAXPGPATH,"%s",pgStat_fname);
-       snprintf(pgstatBuf[bufc++],MAXPGPATH,"%s",pg_pathname);
-       snprintf(pgstatBuf[bufc++],MAXPGPATH,"%s",DataDir);
+       snprintf(pgstatBuf[bufc++],MAXPGPATH,"\"%s\"",pgStat_tmpfname);
+       snprintf(pgstatBuf[bufc++],MAXPGPATH,"\"%s\"",pgStat_fname);
+       snprintf(pgstatBuf[bufc++],MAXPGPATH,"\"%s\"",pg_pathname);
+       snprintf(pgstatBuf[bufc++],MAXPGPATH,"\"%s\"",DataDir);
 
        /* Add to the arg list */
        Assert(bufc <= lengthof(pgstatBuf));
index 3cbd40f3db63914fc2be994e389a643132189cb5..1d781d0bb5afb2b346fcceeabeb2c76e30700e85 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.381 2004/04/19 17:42:58 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.382 2004/05/06 19:23:25 momjian Exp $
  *
  * NOTES
  *
@@ -2741,8 +2741,7 @@ Backend_forkexec(Port *port)
 
        /* Format up context to pass to exec'd process */
        snprintf(buf[bufc++],MAXPGPATH,"%lu",tmpBackendFileNum);
-       /* FIXME: [fork/exec] whitespaces in directories? */
-       snprintf(buf[bufc++],MAXPGPATH,"%s",DataDir);
+       snprintf(buf[bufc++],MAXPGPATH,"\"%s\"",DataDir);
 
        /* Add to the arg list */
        Assert(bufc <= lengthof(buf));
@@ -3039,6 +3038,7 @@ SSDataBase(int xlop)
 #endif
 #else
        char            idbuf[32];
+       char            ddirbuf[MAXPGPATH];
 #endif
 
        fflush(stdout);
@@ -3097,8 +3097,9 @@ SSDataBase(int xlop)
 
 #ifdef EXEC_BACKEND
                /* pass data dir before end of secure switches (-p) */
+               snprintf(ddirbuf, MAXPGPATH, "\"%s\"", DataDir);
                av[ac++] = "-D";
-               av[ac++] = DataDir;
+               av[ac++] = ddirbuf;
 
                /* and the backend identifier + dbname */
                snprintf(idbuf, sizeof(idbuf), "-p%lu,template1", tmpBackendFileNum);
@@ -3490,7 +3491,7 @@ pid_t win32_forkexec(const char* path, char *argv[])
        HANDLE waiterThread;
 
        /* Format the cmd line */
-       snprintf(cmdLine,sizeof(cmdLine),"%s",path);
+       snprintf(cmdLine,sizeof(cmdLine),"\"%s\"",path);
        i = 0;
        while (argv[++i] != NULL)
        {