Cleanup the bootstrap code a little, and rename "dummy procs" in the code

comments and variables to "auxiliary proc", per Heikki's request.
This commit is contained in:
Alvaro Herrera 2007-03-07 13:35:03 +00:00
parent cc0cac4a49
commit 626eb02198
9 changed files with 151 additions and 168 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.86 2007/01/09 02:14:11 tgl Exp $
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.87 2007/03/07 13:35:02 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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();
}

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.232 2007/02/16 02:10:07 alvherre Exp $
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.233 2007/03/07 13:35:02 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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;
}

View File

@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.107 2007/01/05 22:19:29 momjian Exp $
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.108 2007/03/07 13:35:02 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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());

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.32 2007/02/15 23:23:23 alvherre Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.33 2007/03/07 13:35:02 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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
/*

View File

@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.525 2007/02/16 17:06:59 tgl Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.526 2007/03/07 13:35:02 alvherre Exp $
*
* NOTES
*
@ -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;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.185 2007/03/03 18:46:40 momjian Exp $
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.186 2007/03/07 13:35:03 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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 */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.45 2007/01/05 22:19:51 momjian Exp $
* $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.46 2007/03/07 13:35:03 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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 */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.95 2007/03/03 18:46:40 momjian Exp $
* $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.96 2007/03/07 13:35:03 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@ -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);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.87 2007/02/20 17:32:17 tgl Exp $
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.88 2007/03/07 13:35:03 alvherre Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
@ -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);