summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2007-03-07 13:35:03 +0000
committerAlvaro Herrera2007-03-07 13:35:03 +0000
commite60f597c21a27e4bbe95d3786143f8e0fb8700c2 (patch)
tree2a871dc3288ad91d239577a74f1d3670170286c4
parentc534d006294b2f09eb90ab57465674bc7d570e75 (diff)
Cleanup the bootstrap code a little, and rename "dummy procs" in the code
comments and variables to "auxiliary proc", per Heikki's request.
-rw-r--r--src/backend/bootstrap/bootparse.y5
-rw-r--r--src/backend/bootstrap/bootstrap.c146
-rw-r--r--src/backend/main/main.c2
-rw-r--r--src/backend/postmaster/autovacuum.c4
-rw-r--r--src/backend/postmaster/postmaster.c42
-rw-r--r--src/backend/storage/lmgr/proc.c80
-rw-r--r--src/include/bootstrap/bootstrap.h13
-rw-r--r--src/include/storage/proc.h6
-rw-r--r--src/include/tcop/tcopprot.h3
9 files changed, 142 insertions, 159 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 855118ba06..d94ddd1962 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -235,10 +235,7 @@ Boot_InsertStmt:
elog(ERROR, "incorrect number of columns in row (expected %d, got %d)",
numattr, num_columns_read);
if (boot_reldesc == NULL)
- {
- elog(ERROR, "relation not open");
- err_out();
- }
+ elog(FATAL, "relation not open");
InsertOneTuple($2);
do_end();
}
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 4444564d00..5fd7a0c0d8 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -20,8 +20,6 @@
#include <getopt.h>
#endif
-#define BOOTSTRAP_INCLUDE /* mask out stuff in tcop/tcopprot.h */
-
#include "access/genam.h"
#include "access/heapam.h"
#include "access/xact.h"
@@ -48,8 +46,10 @@ extern char *optarg;
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
+static void CheckerModeMain(void);
+static void BootstrapModeMain(void);
static void bootstrap_signals(void);
-static void ShutdownDummyProcess(int code, Datum arg);
+static void ShutdownAuxiliaryProcess(int code, Datum arg);
static hashnode *AddStr(char *str, int strlength, int mderef);
static Form_pg_attribute AllocateAttribute(void);
static int CompHash(char *str, int len);
@@ -166,7 +166,6 @@ struct typmap
static struct typmap **Typ = NULL;
static struct typmap *Ap = NULL;
-static int Warnings = 0;
static char Blanks[MAXATTR];
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
@@ -193,23 +192,19 @@ static IndexList *ILHead = NULL;
/*
- * The main entry point for running the backend in bootstrap mode
+ * AuxiliaryProcessMain
*
- * The bootstrap mode is used to initialize the template database.
- * The bootstrap backend doesn't speak SQL, but instead expects
- * commands in a special bootstrap language.
+ * The main entry point for auxiliary processes, such as the bgwriter,
+ * bootstrapper and the shared memory checker code.
*
- * For historical reasons, BootstrapMain is also used as the control
- * routine for non-backend subprocesses launched by the postmaster,
- * such as startup and shutdown.
+ * This code is here just because of historical reasons.
*/
-int
-BootstrapMain(int argc, char *argv[])
+void
+AuxiliaryProcessMain(int argc, char *argv[])
{
char *progname = argv[0];
- int i;
int flag;
- int xlogop = BS_XLOG_NOP;
+ AuxProcType auxType = CheckerProcess;
char *userDoption = NULL;
/*
@@ -278,7 +273,7 @@ BootstrapMain(int argc, char *argv[])
strlcpy(OutputFileName, optarg, MAXPGPATH);
break;
case 'x':
- xlogop = atoi(optarg);
+ auxType = atoi(optarg);
break;
case 'c':
case '-':
@@ -328,12 +323,12 @@ BootstrapMain(int argc, char *argv[])
{
const char *statmsg;
- switch (xlogop)
+ switch (auxType)
{
- case BS_XLOG_STARTUP:
+ case StartupProcess:
statmsg = "startup process";
break;
- case BS_XLOG_BGWRITER:
+ case BgWriterProcess:
statmsg = "writer process";
break;
default:
@@ -372,9 +367,9 @@ BootstrapMain(int argc, char *argv[])
BaseInit();
/*
- * When we are a dummy process, we aren't going to do the full
+ * When we are an auxiliary process, we aren't going to do the full
* InitPostgres pushups, but there are a couple of things that need to get
- * lit up even in a dummy process.
+ * lit up even in an auxiliary process.
*/
if (IsUnderPostmaster)
{
@@ -383,14 +378,14 @@ BootstrapMain(int argc, char *argv[])
* this was already done by SubPostmasterMain().
*/
#ifndef EXEC_BACKEND
- InitDummyProcess();
+ InitAuxiliaryProcess();
#endif
/* finish setting up bufmgr.c */
InitBufferPoolBackend();
/* register a shutdown callback for LWLock cleanup */
- on_shmem_exit(ShutdownDummyProcess, 0);
+ on_shmem_exit(ShutdownAuxiliaryProcess, 0);
}
/*
@@ -398,36 +393,47 @@ BootstrapMain(int argc, char *argv[])
*/
SetProcessingMode(NormalProcessing);
- switch (xlogop)
+ switch (auxType)
{
- case BS_XLOG_NOP:
+ case CheckerProcess:
bootstrap_signals();
- break;
+ CheckerModeMain();
+ proc_exit(1); /* should never return */
- case BS_XLOG_BOOTSTRAP:
+ case BootstrapProcess:
bootstrap_signals();
BootStrapXLOG();
StartupXLOG();
- break;
+ BootstrapModeMain();
+ proc_exit(1); /* should never return */
- case BS_XLOG_STARTUP:
+ case StartupProcess:
bootstrap_signals();
StartupXLOG();
LoadFreeSpaceMap();
BuildFlatFiles(false);
proc_exit(0); /* startup done */
- case BS_XLOG_BGWRITER:
+ case BgWriterProcess:
/* don't set signals, bgwriter has its own agenda */
InitXLOGAccess();
BackgroundWriterMain();
proc_exit(1); /* should never return */
-
+
default:
- elog(PANIC, "unrecognized XLOG op: %d", xlogop);
+ elog(PANIC, "unrecognized process type: %d", auxType);
proc_exit(1);
}
+}
+/*
+ * In shared memory checker mode, all we really want to do is create shared
+ * memory and semaphores (just to prove we can do it with the current GUC
+ * settings).
+ */
+static void
+CheckerModeMain(void)
+{
/*
* We must be getting invoked for bootstrap mode
*/
@@ -439,15 +445,31 @@ BootstrapMain(int argc, char *argv[])
* Do backend-like initialization for bootstrap mode
*/
InitProcess();
- (void) InitPostgres(NULL, InvalidOid, NULL, NULL);
+ InitPostgres(NULL, InvalidOid, NULL, NULL);
+ proc_exit(0);
+}
+
+/*
+ * The main entry point for running the backend in bootstrap mode
+ *
+ * The bootstrap mode is used to initialize the template database.
+ * The bootstrap backend doesn't speak SQL, but instead expects
+ * commands in a special bootstrap language.
+ */
+static void
+BootstrapModeMain(void)
+{
+ int i;
+
+ Assert(!IsUnderPostmaster);
+
+ SetProcessingMode(BootstrapProcessing);
/*
- * In NOP mode, all we really want to do is create shared memory and
- * semaphores (just to prove we can do it with the current GUC settings).
- * So, quit now.
+ * Do backend-like initialization for bootstrap mode
*/
- if (xlogop == BS_XLOG_NOP)
- proc_exit(0);
+ InitProcess();
+ InitPostgres(NULL, InvalidOid, NULL, NULL);
/* Initialize stuff for bootstrap-file processing */
for (i = 0; i < MAXATTR; i++)
@@ -468,14 +490,10 @@ BootstrapMain(int argc, char *argv[])
/* Perform a checkpoint to ensure everything's down to disk */
SetProcessingMode(NormalProcessing);
CreateCheckPoint(true, true);
- SetProcessingMode(BootstrapProcessing);
/* Clean up and exit */
- StartTransactionCommand();
cleanup();
-
- /* not reached, here to make compiler happy */
- return 0;
+ proc_exit(0);
}
@@ -538,30 +556,18 @@ bootstrap_signals(void)
}
/*
- * Begin shutdown of a dummy process. This is approximately the equivalent
- * of ShutdownPostgres() in postinit.c. We can't run transactions in a
- * dummy process, so most of the work of AbortTransaction() is not needed,
+ * Begin shutdown of an auxiliary process. This is approximately the equivalent
+ * of ShutdownPostgres() in postinit.c. We can't run transactions in an
+ * auxiliary process, so most of the work of AbortTransaction() is not needed,
* but we do need to make sure we've released any LWLocks we are holding.
* (This is only critical during an error exit.)
*/
static void
-ShutdownDummyProcess(int code, Datum arg)
+ShutdownAuxiliaryProcess(int code, Datum arg)
{
LWLockReleaseAll();
}
-/* ----------------
- * error handling / abort routines
- * ----------------
- */
-void
-err_out(void)
-{
- Warnings++;
- cleanup();
-}
-
-
/* ----------------------------------------------------------------
* MANUAL BACKEND INTERACTIVE INTERFACE COMMANDS
* ----------------------------------------------------------------
@@ -815,15 +821,7 @@ InsertOneValue(char *value, int i)
elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
- if (Typ != NULL)
- {
- typoid = boot_reldesc->rd_att->attrs[i]->atttypid;
- }
- else
- {
- /* XXX why is typoid determined differently in this case? */
- typoid = attrtypes[i]->atttypid;
- }
+ typoid = boot_reldesc->rd_att->attrs[i]->atttypid;
boot_get_type_io_data(typoid,
&typlen, &typbyval, &typalign,
@@ -856,19 +854,8 @@ InsertOneNull(int i)
static void
cleanup(void)
{
- static int beenhere = 0;
-
- if (!beenhere)
- beenhere = 1;
- else
- {
- elog(FATAL, "cleanup called twice");
- proc_exit(1);
- }
if (boot_reldesc != NULL)
closerel(NULL);
- CommitTransactionCommand();
- proc_exit(Warnings ? 1 : 0);
}
/* ----------------
@@ -934,7 +921,6 @@ gettype(char *type)
return gettype(type);
}
elog(ERROR, "unrecognized type \"%s\"", type);
- err_out();
/* not reached, here to make compiler happy */
return 0;
}
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index 62c851acb8..606f50b8ab 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
#endif
if (argc > 1 && strcmp(argv[1], "--boot") == 0)
- exit(BootstrapMain(argc, argv));
+ AuxiliaryProcessMain(argc, argv); /* does not return */
if (argc > 1 && strcmp(argv[1], "--describe-config") == 0)
exit(GucInfoMain());
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 01c53cadca..5c513aec9f 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -246,7 +246,7 @@ AutoVacLauncherMain(int argc, char *argv[])
#endif
/*
- * Set up signal handlers. Since this is a "dummy" process, it has
+ * Set up signal handlers. Since this is an auxiliary process, it has
* particular signal requirements -- no deadlock checker or sinval
* catchup, for example.
*
@@ -277,7 +277,7 @@ AutoVacLauncherMain(int argc, char *argv[])
* had to do some stuff with LWLocks).
*/
#ifndef EXEC_BACKEND
- InitDummyProcess();
+ InitAuxiliaryProcess();
#endif
/*
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 868ed3eb25..430756536a 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -275,7 +275,7 @@ static void SignalChildren(int signal);
static void SignalSomeChildren(int signal, bool only_autovac);
static int CountChildren(void);
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname);
-static pid_t StartChildProcess(int xlop);
+static pid_t StartChildProcess(AuxProcType type);
static void StartAutovacuumWorker(void);
#ifdef EXEC_BACKEND
@@ -328,7 +328,7 @@ typedef struct
LWLock *LWLockArray;
slock_t *ProcStructLock;
PROC_HDR *ProcGlobal;
- PGPROC *DummyProcs;
+ PGPROC *AuxiliaryProcs;
InheritableSocket pgStatSock;
pid_t PostmasterPid;
TimestampTz PgStartTime;
@@ -360,8 +360,8 @@ static void ShmemBackendArrayAdd(Backend *bn);
static void ShmemBackendArrayRemove(pid_t pid);
#endif /* EXEC_BACKEND */
-#define StartupDataBase() StartChildProcess(BS_XLOG_STARTUP)
-#define StartBackgroundWriter() StartChildProcess(BS_XLOG_BGWRITER)
+#define StartupDataBase() StartChildProcess(StartupProcess)
+#define StartBackgroundWriter() StartChildProcess(BgWriterProcess)
/* Macros to check exit status of a child process */
#define EXIT_STATUS_0(st) ((st) == 0)
@@ -3433,12 +3433,12 @@ SubPostmasterMain(int argc, char *argv[])
InitShmemAccess(UsedShmemSegAddr);
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
- InitDummyProcess();
+ InitAuxiliaryProcess();
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores(false, 0);
- BootstrapMain(argc - 2, argv + 2);
+ AuxiliaryProcessMain(argc - 2, argv + 2);
proc_exit(0);
}
if (strcmp(argv[1], "--forkavlauncher") == 0)
@@ -3450,7 +3450,7 @@ SubPostmasterMain(int argc, char *argv[])
InitShmemAccess(UsedShmemSegAddr);
/* Need a PGPROC to run CreateSharedMemoryAndSemaphores */
- InitDummyProcess();
+ InitAuxiliaryProcess();
/* Attach process to shared data structures */
CreateSharedMemoryAndSemaphores(false, 0);
@@ -3700,21 +3700,21 @@ CountChildren(void)
/*
- * StartChildProcess -- start a non-backend child process for the postmaster
+ * StartChildProcess -- start an auxiliary process for the postmaster
*
* xlop determines what kind of child will be started. All child types
- * initially go to BootstrapMain, which will handle common setup.
+ * initially go to AuxiliaryProcessMain, which will handle common setup.
*
* Return value of StartChildProcess is subprocess' PID, or 0 if failed
* to start subprocess.
*/
static pid_t
-StartChildProcess(int xlop)
+StartChildProcess(AuxProcType type)
{
pid_t pid;
char *av[10];
int ac = 0;
- char xlbuf[32];
+ char typebuf[32];
/*
* Set up command-line arguments for subprocess
@@ -3726,8 +3726,8 @@ StartChildProcess(int xlop)
av[ac++] = NULL; /* filled in by postmaster_forkexec */
#endif
- snprintf(xlbuf, sizeof(xlbuf), "-x%d", xlop);
- av[ac++] = xlbuf;
+ snprintf(typebuf, sizeof(typebuf), "-x%d", type);
+ av[ac++] = typebuf;
av[ac] = NULL;
Assert(ac < lengthof(av));
@@ -3752,7 +3752,7 @@ StartChildProcess(int xlop)
MemoryContextDelete(PostmasterContext);
PostmasterContext = NULL;
- BootstrapMain(ac, av);
+ AuxiliaryProcessMain(ac, av);
ExitPostmaster(0);
}
#endif /* EXEC_BACKEND */
@@ -3763,13 +3763,13 @@ StartChildProcess(int xlop)
int save_errno = errno;
errno = save_errno;
- switch (xlop)
+ switch (type)
{
- case BS_XLOG_STARTUP:
+ case StartupProcess:
ereport(LOG,
(errmsg("could not fork startup process: %m")));
break;
- case BS_XLOG_BGWRITER:
+ case BgWriterProcess:
ereport(LOG,
(errmsg("could not fork background writer process: %m")));
break;
@@ -3783,7 +3783,7 @@ StartChildProcess(int xlop)
* fork failure is fatal during startup, but there's no need to choke
* immediately if starting other child types fails.
*/
- if (xlop == BS_XLOG_STARTUP)
+ if (type == StartupProcess)
ExitPostmaster(1);
return 0;
}
@@ -3887,7 +3887,7 @@ extern slock_t *ShmemLock;
extern LWLock *LWLockArray;
extern slock_t *ProcStructLock;
extern PROC_HDR *ProcGlobal;
-extern PGPROC *DummyProcs;
+extern PGPROC *AuxiliaryProcs;
extern int pgStatSock;
#ifndef WIN32
@@ -3930,7 +3930,7 @@ save_backend_variables(BackendParameters * param, Port *port,
param->LWLockArray = LWLockArray;
param->ProcStructLock = ProcStructLock;
param->ProcGlobal = ProcGlobal;
- param->DummyProcs = DummyProcs;
+ param->AuxiliaryProcs = AuxiliaryProcs;
write_inheritable_socket(&param->pgStatSock, pgStatSock, childPid);
param->PostmasterPid = PostmasterPid;
@@ -4133,7 +4133,7 @@ restore_backend_variables(BackendParameters * param, Port *port)
LWLockArray = param->LWLockArray;
ProcStructLock = param->ProcStructLock;
ProcGlobal = param->ProcGlobal;
- DummyProcs = param->DummyProcs;
+ AuxiliaryProcs = param->AuxiliaryProcs;
read_inheritable_socket(&pgStatSock, &param->pgStatSock);
PostmasterPid = param->PostmasterPid;
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index c16fa551b4..aae21c42f5 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -64,7 +64,7 @@ NON_EXEC_STATIC slock_t *ProcStructLock = NULL;
/* Pointers to shared-memory structures */
NON_EXEC_STATIC PROC_HDR *ProcGlobal = NULL;
-NON_EXEC_STATIC PGPROC *DummyProcs = NULL;
+NON_EXEC_STATIC PGPROC *AuxiliaryProcs = NULL;
/* If we are waiting for a lock, this points to the associated LOCALLOCK */
static LOCALLOCK *lockAwaited = NULL;
@@ -80,7 +80,7 @@ static TimestampTz statement_fin_time;
static void RemoveProcFromArray(int code, Datum arg);
static void ProcKill(int code, Datum arg);
-static void DummyProcKill(int code, Datum arg);
+static void AuxiliaryProcKill(int code, Datum arg);
static bool CheckStatementTimeout(void);
@@ -94,8 +94,8 @@ ProcGlobalShmemSize(void)
/* ProcGlobal */
size = add_size(size, sizeof(PROC_HDR));
- /* DummyProcs */
- size = add_size(size, mul_size(NUM_DUMMY_PROCS, sizeof(PGPROC)));
+ /* AuxiliaryProcs */
+ size = add_size(size, mul_size(NUM_AUXILIARY_PROCS, sizeof(PGPROC)));
/* MyProcs */
size = add_size(size, mul_size(MaxBackends, sizeof(PGPROC)));
/* ProcStructLock */
@@ -110,8 +110,8 @@ ProcGlobalShmemSize(void)
int
ProcGlobalSemas(void)
{
- /* We need a sema per backend, plus one for each dummy process. */
- return MaxBackends + NUM_DUMMY_PROCS;
+ /* We need a sema per backend, plus one for each auxiliary process. */
+ return MaxBackends + NUM_AUXILIARY_PROCS;
}
/*
@@ -135,7 +135,7 @@ ProcGlobalSemas(void)
* postmaster, not in backends.
*
* Note: this is NOT called by individual backends under a postmaster,
- * not even in the EXEC_BACKEND case. The ProcGlobal and DummyProcs
+ * not even in the EXEC_BACKEND case. The ProcGlobal and AuxiliaryProcs
* pointers must be propagated specially for EXEC_BACKEND operation.
*/
void
@@ -151,11 +151,11 @@ InitProcGlobal(void)
Assert(!found);
/*
- * Create the PGPROC structures for dummy (bgwriter) processes, too. These
- * do not get linked into the freeProcs list.
+ * Create the PGPROC structures for auxiliary (bgwriter) processes, too.
+ * These do not get linked into the freeProcs list.
*/
- DummyProcs = (PGPROC *)
- ShmemInitStruct("DummyProcs", NUM_DUMMY_PROCS * sizeof(PGPROC),
+ AuxiliaryProcs = (PGPROC *)
+ ShmemInitStruct("AuxiliaryProcs", NUM_AUXILIARY_PROCS * sizeof(PGPROC),
&found);
Assert(!found);
@@ -182,11 +182,11 @@ InitProcGlobal(void)
ProcGlobal->freeProcs = MAKE_OFFSET(&procs[i]);
}
- MemSet(DummyProcs, 0, NUM_DUMMY_PROCS * sizeof(PGPROC));
- for (i = 0; i < NUM_DUMMY_PROCS; i++)
+ MemSet(AuxiliaryProcs, 0, NUM_AUXILIARY_PROCS * sizeof(PGPROC));
+ for (i = 0; i < NUM_AUXILIARY_PROCS; i++)
{
- DummyProcs[i].pid = 0; /* marks dummy proc as not in use */
- PGSemaphoreCreate(&(DummyProcs[i].sem));
+ AuxiliaryProcs[i].pid = 0; /* marks auxiliary proc as not in use */
+ PGSemaphoreCreate(&(AuxiliaryProcs[i].sem));
}
/* Create ProcStructLock spinlock, too */
@@ -320,21 +320,21 @@ InitProcessPhase2(void)
}
/*
- * InitDummyProcess -- create a dummy per-process data structure
+ * InitAuxiliaryProcess -- create a per-auxiliary-process data structure
*
* This is called by bgwriter and similar processes so that they will have a
* MyProc value that's real enough to let them wait for LWLocks. The PGPROC
* and sema that are assigned are one of the extra ones created during
* InitProcGlobal.
*
- * Dummy processes are presently not expected to wait for real (lockmgr)
+ * Auxiliary processes are presently not expected to wait for real (lockmgr)
* locks, so we need not set up the deadlock checker. They are never added
* to the ProcArray or the sinval messaging mechanism, either.
*/
void
-InitDummyProcess(void)
+InitAuxiliaryProcess(void)
{
- PGPROC *dummyproc;
+ PGPROC *auxproc;
int proctype;
int i;
@@ -342,7 +342,7 @@ InitDummyProcess(void)
* ProcGlobal should be set up already (if we are a backend, we inherit
* this by fork() or EXEC_BACKEND mechanism from the postmaster).
*/
- if (ProcGlobal == NULL || DummyProcs == NULL)
+ if (ProcGlobal == NULL || AuxiliaryProcs == NULL)
elog(PANIC, "proc header uninitialized");
if (MyProc != NULL)
@@ -350,7 +350,7 @@ InitDummyProcess(void)
/*
* We use the ProcStructLock to protect assignment and releasing of
- * DummyProcs entries.
+ * AuxiliaryProcs entries.
*
* While we are holding the ProcStructLock, also copy the current shared
* estimate of spins_per_delay to local storage.
@@ -360,25 +360,25 @@ InitDummyProcess(void)
set_spins_per_delay(ProcGlobal->spins_per_delay);
/*
- * Find a free dummyproc ... *big* trouble if there isn't one ...
+ * Find a free auxproc ... *big* trouble if there isn't one ...
*/
- for (proctype = 0; proctype < NUM_DUMMY_PROCS; proctype++)
+ for (proctype = 0; proctype < NUM_AUXILIARY_PROCS; proctype++)
{
- dummyproc = &DummyProcs[proctype];
- if (dummyproc->pid == 0)
+ auxproc = &AuxiliaryProcs[proctype];
+ if (auxproc->pid == 0)
break;
}
- if (proctype >= NUM_DUMMY_PROCS)
+ if (proctype >= NUM_AUXILIARY_PROCS)
{
SpinLockRelease(ProcStructLock);
- elog(FATAL, "all DummyProcs are in use");
+ elog(FATAL, "all AuxiliaryProcs are in use");
}
- /* Mark dummy proc as in use by me */
+ /* Mark auxiliary proc as in use by me */
/* use volatile pointer to prevent code rearrangement */
- ((volatile PGPROC *) dummyproc)->pid = MyProcPid;
+ ((volatile PGPROC *) auxproc)->pid = MyProcPid;
- MyProc = dummyproc;
+ MyProc = auxproc;
SpinLockRelease(ProcStructLock);
@@ -412,7 +412,7 @@ InitDummyProcess(void)
/*
* Arrange to clean up at process exit.
*/
- on_shmem_exit(DummyProcKill, Int32GetDatum(proctype));
+ on_shmem_exit(AuxiliaryProcKill, Int32GetDatum(proctype));
}
/*
@@ -582,28 +582,28 @@ ProcKill(int code, Datum arg)
}
/*
- * DummyProcKill() -- Cut-down version of ProcKill for dummy (bgwriter)
- * processes. The PGPROC and sema are not released, only marked
- * as not-in-use.
+ * AuxiliaryProcKill() -- Cut-down version of ProcKill for auxiliary
+ * processes (bgwriter, etc). The PGPROC and sema are not released, only
+ * marked as not-in-use.
*/
static void
-DummyProcKill(int code, Datum arg)
+AuxiliaryProcKill(int code, Datum arg)
{
int proctype = DatumGetInt32(arg);
- PGPROC *dummyproc;
+ PGPROC *auxproc;
- Assert(proctype >= 0 && proctype < NUM_DUMMY_PROCS);
+ Assert(proctype >= 0 && proctype < NUM_AUXILIARY_PROCS);
- dummyproc = &DummyProcs[proctype];
+ auxproc = &AuxiliaryProcs[proctype];
- Assert(MyProc == dummyproc);
+ Assert(MyProc == auxproc);
/* Release any LW locks I am holding (see notes above) */
LWLockReleaseAll();
SpinLockAcquire(ProcStructLock);
- /* Mark dummy proc no longer in use */
+ /* Mark auxiliary proc no longer in use */
MyProc->pid = 0;
/* PGPROC struct isn't mine anymore */
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index 1bcd7ad732..01265c26e4 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -32,7 +32,7 @@ typedef struct hashnode
extern Relation boot_reldesc;
extern Form_pg_attribute attrtypes[MAXATTR];
extern int numattr;
-extern int BootstrapMain(int argc, char *argv[]);
+extern void AuxiliaryProcessMain(int argc, char *argv[]);
extern void index_register(Oid heap, Oid ind, IndexInfo *indexInfo);
@@ -64,9 +64,12 @@ extern int boot_yyparse(void);
extern int boot_yylex(void);
extern void boot_yyerror(const char *str);
-#define BS_XLOG_NOP 0
-#define BS_XLOG_BOOTSTRAP 1
-#define BS_XLOG_STARTUP 2
-#define BS_XLOG_BGWRITER 3
+typedef enum
+{
+ CheckerProcess,
+ BootstrapProcess,
+ StartupProcess,
+ BgWriterProcess
+} AuxProcType;
#endif /* BOOTSTRAP_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index d6c92daf92..c551f4481f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -118,10 +118,10 @@ typedef struct PROC_HDR
} PROC_HDR;
/*
- * We set aside some extra PGPROC structures for "dummy" processes,
+ * We set aside some extra PGPROC structures for auxiliary processes,
* ie things that aren't full-fledged backends but need shmem access.
*/
-#define NUM_DUMMY_PROCS 3
+#define NUM_AUXILIARY_PROCS 3
/* configurable options */
@@ -140,7 +140,7 @@ extern Size ProcGlobalShmemSize(void);
extern void InitProcGlobal(void);
extern void InitProcess(void);
extern void InitProcessPhase2(void);
-extern void InitDummyProcess(void);
+extern void InitAuxiliaryProcess(void);
extern bool HaveNFreeProcs(int n);
extern void ProcReleaseLocks(bool isCommit);
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index a81e6f4107..2e421449d2 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -44,8 +44,6 @@ typedef enum
extern LogStmtLevel log_statement;
-#ifndef BOOTSTRAP_INCLUDE
-
extern List *pg_parse_and_rewrite(const char *query_string,
Oid *paramTypes, int numParams);
extern List *pg_parse_query(const char *query_string);
@@ -56,7 +54,6 @@ extern List *pg_plan_queries(List *querytrees, ParamListInfo boundParams,
bool needSnapshot);
extern bool assign_max_stack_depth(int newval, bool doit, GucSource source);
-#endif /* BOOTSTRAP_INCLUDE */
extern void die(SIGNAL_ARGS);
extern void quickdie(SIGNAL_ARGS);