Index: src/backend/bootstrap/bootstrap.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/bootstrap/bootstrap.c,v retrieving revision 1.171 diff -w -c -r1.171 bootstrap.c *** src/backend/bootstrap/bootstrap.c 20 Dec 2003 17:31:21 -0000 1.171 --- src/backend/bootstrap/bootstrap.c 21 Dec 2003 04:46:50 -0000 *************** *** 48,53 **** --- 48,58 ---- #define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t))) + #ifdef EXEC_BACKEND + typedef struct Port Port; + extern void SSDataBaseInit(int); + extern void read_backend_variables(pid_t, Port*); + #endif extern int Int_yyparse(void); static hashnode *AddStr(char *str, int strlength, int mderef); *************** *** 238,244 **** * * If we are running under the postmaster, this is done already. */ ! if (!IsUnderPostmaster /* when exec || ExecBackend */ ) MemoryContextInit(); /* --- 243,249 ---- * * If we are running under the postmaster, this is done already. */ ! if (!IsUnderPostmaster || ExecBackend) MemoryContextInit(); /* *************** *** 247,253 **** /* Set defaults, to be overriden by explicit options below */ dbname = NULL; ! if (!IsUnderPostmaster /* when exec || ExecBackend */ ) { InitializeGUCOptions(); potential_DataDir = getenv("PGDATA"); /* Null if no PGDATA --- 252,258 ---- /* Set defaults, to be overriden by explicit options below */ dbname = NULL; ! if (!IsUnderPostmaster) { InitializeGUCOptions(); potential_DataDir = getenv("PGDATA"); /* Null if no PGDATA *************** *** 285,308 **** xlogop = atoi(optarg); break; case 'p': - { - /* indicates fork from postmaster */ #ifdef EXEC_BACKEND ! char *p; ! ! sscanf(optarg, "%lu,%p,", ! &UsedShmemSegID, ! &UsedShmemSegAddr); ! p = strchr(optarg, ','); ! if (p) ! p = strchr(p + 1, ','); ! if (p) ! dbname = strdup(p + 1); ! #else ! dbname = strdup(optarg); #endif break; - } case 'B': SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV); break; --- 290,300 ---- xlogop = atoi(optarg); break; case 'p': #ifdef EXEC_BACKEND ! IsUnderPostmaster = true; #endif + dbname = strdup(optarg); break; case 'B': SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV); break; *************** *** 347,358 **** if (!dbname || argc != optind) usage(); ! #ifdef EXEC_BACKEND ! if (IsUnderPostmaster && MyProc /* ordinary backend */ ) ! AttachSharedMemoryAndSemaphores(); ! #endif ! ! if (!IsUnderPostmaster /* when exec || ExecBackend */ ) { if (!potential_DataDir) { --- 339,345 ---- if (!dbname || argc != optind) usage(); ! if (!IsUnderPostmaster || ExecBackend) { if (!potential_DataDir) { *************** *** 376,381 **** --- 363,371 ---- { #ifdef EXEC_BACKEND read_nondefault_variables(); + read_backend_variables(getpid(),NULL); + + SSDataBaseInit(xlogop); #endif } else *************** *** 427,432 **** --- 417,426 ---- SetProcessingMode(BootstrapProcessing); IgnoreSystemIndexes(true); + #ifdef EXEC_BACKEND + if (IsUnderPostmaster) + AttachSharedMemoryAndSemaphores(); + #endif XLOGPathInit(); BaseInit(); Index: src/backend/main/main.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/main/main.c,v retrieving revision 1.66 diff -w -c -r1.66 main.c *** src/backend/main/main.c 29 Nov 2003 19:51:49 -0000 1.66 --- src/backend/main/main.c 21 Dec 2003 04:46:51 -0000 *************** *** 39,44 **** --- 39,45 ---- #include "tcop/tcopprot.h" #include "utils/help_config.h" #include "utils/ps_status.h" + #include "pgstat.h" *************** *** 202,210 **** /* * Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain, ! * or BootstrapMain depending on the program name (and possibly first ! * argument) we were called with. The lack of consistency here is ! * historical. */ len = strlen(new_argv[0]); --- 203,211 ---- /* * Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain, ! * pgstat_main, pgstat_mainChild or BootstrapMain depending on the ! * program name (and possibly first argument) we were called with. ! * The lack of consistency here is historical. */ len = strlen(new_argv[0]); *************** *** 220,225 **** --- 221,248 ---- */ if (argc > 1 && strcmp(new_argv[1], "-boot") == 0) exit(BootstrapMain(argc - 1, new_argv + 1)); + + #ifdef EXEC_BACKEND + /* + * If the first argument is "-statBuf", then invoke pgstat_main. Note + * we remove "-statBuf" from the arguments passed on to pgstat_main. + */ + if (argc > 1 && strcmp(new_argv[1], "-statBuf") == 0) + { + pgstat_main(argc - 2, new_argv + 2); + exit(0); + } + + /* + * If the first argument is "-statCol", then invoke pgstat_mainChild. Note + * we remove "-statCol" from the arguments passed on to pgstat_mainChild. + */ + if (argc > 1 && strcmp(new_argv[1], "-statCol") == 0) + { + pgstat_mainChild(argc - 2, new_argv + 2); + exit(0); + } + #endif /* * If the first argument is "--describe-config", then invoke runtime Index: src/backend/postmaster/pgstat.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v retrieving revision 1.49 diff -w -c -r1.49 pgstat.c *** src/backend/postmaster/pgstat.c 20 Dec 2003 17:31:21 -0000 1.49 --- src/backend/postmaster/pgstat.c 21 Dec 2003 04:47:00 -0000 *************** *** 106,112 **** * Local function forward declarations * ---------- */ ! static void pgstat_main(void); static void pgstat_recvbuffer(void); static void pgstat_die(SIGNAL_ARGS); --- 106,118 ---- * Local function forward declarations * ---------- */ ! #ifdef EXEC_BACKEND ! static void pgstat_exec(STATS_PROCESS_TYPE procType); ! static void pgstat_parseArgs(PGSTAT_FORK_ARGS); ! #endif ! NON_EXEC_STATIC void pgstat_main(PGSTAT_FORK_ARGS); ! NON_EXEC_STATIC void pgstat_mainChild(PGSTAT_FORK_ARGS); ! static void pgstat_mainInit(void); static void pgstat_recvbuffer(void); static void pgstat_die(SIGNAL_ARGS); *************** *** 328,333 **** --- 334,422 ---- } + #ifdef EXEC_BACKEND + + /* ---------- + * pgstat_exec() - + * + * Used to format up the arglist for, and exec, statistics + * (buffer and collector) processes + * + */ + static void + pgstat_exec(STATS_PROCESS_TYPE procType) + { + char *av[11]; + int ac = 0, bufc = 0, i; + char pgstatBuf[8][MAXPGPATH]; + + av[ac++] = "postgres"; + switch (procType) + { + case STAT_PROC_BUFFER: + av[ac++] = "-statBuf"; + break; + + case STAT_PROC_COLLECTOR: + av[ac++] = "-statCol"; + break; + + default: + Assert(false); + } + + /* Sockets + pipes */ + bufc = 0; + snprintf(pgstatBuf[bufc++],MAXPGPATH,"%d",pgStatSock); + snprintf(pgstatBuf[bufc++],MAXPGPATH,"%d",pgStatPmPipe[0]); + snprintf(pgstatBuf[bufc++],MAXPGPATH,"%d",pgStatPmPipe[1]); + snprintf(pgstatBuf[bufc++],MAXPGPATH,"%d",pgStatPipe[0]); + snprintf(pgstatBuf[bufc++],MAXPGPATH,"%d",pgStatPipe[1]); + + /* + 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); + + /* Add to the arg list */ + Assert(bufc <= lengthof(pgstatBuf)); + for (i = 0; i < bufc; i++) + av[ac++] = pgstatBuf[i]; + + av[ac++] = NULL; + Assert(ac <= lengthof(av)); + + if (execv(pg_pathname,av) == -1) + /* FIXME: [fork/exec] suggestions for what to do here? Can't call elog... */ + Assert(false); + } + + + /* ---------- + * pgstat_parseArgs() - + * + * Used to unformat the arglist for exec'ed statistics + * (buffer and collector) processes + * + */ + static void + pgstat_parseArgs(PGSTAT_FORK_ARGS) + { + Assert(argc == 8); + argc = 0; + pgStatSock = atoi(argv[argc++]); + pgStatPmPipe[0] = atoi(argv[argc++]); + pgStatPmPipe[1] = atoi(argv[argc++]); + pgStatPipe[0] = atoi(argv[argc++]); + pgStatPipe[1] = atoi(argv[argc++]); + strncpy(pgStat_tmpfname,argv[argc++],MAXPGPATH); + strncpy(pgStat_fname, argv[argc++],MAXPGPATH); + strncpy(pg_pathname, argv[argc++],MAXPGPATH); + } + + #endif + /* ---------- * pgstat_start() - * *************** *** 416,437 **** beos_backend_startup(); #endif - IsUnderPostmaster = true; /* we are a postmaster subprocess now */ - - MyProcPid = getpid(); /* reset MyProcPid */ - - /* Lose the postmaster's on-exit routines */ - on_exit_reset(); - /* Close the postmaster's sockets, except for pgstat link */ ClosePostmasterPorts(false); /* Drop our connection to postmaster's shared memory, as well */ PGSharedMemoryDetach(); pgstat_main(); ! ! exit(0); } --- 505,521 ---- beos_backend_startup(); #endif /* Close the postmaster's sockets, except for pgstat link */ ClosePostmasterPorts(false); /* Drop our connection to postmaster's shared memory, as well */ PGSharedMemoryDetach(); + #ifdef EXEC_BACKEND + pgstat_exec(STAT_PROC_BUFFER); + #else pgstat_main(); ! #endif } *************** *** 1228,1262 **** *------------------------------------------------------------ */ - - /* ---------- - * pgstat_main() - - * - * Start up the statistics collector itself. This is the body of the - * postmaster child process. - * ---------- - */ static void ! pgstat_main(void) { ! PgStat_Msg msg; ! fd_set rfds; ! int readPipe; ! int pmPipe = pgStatPmPipe[0]; ! int maxfd; ! int nready; ! int len = 0; ! struct timeval timeout; ! struct timeval next_statwrite; ! bool need_statwrite; ! HASHCTL hash_ctl; ! /* ! * Close the writing end of the postmaster pipe, so we'll see it ! * closing when the postmaster terminates and can terminate as well. ! */ ! closesocket(pgStatPmPipe[1]); ! pgStatPmPipe[1] = -1; /* * Ignore all signals usually bound to some action in the postmaster, --- 1312,1326 ---- *------------------------------------------------------------ */ static void ! pgstat_mainInit(void) { ! IsUnderPostmaster = true; /* we are a postmaster subprocess now */ ! MyProcPid = getpid(); /* reset MyProcPid */ ! ! /* Lose the postmaster's on-exit routines */ ! on_exit_reset(); /* * Ignore all signals usually bound to some action in the postmaster, *************** *** 1275,1280 **** --- 1339,1369 ---- pqsignal(SIGTTOU, SIG_DFL); pqsignal(SIGCONT, SIG_DFL); pqsignal(SIGWINCH, SIG_DFL); + } + + + /* ---------- + * pgstat_main() - + * + * Start up the statistics collector itself. This is the body of the + * postmaster child process. + * ---------- + */ + NON_EXEC_STATIC void + pgstat_main(PGSTAT_FORK_ARGS) + { + pgstat_mainInit(); /* Note: for *both* EXEC_BACKEND and regular cases */ + + #ifdef EXEC_BACKEND + pgstat_parseArgs(argc,argv); + #endif + + /* + * Close the writing end of the postmaster pipe, so we'll see it + * closing when the postmaster terminates and can terminate as well. + */ + closesocket(pgStatPmPipe[1]); + pgStatPmPipe[1] = -1; /* * Start a buffering process to read from the socket, so we have a *************** *** 1305,1313 **** case 0: /* child becomes collector process */ ! closesocket(pgStatPipe[1]); ! closesocket(pgStatSock); ! break; default: /* parent becomes buffer process */ --- 1394,1405 ---- case 0: /* child becomes collector process */ ! #ifdef EXEC_BACKEND ! pgstat_exec(STAT_PROC_COLLECTOR); ! #else ! pgstat_mainChild(); ! #endif ! exit(0); default: /* parent becomes buffer process */ *************** *** 1315,1328 **** pgstat_recvbuffer(); exit(0); } /* * In the child we can have default SIGCHLD handling (in case we want * to call system() here...) */ pqsignal(SIGCHLD, SIG_DFL); - - MyProcPid = getpid(); /* reset MyProcPid */ /* * Identify myself via ps --- 1407,1448 ---- pgstat_recvbuffer(); exit(0); } + } + + + NON_EXEC_STATIC void + pgstat_mainChild(PGSTAT_FORK_ARGS) + { + PgStat_Msg msg; + fd_set rfds; + int readPipe; + int pmPipe; + int maxfd; + int nready; + int len = 0; + struct timeval timeout; + struct timeval next_statwrite; + bool need_statwrite; + HASHCTL hash_ctl; + + #ifdef EXEC_BACKEND + MemoryContextInit(); /* before any elog'ing can occur */ + + pgstat_mainInit(); + pgstat_parseArgs(argc,argv); + #else + MyProcPid = getpid(); /* reset MyProcPid */ + #endif + + closesocket(pgStatPipe[1]); + closesocket(pgStatSock); + pmPipe = pgStatPmPipe[0]; /* * In the child we can have default SIGCHLD handling (in case we want * to call system() here...) */ pqsignal(SIGCHLD, SIG_DFL); /* * Identify myself via ps Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v retrieving revision 1.352 diff -w -c -r1.352 postmaster.c *** src/backend/postmaster/postmaster.c 20 Dec 2003 17:31:21 -0000 1.352 --- src/backend/postmaster/postmaster.c 21 Dec 2003 04:47:06 -0000 *************** *** 289,294 **** --- 289,295 ---- static void SignalChildren(int signal); static int CountChildren(void); static bool CreateOptsFile(int argc, char *argv[]); + NON_EXEC_STATIC void SSDataBaseInit(int xlop); static pid_t SSDataBase(int xlop); static void postmaster_error(const char *fmt,...) *************** *** 296,303 **** __attribute__((format(printf, 1, 2))); #ifdef EXEC_BACKEND ! static void ! write_backend_variables(pid_t pid, Port *port); #endif #define StartupDataBase() SSDataBase(BS_XLOG_STARTUP) --- 297,304 ---- __attribute__((format(printf, 1, 2))); #ifdef EXEC_BACKEND ! void read_backend_variables(pid_t pid, Port *port); ! static void write_backend_variables(pid_t pid, Port *port); #endif #define StartupDataBase() SSDataBase(BS_XLOG_STARTUP) *************** *** 2848,2856 **** /* * Fire off a subprocess for startup/shutdown/checkpoint. * ! * Return value is subprocess' PID, or 0 if failed to start subprocess * (0 is returned only for checkpoint case). */ static pid_t SSDataBase(int xlop) { --- 2849,2894 ---- /* * Fire off a subprocess for startup/shutdown/checkpoint. * ! * Return value of SSDataBase is subprocess' PID, or 0 if failed to start subprocess * (0 is returned only for checkpoint case). */ + NON_EXEC_STATIC void + SSDataBaseInit(int xlop) + { + const char *statmsg; + + IsUnderPostmaster = true; /* we are a postmaster subprocess + * now */ + + /* Lose the postmaster's on-exit routines and port connections */ + on_exit_reset(); + + /* + * Identify myself via ps + */ + switch (xlop) + { + case BS_XLOG_STARTUP: + statmsg = "startup subprocess"; + break; + case BS_XLOG_CHECKPOINT: + statmsg = "checkpoint subprocess"; + break; + case BS_XLOG_BGWRITER: + statmsg = "bgwriter subprocess"; + break; + case BS_XLOG_SHUTDOWN: + statmsg = "shutdown subprocess"; + break; + default: + statmsg = "??? subprocess"; + break; + } + init_ps_display(statmsg, "", ""); + set_ps_display(""); + } + + static pid_t SSDataBase(int xlop) { *************** *** 2876,2891 **** if ((pid = fork()) == 0) /* child */ { - const char *statmsg; char *av[10]; int ac = 0; char nbbuf[32]; char xlbuf[32]; - #ifdef EXEC_BACKEND - char pbuf[NAMEDATALEN + 256]; - #endif - #ifdef LINUX_PROFILE setitimer(ITIMER_PROF, &prof_itimer, NULL); #endif --- 2914,2924 ---- *************** *** 2895,2959 **** beos_backend_startup(); #endif - IsUnderPostmaster = true; /* we are a postmaster subprocess - * now */ - - /* Lose the postmaster's on-exit routines and port connections */ - on_exit_reset(); - /* Close the postmaster's sockets */ ClosePostmasterPorts(true); ! /* ! * Identify myself via ps ! */ ! switch (xlop) ! { ! case BS_XLOG_STARTUP: ! statmsg = "startup subprocess"; ! break; ! case BS_XLOG_CHECKPOINT: ! statmsg = "checkpoint subprocess"; ! break; ! case BS_XLOG_BGWRITER: ! statmsg = "bgwriter subprocess"; ! break; ! case BS_XLOG_SHUTDOWN: ! statmsg = "shutdown subprocess"; ! break; ! default: ! statmsg = "??? subprocess"; ! break; ! } ! init_ps_display(statmsg, "", ""); ! set_ps_display(""); /* Set up command-line arguments for subprocess */ av[ac++] = "postgres"; snprintf(nbbuf, sizeof(nbbuf), "-B%d", NBuffers); av[ac++] = nbbuf; snprintf(xlbuf, sizeof(xlbuf), "-x%d", xlop); av[ac++] = xlbuf; - av[ac++] = "-p"; #ifdef EXEC_BACKEND ! Assert(UsedShmemSegID != 0 && UsedShmemSegAddr != NULL); ! /* database name at the end because it might contain commas */ ! snprintf(pbuf, sizeof(pbuf), "%lu,%p,%s", ! UsedShmemSegID, UsedShmemSegAddr, "template1"); ! av[ac++] = pbuf; ! #else ! av[ac++] = "template1"; #endif av[ac] = (char *) NULL; Assert(ac < lengthof(av)); BootstrapMain(ac, av); ExitPostmaster(0); } /* in parent */ --- 2928,2974 ---- beos_backend_startup(); #endif /* Close the postmaster's sockets */ ClosePostmasterPorts(true); ! #ifndef EXEC_BACKEND ! SSDataBaseInit(xlop); ! #endif /* Set up command-line arguments for subprocess */ av[ac++] = "postgres"; + #ifdef EXEC_BACKEND + av[ac++] = "-boot"; + #endif + snprintf(nbbuf, sizeof(nbbuf), "-B%d", NBuffers); av[ac++] = nbbuf; snprintf(xlbuf, sizeof(xlbuf), "-x%d", xlop); av[ac++] = xlbuf; #ifdef EXEC_BACKEND ! write_backend_variables(getpid(),NULL); ! ! /* pass data dir before end of secure switches (-p) */ ! av[ac++] = "-D"; ! av[ac++] = DataDir; #endif + av[ac++] = "-p"; + av[ac++] = "template1"; av[ac] = (char *) NULL; Assert(ac < lengthof(av)); + #ifdef EXEC_BACKEND + if (execv(pg_pathname,av) == -1) + elog(FATAL,"unable to execv in SSDataBase: %m"); + #else BootstrapMain(ac, av); ExitPostmaster(0); + #endif } /* in parent */ *************** *** 3107,3113 **** extern int pgStatSock; #define write_var(var,fp) fwrite((void*)&(var),sizeof(var),1,fp) ! #define read_var(var,fp) fread((void*)&(var),sizeof(var),1,fp); #define get_tmp_backend_file_name(buf,id) \ do { \ Assert(DataDir); \ --- 3122,3128 ---- extern int pgStatSock; #define write_var(var,fp) fwrite((void*)&(var),sizeof(var),1,fp) ! #define read_var(var,fp) fread((void*)&(var),sizeof(var),1,fp) #define get_tmp_backend_file_name(buf,id) \ do { \ Assert(DataDir); \ *************** *** 3146,3156 **** --- 3161,3176 ---- } /* Write vars */ + if (port) + { write_var(port->sock,fp); write_var(port->proto,fp); write_var(port->laddr,fp); write_var(port->raddr,fp); write_var(port->canAcceptConnections,fp); + write_var(port->cryptSalt,fp); + write_var(port->md5Salt,fp); + } write_var(MyCancelKey,fp); write_var(RedoRecPtr,fp); *************** *** 3190,3200 **** --- 3210,3225 ---- } /* Read vars */ + if (port) + { read_var(port->sock,fp); read_var(port->proto,fp); read_var(port->laddr,fp); read_var(port->raddr,fp); read_var(port->canAcceptConnections,fp); + read_var(port->cryptSalt,fp); + read_var(port->md5Salt,fp); + } read_var(MyCancelKey,fp); read_var(RedoRecPtr,fp); Index: src/backend/storage/freespace/freespace.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/storage/freespace/freespace.c,v retrieving revision 1.28 diff -w -c -r1.28 freespace.c Index: src/backend/storage/lmgr/proc.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/storage/lmgr/proc.c,v retrieving revision 1.142 diff -w -c -r1.142 proc.c *** src/backend/storage/lmgr/proc.c 21 Dec 2003 00:33:33 -0000 1.142 --- src/backend/storage/lmgr/proc.c 21 Dec 2003 04:47:14 -0000 *************** *** 122,141 **** void InitProcGlobal(int maxBackends) { ! bool found = false; /* Create or attach to the ProcGlobal shared structure */ ProcGlobal = (PROC_HDR *) ! ShmemInitStruct("Proc Header", sizeof(PROC_HDR), &found); ! /* -------------------- ! * We're the first - initialize. ! * XXX if found should ever be true, it is a sign of impending doom ... ! * ought to complain if so? ! * -------------------- */ ! if (!found) { int i; ProcGlobal->freeProcs = INVALID_OFFSET; --- 122,152 ---- void InitProcGlobal(int maxBackends) { ! bool foundProcGlobal, foundDummy; /* Create or attach to the ProcGlobal shared structure */ ProcGlobal = (PROC_HDR *) ! ShmemInitStruct("Proc Header", sizeof(PROC_HDR), &foundProcGlobal); ! /* ! * Create or attach to the PGPROC structures for dummy (checkpoint) ! * processes, too. This does not get linked into the freeProcs ! * list. */ ! DummyProc = (PGPROC *) ! ShmemInitStruct("DummyProc",sizeof(PGPROC) * NUM_DUMMY_PROCS, &foundDummy); ! ! if (foundProcGlobal || foundDummy) { + /* both should be present or neither */ + Assert(foundProcGlobal && foundDummy); + return; + } + else + { + /* + * We're the first - initialize. + */ int i; ProcGlobal->freeProcs = INVALID_OFFSET; *************** *** 159,174 **** ProcGlobal->freeProcs = MAKE_OFFSET(proc); } - /* - * Pre-allocate a PGPROC structure for dummy (checkpoint) - * processes, too. This does not get linked into the freeProcs - * list. - */ - DummyProc = (PGPROC *) ShmemAlloc(sizeof(PGPROC) * NUM_DUMMY_PROCS); - if (!DummyProc) - ereport(FATAL, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of shared memory"))); MemSet(DummyProc, 0, sizeof(PGPROC) * NUM_DUMMY_PROCS); for (i = 0; i < NUM_DUMMY_PROCS; i++) { --- 170,175 ---- Index: src/backend/tcop/postgres.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/postgres.c,v retrieving revision 1.380 diff -w -c -r1.380 postgres.c *** src/backend/tcop/postgres.c 20 Dec 2003 17:31:21 -0000 1.380 --- src/backend/tcop/postgres.c 21 Dec 2003 04:47:21 -0000 *************** *** 2063,2069 **** * * If we are running under the postmaster, this is done already. */ ! if (!IsUnderPostmaster /* when exec || ExecBackend */) MemoryContextInit(); set_ps_display("startup"); --- 2063,2069 ---- * * If we are running under the postmaster, this is done already. */ ! if (!IsUnderPostmaster || ExecBackend) MemoryContextInit(); set_ps_display("startup"); *************** *** 2076,2082 **** Noversion = false; EchoQuery = false; ! if (!IsUnderPostmaster /* when exec || ExecBackend */ ) { InitializeGUCOptions(); potential_DataDir = getenv("PGDATA"); --- 2076,2082 ---- Noversion = false; EchoQuery = false; ! if (!IsUnderPostmaster) { InitializeGUCOptions(); potential_DataDir = getenv("PGDATA"); Index: src/include/pgstat.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/pgstat.h,v retrieving revision 1.17 diff -w -c -r1.17 pgstat.h *** src/include/pgstat.h 29 Nov 2003 22:40:53 -0000 1.17 --- src/include/pgstat.h 21 Dec 2003 04:47:25 -0000 *************** *** 326,331 **** --- 326,343 ---- } PgStat_Msg; + #ifdef EXEC_BACKEND + typedef enum STATS_PROCESS_TYPE + { + STAT_PROC_BUFFER, + STAT_PROC_COLLECTOR + } STATS_PROCESS_TYPE; + #define PGSTAT_FORK_ARGS int argc, char *argv[] + #else + #define PGSTAT_FORK_ARGS void + #endif + + /* ---------- * GUC parameters * ---------- *************** *** 341,346 **** --- 353,369 ---- * ---------- */ extern bool pgstat_is_running; + + + /* ---------- + * Functions called from main + * ---------- + */ + #ifdef EXEC_BACKEND + extern void pgstat_main(PGSTAT_FORK_ARGS); + extern void pgstat_mainChild(PGSTAT_FORK_ARGS); + #endif + /* ---------- * Functions called from postmaster