Commit 47937403 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

XLOG (also known as WAL -:)) Bootstrap/Startup/Shutdown.

First step in cleaning up backend initialization code.
Fix for FATAL: now FATAL is ERROR + exit.
parent 9dcd8c52
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.68 1999/09/27 20:26:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.69 1999/10/06 21:58:02 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -39,6 +39,14 @@ ...@@ -39,6 +39,14 @@
#define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t)) #define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t))
#define FIRST_TYPE_OID 16 /* OID of the first type */ #define FIRST_TYPE_OID 16 /* OID of the first type */
extern void BaseInit(void);
extern void StartupXLOG(void);
extern void ShutdownXLOG(void);
extern void BootStrapXLOG(void);
extern char XLogDir[];
extern char ControlFilePath[];
extern int Int_yyparse(void); extern int Int_yyparse(void);
static hashnode *AddStr(char *str, int strlength, int mderef); static hashnode *AddStr(char *str, int strlength, int mderef);
static Form_pg_attribute AllocateAttribute(void); static Form_pg_attribute AllocateAttribute(void);
...@@ -218,22 +226,13 @@ BootstrapMain(int argc, char *argv[]) ...@@ -218,22 +226,13 @@ BootstrapMain(int argc, char *argv[])
*/ */
{ {
int i; int i;
int portFd = -1;
char *dbName; char *dbName;
int flag; int flag;
int override = 1; /* use BootstrapProcessing or bool xloginit = false;
* InitProcessing mode */
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
/* ----------------
* initialize signal handlers
* ----------------
*/
pqsignal(SIGINT, (sig_func) die);
pqsignal(SIGHUP, (sig_func) die);
pqsignal(SIGTERM, (sig_func) die);
/* -------------------- /* --------------------
* initialize globals * initialize globals
...@@ -252,8 +251,9 @@ BootstrapMain(int argc, char *argv[]) ...@@ -252,8 +251,9 @@ BootstrapMain(int argc, char *argv[])
Noversion = false; Noversion = false;
dbName = NULL; dbName = NULL;
DataDir = getenv("PGDATA"); /* Null if no PGDATA variable */ DataDir = getenv("PGDATA"); /* Null if no PGDATA variable */
IsUnderPostmaster = false;
while ((flag = getopt(argc, argv, "D:dCOQP:F")) != EOF) while ((flag = getopt(argc, argv, "D:dCQxpB:F")) != EOF)
{ {
switch (flag) switch (flag)
{ {
...@@ -270,14 +270,17 @@ BootstrapMain(int argc, char *argv[]) ...@@ -270,14 +270,17 @@ BootstrapMain(int argc, char *argv[])
case 'F': case 'F':
disableFsync = true; disableFsync = true;
break; break;
case 'O':
override = true;
break;
case 'Q': case 'Q':
Quiet = true; Quiet = true;
break; break;
case 'P': /* specify port */ case 'x':
portFd = atoi(optarg); xloginit = true;
break;
case 'p':
IsUnderPostmaster = true;
break;
case 'B':
NBuffers = atoi(optarg);
break; break;
default: default:
usage(); usage();
...@@ -290,6 +293,8 @@ BootstrapMain(int argc, char *argv[]) ...@@ -290,6 +293,8 @@ BootstrapMain(int argc, char *argv[])
else if (argc - optind == 1) else if (argc - optind == 1)
dbName = argv[optind]; dbName = argv[optind];
SetProcessingMode(BootstrapProcessing);
if (!DataDir) if (!DataDir)
{ {
fprintf(stderr, "%s does not know where to find the database system " fprintf(stderr, "%s does not know where to find the database system "
...@@ -311,24 +316,50 @@ BootstrapMain(int argc, char *argv[]) ...@@ -311,24 +316,50 @@ BootstrapMain(int argc, char *argv[])
} }
} }
/* ---------------- BaseInit();
* initialize input fd
* ---------------- if (!IsUnderPostmaster)
{
pqsignal(SIGINT, (sig_func) die);
pqsignal(SIGHUP, (sig_func) die);
pqsignal(SIGTERM, (sig_func) die);
}
/*
* Bootstrap under Postmaster means two things:
* (xloginit) ? StartupXLOG : ShutdownXLOG
*
* If !under Postmaster and xloginit then BootStrapXLOG.
*/ */
if (IsUnderPostmaster && portFd < 0) if (IsUnderPostmaster || xloginit)
{ {
fputs("backend: failed, no -P option with -postmaster opt.\n", stderr); sprintf(XLogDir, "%s%cpg_xlog", DataDir, SEP_CHAR);
proc_exit(1); sprintf(ControlFilePath, "%s%cpg_control", DataDir, SEP_CHAR);
} }
/* ---------------- if (IsUnderPostmaster && xloginit)
* backend initialization {
* ---------------- StartupXLOG();
proc_exit(0);
}
if (!IsUnderPostmaster && xloginit)
{
BootStrapXLOG();
}
/*
* backend initialization
*/ */
SetProcessingMode((override) ? BootstrapProcessing : InitProcessing);
InitPostgres(dbName); InitPostgres(dbName);
LockDisable(true); LockDisable(true);
if (IsUnderPostmaster && !xloginit)
{
ShutdownXLOG();
proc_exit(0);
}
for (i = 0; i < MAXATTR; i++) for (i = 0; i < MAXATTR; i++)
{ {
attrtypes[i] = (Form_pg_attribute) NULL; attrtypes[i] = (Form_pg_attribute) NULL;
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.30 1999/09/24 00:24:29 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.31 1999/10/06 21:58:04 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -230,16 +230,18 @@ InitBufferPool(IPCKey key) ...@@ -230,16 +230,18 @@ InitBufferPool(IPCKey key)
#ifndef HAS_TEST_AND_SET #ifndef HAS_TEST_AND_SET
{ {
int status;
extern IpcSemaphoreId WaitIOSemId; extern IpcSemaphoreId WaitIOSemId;
extern IpcSemaphoreId WaitCLSemId; extern IpcSemaphoreId WaitCLSemId;
WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key), WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key),
1, IPCProtection, 0, 1, &status); 1, IPCProtection, 0, 1);
if (WaitIOSemId < 0)
elog(FATAL, "InitBufferPool: IpcSemaphoreCreate(WaitIOSemId) failed");
WaitCLSemId = IpcSemaphoreCreate(IPCKeyGetWaitCLSemaphoreKey(key), WaitCLSemId = IpcSemaphoreCreate(IPCKeyGetWaitCLSemaphoreKey(key),
1, IPCProtection, 1, IPCProtection,
IpcSemaphoreDefaultStartValue, IpcSemaphoreDefaultStartValue, 1);
1, &status); if (WaitCLSemId < 0)
elog(FATAL, "InitBufferPool: IpcSemaphoreCreate(WaitCLSemId) failed");
} }
#endif #endif
PrivateRefCount = (long *) calloc(NBuffers, sizeof(long)); PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.38 1999/07/17 20:17:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.39 1999/10/06 21:58:06 vadim Exp $
* *
* NOTES * NOTES
* *
...@@ -284,18 +284,6 @@ IPCPrivateMemoryKill(int status, ...@@ -284,18 +284,6 @@ IPCPrivateMemoryKill(int status,
} }
} }
/****************************************************************************/
/* IpcSemaphoreCreate(semKey, semNum, permission, semStartValue) */
/* */
/* - returns a semaphore identifier: */
/* */
/* if key doesn't exist: return a new id, status:= IpcSemIdNotExist */
/* if key exists: return the old id, status:= IpcSemIdExist */
/* if semNum > MAX : return # of argument, status:=IpcInvalidArgument */
/* */
/****************************************************************************/
/* /*
* Note: * Note:
* XXX This should be split into two different calls. One should * XXX This should be split into two different calls. One should
...@@ -312,8 +300,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey, ...@@ -312,8 +300,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
int semNum, int semNum,
int permission, int permission,
int semStartValue, int semStartValue,
int removeOnExit, int removeOnExit)
int *status)
{ {
int i; int i;
int errStatus; int errStatus;
...@@ -321,20 +308,14 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey, ...@@ -321,20 +308,14 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
u_short array[IPC_NMAXSEM]; u_short array[IPC_NMAXSEM];
union semun semun; union semun semun;
/* get a semaphore if non-existent */
/* check arguments */ /* check arguments */
if (semNum > IPC_NMAXSEM || semNum <= 0) if (semNum > IPC_NMAXSEM || semNum <= 0)
{ return(-1);
*status = IpcInvalidArgument;
return 2; /* returns the number of the invalid
* argument */
}
semId = semget(semKey, 0, 0); semId = semget(semKey, 0, 0);
if (semId == -1) if (semId == -1)
{ {
*status = IpcSemIdNotExist; /* there doesn't exist a semaphore */
#ifdef DEBUG_IPC #ifdef DEBUG_IPC
EPRINTF("calling semget with %d, %d , %d\n", EPRINTF("calling semget with %d, %d , %d\n",
semKey, semKey,
...@@ -348,7 +329,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey, ...@@ -348,7 +329,7 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
EPRINTF("IpcSemaphoreCreate: semget failed (%s) " EPRINTF("IpcSemaphoreCreate: semget failed (%s) "
"key=%d, num=%d, permission=%o", "key=%d, num=%d, permission=%o",
strerror(errno), semKey, semNum, permission); strerror(errno), semKey, semNum, permission);
proc_exit(3); return(-1);
} }
for (i = 0; i < semNum; i++) for (i = 0; i < semNum; i++)
array[i] = semStartValue; array[i] = semStartValue;
...@@ -358,22 +339,16 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey, ...@@ -358,22 +339,16 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey,
{ {
EPRINTF("IpcSemaphoreCreate: semctl failed (%s) id=%d", EPRINTF("IpcSemaphoreCreate: semctl failed (%s) id=%d",
strerror(errno), semId); strerror(errno), semId);
semctl(semId, 0, IPC_RMID, semun);
return(-1);
} }
if (removeOnExit) if (removeOnExit)
on_shmem_exit(IPCPrivateSemaphoreKill, (caddr_t) semId); on_shmem_exit(IPCPrivateSemaphoreKill, (caddr_t) semId);
}
else
{
/* there is a semaphore id for this key */
*status = IpcSemIdExist;
} }
#ifdef DEBUG_IPC #ifdef DEBUG_IPC
EPRINTF("\nIpcSemaphoreCreate, status %d, returns %d\n", EPRINTF("\nIpcSemaphoreCreate, returns %d\n", semId);
*status,
semId);
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
#endif #endif
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.30 1999/07/17 20:17:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.31 1999/10/06 21:58:06 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -54,17 +54,17 @@ void ...@@ -54,17 +54,17 @@ void
CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends) CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
{ {
int size; int size;
extern int XLOGShmemSize(void);
extern void XLOGShmemInit(void);
#ifdef HAS_TEST_AND_SET #ifdef HAS_TEST_AND_SET
/* --------------- /*
* create shared memory for slocks * Create shared memory for slocks
* --------------
*/ */
CreateAndInitSLockMemory(IPCKeyGetSLockSharedMemoryKey(key)); CreateAndInitSLockMemory(IPCKeyGetSLockSharedMemoryKey(key));
#endif #endif
/* ---------------- /*
* kill and create the buffer manager buffer pool (and semaphore) * Kill and create the buffer manager buffer pool (and semaphore)
* ----------------
*/ */
CreateSpinlocks(IPCKeyGetSpinLockSemaphoreKey(key)); CreateSpinlocks(IPCKeyGetSpinLockSemaphoreKey(key));
...@@ -73,7 +73,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends) ...@@ -73,7 +73,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
* moderately-accurate estimates for the big hogs, plus 100K for the * moderately-accurate estimates for the big hogs, plus 100K for the
* stuff that's too small to bother with estimating. * stuff that's too small to bother with estimating.
*/ */
size = BufferShmemSize() + LockShmemSize(maxBackends); size = BufferShmemSize() + LockShmemSize(maxBackends) + XLOGShmemSize();
#ifdef STABLE_MEMORY_STORAGE #ifdef STABLE_MEMORY_STORAGE
size += MMShmemSize(); size += MMShmemSize();
#endif #endif
...@@ -89,6 +89,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends) ...@@ -89,6 +89,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
ShmemCreate(IPCKeyGetBufferMemoryKey(key), size); ShmemCreate(IPCKeyGetBufferMemoryKey(key), size);
ShmemIndexReset(); ShmemIndexReset();
InitShmem(key, size); InitShmem(key, size);
XLOGShmemInit();
InitBufferPool(key); InitBufferPool(key);
/* ---------------- /* ----------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.46 1999/09/24 00:24:35 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.47 1999/10/06 21:58:06 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -187,8 +187,7 @@ InitShmem(unsigned int key, unsigned int size) ...@@ -187,8 +187,7 @@ InitShmem(unsigned int key, unsigned int size)
* bootstrap initialize spin locks so we can start to use the * bootstrap initialize spin locks so we can start to use the
* allocator and shmem index. * allocator and shmem index.
*/ */
if (!InitSpinLocks(ShmemBootstrap, IPCKeyGetSpinLockSemaphoreKey(key))) InitSpinLocks();
return FALSE;
/* /*
* We have just allocated additional space for two spinlocks. Now * We have just allocated additional space for two spinlocks. Now
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.20 1999/07/16 04:59:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.21 1999/10/06 21:58:06 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,15 +40,15 @@ IpcSemaphoreId SpinLockId; ...@@ -40,15 +40,15 @@ IpcSemaphoreId SpinLockId;
#ifdef HAS_TEST_AND_SET #ifdef HAS_TEST_AND_SET
/* real spin lock implementations */ /* real spin lock implementations */
bool void
CreateSpinlocks(IPCKey key) CreateSpinlocks(IPCKey key)
{ {
/* the spin lock shared memory must have been created by now */ /* the spin lock shared memory must have been created by now */
return TRUE; return;
} }
bool void
InitSpinLocks(int init, IPCKey key) InitSpinLocks(void)
{ {
extern SPINLOCK ShmemLock; extern SPINLOCK ShmemLock;
extern SPINLOCK ShmemIndexLock; extern SPINLOCK ShmemIndexLock;
...@@ -57,7 +57,8 @@ InitSpinLocks(int init, IPCKey key) ...@@ -57,7 +57,8 @@ InitSpinLocks(int init, IPCKey key)
extern SPINLOCK ProcStructLock; extern SPINLOCK ProcStructLock;
extern SPINLOCK SInvalLock; extern SPINLOCK SInvalLock;
extern SPINLOCK OidGenLockId; extern SPINLOCK OidGenLockId;
extern SPINLOCK XidGenLockId;
extern SPINLOCK ControlFileLockId;
#ifdef STABLE_MEMORY_STORAGE #ifdef STABLE_MEMORY_STORAGE
extern SPINLOCK MMCacheLock; extern SPINLOCK MMCacheLock;
...@@ -71,12 +72,14 @@ InitSpinLocks(int init, IPCKey key) ...@@ -71,12 +72,14 @@ InitSpinLocks(int init, IPCKey key)
ProcStructLock = (SPINLOCK) PROCSTRUCTLOCKID; ProcStructLock = (SPINLOCK) PROCSTRUCTLOCKID;
SInvalLock = (SPINLOCK) SINVALLOCKID; SInvalLock = (SPINLOCK) SINVALLOCKID;
OidGenLockId = (SPINLOCK) OIDGENLOCKID; OidGenLockId = (SPINLOCK) OIDGENLOCKID;
XidGenLockId = (SPINLOCK) XIDGENLOCKID;
ControlFileLockId = (SPINLOCK) CNTLFILELOCKID;
#ifdef STABLE_MEMORY_STORAGE #ifdef STABLE_MEMORY_STORAGE
MMCacheLock = (SPINLOCK) MMCACHELOCKID; MMCacheLock = (SPINLOCK) MMCACHELOCKID;
#endif #endif
return TRUE; return;
} }
#ifdef LOCKDEBUG #ifdef LOCKDEBUG
...@@ -224,55 +227,17 @@ SpinIsLocked(SPINLOCK lock) ...@@ -224,55 +227,17 @@ SpinIsLocked(SPINLOCK lock)
* the spinlocks * the spinlocks
* *
*/ */
bool void
CreateSpinlocks(IPCKey key) CreateSpinlocks(IPCKey key)
{ {
int status; SpinLockId = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection,
IpcSemaphoreId semid; IpcSemaphoreDefaultStartValue, 1);
semid = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection,
IpcSemaphoreDefaultStartValue, 1, &status);
if (status == IpcSemIdExist)
{
IpcSemaphoreKill(key);
elog(NOTICE, "Destroying old spinlock semaphore");
semid = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection,
IpcSemaphoreDefaultStartValue, 1, &status);
}
if (semid >= 0) if (SpinLockId <= 0)
{ elog(STOP, "CreateSpinlocks: cannot create spin locks");
SpinLockId = semid;
return TRUE;
}
/* cannot create spinlocks */
elog(FATAL, "CreateSpinlocks: cannot create spin locks");
return FALSE;
}
/*
* Attach to existing spinlock set
*/
static bool
AttachSpinLocks(IPCKey key)
{
IpcSemaphoreId id;
id = semget(key, MAX_SPINS, 0); return;
if (id < 0)
{
if (errno == EEXIST)
{
/* key is the name of someone else's semaphore */
elog(FATAL, "AttachSpinlocks: SPIN_KEY belongs to someone else");
}
/* cannot create spinlocks */
elog(FATAL, "AttachSpinlocks: cannot create spin locks");
return FALSE;
}
SpinLockId = id;
return TRUE;
} }
/* /*
...@@ -287,8 +252,8 @@ AttachSpinLocks(IPCKey key) ...@@ -287,8 +252,8 @@ AttachSpinLocks(IPCKey key)
* (SJCacheLock) for it. Same story for the main memory storage mgr. * (SJCacheLock) for it. Same story for the main memory storage mgr.
* *
*/ */
bool void
InitSpinLocks(int init, IPCKey key) InitSpinLocks(void)
{ {
extern SPINLOCK ShmemLock; extern SPINLOCK ShmemLock;
extern SPINLOCK ShmemIndexLock; extern SPINLOCK ShmemIndexLock;
...@@ -297,26 +262,14 @@ InitSpinLocks(int init, IPCKey key) ...@@ -297,26 +262,14 @@ InitSpinLocks(int init, IPCKey key)
extern SPINLOCK ProcStructLock; extern SPINLOCK ProcStructLock;
extern SPINLOCK SInvalLock; extern SPINLOCK SInvalLock;
extern SPINLOCK OidGenLockId; extern SPINLOCK OidGenLockId;
extern SPINLOCK XidGenLockId;
extern SPINLOCK ControlFileLockId;
#ifdef STABLE_MEMORY_STORAGE #ifdef STABLE_MEMORY_STORAGE
extern SPINLOCK MMCacheLock; extern SPINLOCK MMCacheLock;
#endif #endif
if (!init || key != IPC_PRIVATE)
{
/*
* if bootstrap and key is IPC_PRIVATE, it means that we are
* running backend by itself. no need to attach spinlocks
*/
if (!AttachSpinLocks(key))
{
elog(FATAL, "InitSpinLocks: couldnt attach spin locks");
return FALSE;
}
}
/* These five (or six) spinlocks have fixed location is shmem */ /* These five (or six) spinlocks have fixed location is shmem */
ShmemLock = (SPINLOCK) SHMEMLOCKID; ShmemLock = (SPINLOCK) SHMEMLOCKID;
ShmemIndexLock = (SPINLOCK) SHMEMINDEXLOCKID; ShmemIndexLock = (SPINLOCK) SHMEMINDEXLOCKID;
...@@ -325,12 +278,14 @@ InitSpinLocks(int init, IPCKey key) ...@@ -325,12 +278,14 @@ InitSpinLocks(int init, IPCKey key)
ProcStructLock = (SPINLOCK) PROCSTRUCTLOCKID; ProcStructLock = (SPINLOCK) PROCSTRUCTLOCKID;
SInvalLock = (SPINLOCK) SINVALLOCKID; SInvalLock = (SPINLOCK) SINVALLOCKID;
OidGenLockId = (SPINLOCK) OIDGENLOCKID; OidGenLockId = (SPINLOCK) OIDGENLOCKID;
XidGenLockId = (SPINLOCK) XIDGENLOCKID;
ControlFileLockId = (SPINLOCK) CNTLFILELOCKID;
#ifdef STABLE_MEMORY_STORAGE #ifdef STABLE_MEMORY_STORAGE
MMCacheLock = (SPINLOCK) MMCACHELOCKID; MMCacheLock = (SPINLOCK) MMCACHELOCKID;
#endif #endif
return TRUE; return;
} }
#endif /* HAS_TEST_AND_SET */ #endif /* HAS_TEST_AND_SET */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.61 1999/09/24 00:24:41 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.62 1999/10/06 21:58:07 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
* This is so that we can support more backends. (system-wide semaphore * This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95 * sets run out pretty fast.) -ay 4/95
* *
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.61 1999/09/24 00:24:41 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.62 1999/10/06 21:58:07 vadim Exp $
*/ */
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
#include "storage/proc.h" #include "storage/proc.h"
#include "utils/trace.h" #include "utils/trace.h"
static void HandleDeadLock(int sig); void HandleDeadLock(SIGNAL_ARGS);
static void ProcFreeAllSemaphores(void); static void ProcFreeAllSemaphores(void);
#define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT] #define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
...@@ -84,12 +84,6 @@ static void ProcFreeAllSemaphores(void); ...@@ -84,12 +84,6 @@ static void ProcFreeAllSemaphores(void);
*/ */
SPINLOCK ProcStructLock; SPINLOCK ProcStructLock;
/*
* For cleanup routines. Don't cleanup if the initialization
* has not happened.
*/
static bool ProcInitialized = FALSE;
static PROC_HDR *ProcGlobal = NULL; static PROC_HDR *ProcGlobal = NULL;
PROC *MyProc = NULL; PROC *MyProc = NULL;
...@@ -167,8 +161,9 @@ InitProcGlobal(IPCKey key, int maxBackends) ...@@ -167,8 +161,9 @@ InitProcGlobal(IPCKey key, int maxBackends)
PROC_NSEMS_PER_SET, PROC_NSEMS_PER_SET,
IPCProtection, IPCProtection,
IpcSemaphoreDefaultStartValue, IpcSemaphoreDefaultStartValue,
0, 0);
&semstat); if (semId < 0)
elog(FATAL, "InitProcGlobal: IpcSemaphoreCreate failed");
/* mark this sema set allocated */ /* mark this sema set allocated */
ProcGlobal->freeSemMap[i] = (1 << PROC_NSEMS_PER_SET); ProcGlobal->freeSemMap[i] = (1 << PROC_NSEMS_PER_SET);
} }
...@@ -189,12 +184,6 @@ InitProcess(IPCKey key) ...@@ -189,12 +184,6 @@ InitProcess(IPCKey key)
unsigned long location, unsigned long location,
myOffset; myOffset;
/* ------------------
* Routine called if deadlock timer goes off. See ProcSleep()
* ------------------
*/
pqsignal(SIGALRM, HandleDeadLock);
SpinAcquire(ProcStructLock); SpinAcquire(ProcStructLock);
/* attach to the free list */ /* attach to the free list */
...@@ -203,7 +192,7 @@ InitProcess(IPCKey key) ...@@ -203,7 +192,7 @@ InitProcess(IPCKey key)
if (!found) if (!found)
{ {
/* this should not happen. InitProcGlobal() is called before this. */ /* this should not happen. InitProcGlobal() is called before this. */
elog(ERROR, "InitProcess: Proc Header uninitialized"); elog(STOP, "InitProcess: Proc Header uninitialized");
} }
if (MyProc != NULL) if (MyProc != NULL)
...@@ -271,8 +260,7 @@ InitProcess(IPCKey key) ...@@ -271,8 +260,7 @@ InitProcess(IPCKey key)
PROC_NSEMS_PER_SET, PROC_NSEMS_PER_SET,
IPCProtection, IPCProtection,
IpcSemaphoreDefaultStartValue, IpcSemaphoreDefaultStartValue,
0, 0);
&semstat);
/* /*
* we might be reusing a semaphore that belongs to a dead backend. * we might be reusing a semaphore that belongs to a dead backend.
...@@ -316,14 +304,12 @@ InitProcess(IPCKey key) ...@@ -316,14 +304,12 @@ InitProcess(IPCKey key)
*/ */
location = MAKE_OFFSET(MyProc); location = MAKE_OFFSET(MyProc);
if ((!ShmemPIDLookup(MyProcPid, &location)) || (location != MAKE_OFFSET(MyProc))) if ((!ShmemPIDLookup(MyProcPid, &location)) || (location != MAKE_OFFSET(MyProc)))
elog(FATAL, "InitProc: ShmemPID table broken"); elog(STOP, "InitProc: ShmemPID table broken");
MyProc->errType = NO_ERROR; MyProc->errType = NO_ERROR;
SHMQueueElemInit(&(MyProc->links)); SHMQueueElemInit(&(MyProc->links));
on_shmem_exit(ProcKill, (caddr_t) MyProcPid); on_shmem_exit(ProcKill, (caddr_t) MyProcPid);
ProcInitialized = TRUE;
} }
/* /*
...@@ -755,8 +741,8 @@ ProcAddLock(SHM_QUEUE *elem) ...@@ -755,8 +741,8 @@ ProcAddLock(SHM_QUEUE *elem)
* up my semaphore. * up my semaphore.
* -------------------- * --------------------
*/ */
static void void
HandleDeadLock(int sig) HandleDeadLock(SIGNAL_ARGS)
{ {
LOCK *mywaitlock; LOCK *mywaitlock;
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.48 1999/09/11 19:06:31 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.49 1999/10/06 21:58:09 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
extern int errno; extern int errno;
extern int sys_nerr; extern int sys_nerr;
extern CommandDest whereToSendOutput;
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
/* /*
...@@ -107,6 +108,19 @@ elog(int lev, const char *fmt, ...) ...@@ -107,6 +108,19 @@ elog(int lev, const char *fmt, ...)
if (lev <= DEBUG && Debugfile < 0) if (lev <= DEBUG && Debugfile < 0)
return; /* ignore debug msgs if noplace to send */ return; /* ignore debug msgs if noplace to send */
if (lev == ERROR || lev == FATAL)
{
if (IsInitProcessingMode())
{
extern TransactionState CurrentTransactionState;
if (CurrentTransactionState->state != TRANS_DEFAULT &&
CurrentTransactionState->state != TRANS_DISABLED)
abort();
lev = FATAL;
}
}
/* choose message prefix and indent level */ /* choose message prefix and indent level */
switch (lev) switch (lev)
{ {
...@@ -304,7 +318,7 @@ elog(int lev, const char *fmt, ...) ...@@ -304,7 +318,7 @@ elog(int lev, const char *fmt, ...)
#ifndef PG_STANDALONE #ifndef PG_STANDALONE
if (lev > DEBUG && IsUnderPostmaster) if (lev > DEBUG && whereToSendOutput == Remote)
{ {
/* Send IPC message to the front-end program */ /* Send IPC message to the front-end program */
char msgtype; char msgtype;
...@@ -336,7 +350,7 @@ elog(int lev, const char *fmt, ...) ...@@ -336,7 +350,7 @@ elog(int lev, const char *fmt, ...)
pq_flush(); pq_flush();
} }
if (lev > DEBUG && ! IsUnderPostmaster) if (lev > DEBUG && whereToSendOutput != Remote)
{ {
/* We are running as an interactive backend, so just send /* We are running as an interactive backend, so just send
* the message to stderr. * the message to stderr.
...@@ -355,36 +369,29 @@ elog(int lev, const char *fmt, ...) ...@@ -355,36 +369,29 @@ elog(int lev, const char *fmt, ...)
/* /*
* Perform error recovery action as specified by lev. * Perform error recovery action as specified by lev.
*/ */
if (lev == ERROR) if (lev == ERROR || lev == FATAL)
{ {
if (InError) if (InError)
{ {
/* error reported during error recovery; don't loop forever */ /* error reported during error recovery; don't loop forever */
elog(REALLYFATAL, "elog: error during error recovery, giving up!"); elog(REALLYFATAL, "elog: error during error recovery, giving up!");
} }
/* exit to main loop */ InError = true;
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */ ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
if (lev == FATAL)
{
if (IsInitProcessingMode())
ExitPostgres(0);
ExitAfterAbort = true;
}
/* exit to main loop */
siglongjmp(Warn_restart, 1); siglongjmp(Warn_restart, 1);
} }
if (lev == FATAL)
{
/*
* Assume that if we have detected the failure we can exit with a
* normal exit status. This will prevent the postmaster from
* cleaning up when it's not needed.
*/
fflush(stdout);
fflush(stderr);
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
ProcReleaseLocks(); /* get rid of real locks we hold */
proc_exit(0);
}
if (lev > FATAL) if (lev > FATAL)
{ {
/* /*
* Serious crash time. Postmaster will observe nonzero * Serious crash time. Postmaster will observe nonzero
* process exit status and kill the other backends too. * process exit status and kill the other backends too.
*/ */
fflush(stdout); fflush(stdout);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.34 1999/07/17 20:18:08 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.35 1999/10/06 21:58:10 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -133,20 +133,7 @@ StatusPostmasterExit(int status) ...@@ -133,20 +133,7 @@ StatusPostmasterExit(int status)
* processing mode support stuff (used to be in pmod.c) * processing mode support stuff (used to be in pmod.c)
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
static ProcessingMode Mode = NoProcessing; static ProcessingMode Mode = InitProcessing;
#ifdef NOT_USED
/*
* IsNoProcessingMode
* True iff processing mode is NoProcessing.
*/
bool
IsNoProcessingMode()
{
return (bool) (Mode == NoProcessing);
}
#endif
/* /*
* IsBootstrapProcessingMode * IsBootstrapProcessingMode
...@@ -186,13 +173,13 @@ IsNormalProcessingMode() ...@@ -186,13 +173,13 @@ IsNormalProcessingMode()
* BadArg if called with invalid mode. * BadArg if called with invalid mode.
* *
* Note: * Note:
* Mode is NoProcessing before the first time this is called. * Mode is InitProcessing before the first time this is called.
*/ */
void void
SetProcessingMode(ProcessingMode mode) SetProcessingMode(ProcessingMode mode)
{ {
AssertArg(mode == NoProcessing || mode == BootstrapProcessing || AssertArg(mode == BootstrapProcessing || mode == InitProcessing ||
mode == InitProcessing || mode == NormalProcessing); mode == NormalProcessing);
Mode = mode; Mode = mode;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.50 1999/09/28 11:41:09 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.51 1999/10/06 21:58:10 vadim Exp $
* *
* NOTES * NOTES
* InitPostgres() is the function called from PostgresMain * InitPostgres() is the function called from PostgresMain
...@@ -53,12 +53,13 @@ ...@@ -53,12 +53,13 @@
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#endif #endif
void BaseInit(void);
static void VerifySystemDatabase(void); static void VerifySystemDatabase(void);
static void VerifyMyDatabase(void); static void VerifyMyDatabase(void);
static void ReverifyMyDatabase(char *name); static void ReverifyMyDatabase(char *name);
static void InitCommunication(void); static void InitCommunication(void);
static void InitMyDatabaseInfo(char *name); static void InitMyDatabaseInfo(char *name);
static void InitStdio(void);
static void InitUserid(void); static void InitUserid(void);
...@@ -385,37 +386,6 @@ InitCommunication() ...@@ -385,37 +386,6 @@ InitCommunication()
{ {
if (MyBackendTag == -1) if (MyBackendTag == -1)
elog(FATAL, "InitCommunication: missing POSTID"); elog(FATAL, "InitCommunication: missing POSTID");
/*
* Enable this if you are trying to force the backend to run as if
* it is running under the postmaster.
*
* This goto forces Postgres to attach to shared memory instead of
* using malloc'ed memory (which is the normal behavior if run
* directly).
*
* To enable emulation, run the following shell commands (in addition
* to enabling this goto)
*
* % setenv POSTID 1 % setenv POSTPORT 4321 % setenv IPC_KEY 4321000
* % postmaster & % kill -9 %1
*
* Upon doing this, Postmaster will have allocated the shared memory
* resources that Postgres will attach to if you enable
* EMULATE_UNDER_POSTMASTER.
*
* This comment may well age with time - it is current as of 8
* January 1990
*
* Greg
*/
#ifdef EMULATE_UNDER_POSTMASTER
goto forcesharedmemory;
#endif
} }
else if (IsUnderPostmaster) else if (IsUnderPostmaster)
{ {
...@@ -439,12 +409,6 @@ InitCommunication() ...@@ -439,12 +409,6 @@ InitCommunication()
* initialize shared memory and semaphores appropriately. * initialize shared memory and semaphores appropriately.
* ---------------- * ----------------
*/ */
#ifdef EMULATE_UNDER_POSTMASTER
forcesharedmemory:
#endif
if (!IsUnderPostmaster) /* postmaster already did this */ if (!IsUnderPostmaster) /* postmaster already did this */
{ {
PostgresIpcKey = key; PostgresIpcKey = key;
...@@ -452,21 +416,6 @@ forcesharedmemory: ...@@ -452,21 +416,6 @@ forcesharedmemory:
} }
} }
/* --------------------------------
* InitStdio
*
* this routine consists of a bunch of code fragments
* that used to be randomly scattered through cinit().
* they all seem to do stuff associated with io.
* --------------------------------
*/
static void
InitStdio()
{
DebugFileOpen();
}
/* -------------------------------- /* --------------------------------
* InitPostgres * InitPostgres
* Initialize POSTGRES. * Initialize POSTGRES.
...@@ -477,8 +426,6 @@ InitStdio() ...@@ -477,8 +426,6 @@ InitStdio()
*/ */
extern int NBuffers; extern int NBuffers;
bool PostgresIsInitialized = false;
int lockingOff = 0; /* backend -L switch */ int lockingOff = 0; /* backend -L switch */
/* /*
...@@ -488,37 +435,11 @@ InitPostgres(char *name) /* database name */ ...@@ -488,37 +435,11 @@ InitPostgres(char *name) /* database name */
{ {
bool bootstrap; /* true if BootstrapProcessing */ bool bootstrap; /* true if BootstrapProcessing */
/* ---------------- /*
* see if we're running in BootstrapProcessing mode * See if we're running in BootstrapProcessing mode
* ----------------
*/ */
bootstrap = IsBootstrapProcessingMode(); bootstrap = IsBootstrapProcessingMode();
/* ----------------
* turn on the exception handler. Note: we cannot use elog, Assert,
* AssertState, etc. until after exception handling is on.
* ----------------
*/
EnableExceptionHandling(true);
/* ----------------
* A stupid check to make sure we don't call this more than once.
* But things like ReinitPostgres() get around this by just diddling
* the PostgresIsInitialized flag.
* ----------------
*/
AssertState(!PostgresIsInitialized);
/* ----------------
* Memory system initialization.
* (we may call palloc after EnableMemoryContext())
*
* Note EnableMemoryContext() must happen before EnablePortalManager().
* ----------------
*/
EnableMemoryContext(true); /* initializes the "top context" */
EnablePortalManager(true); /* memory for portal/transaction stuff */
/* ---------------- /* ----------------
* initialize the backend local portal stack used by * initialize the backend local portal stack used by
* internal PQ function calls. see src/lib/libpq/be-dumpdata.c * internal PQ function calls. see src/lib/libpq/be-dumpdata.c
...@@ -528,14 +449,6 @@ InitPostgres(char *name) /* database name */ ...@@ -528,14 +449,6 @@ InitPostgres(char *name) /* database name */
*/ */
be_portalinit(); be_portalinit();
/* ----------------
* attach to shared memory and semaphores, and initialize our
* input/output/debugging file descriptors.
* ----------------
*/
InitCommunication();
InitStdio();
/* /*
* initialize the local buffer manager * initialize the local buffer manager
*/ */
...@@ -574,13 +487,9 @@ InitPostgres(char *name) /* database name */ ...@@ -574,13 +487,9 @@ InitPostgres(char *name) /* database name */
* Will try that, but may not work... - thomas 1997-11-01 * Will try that, but may not work... - thomas 1997-11-01
*/ */
/* Does not touch files (?) - thomas 1997-11-01 */ /*
smgrinit(); * Initialize the transaction system and the relation descriptor cache.
* Note we have to make certain the lock manager is off while we do this.
/* ----------------
* initialize the transaction system and the relation descriptor cache.
* Note we have to make certain the lock manager is off while we do this.
* ----------------
*/ */
AmiTransactionOverride(IsBootstrapProcessingMode()); AmiTransactionOverride(IsBootstrapProcessingMode());
LockDisable(true); LockDisable(true);
...@@ -598,20 +507,18 @@ InitPostgres(char *name) /* database name */ ...@@ -598,20 +507,18 @@ InitPostgres(char *name) /* database name */
LockDisable(false); LockDisable(false);
/* ---------------- /*
* Set up my per-backend PROC struct in shared memory. * Set up my per-backend PROC struct in shared memory.
* ----------------
*/ */
InitProcess(PostgresIpcKey); InitProcess(PostgresIpcKey);
/* ---------------- /*
* Initialize my entry in the shared-invalidation manager's * Initialize my entry in the shared-invalidation manager's
* array of per-backend data. (Formerly this came before * array of per-backend data. (Formerly this came before
* InitProcess, but now it must happen after, because it uses * InitProcess, but now it must happen after, because it uses
* MyProc.) Once I have done this, I am visible to other backends! * MyProc.) Once I have done this, I am visible to other backends!
* *
* Sets up MyBackendId, a unique backend identifier. * Sets up MyBackendId, a unique backend identifier.
* ----------------
*/ */
InitSharedInvalidationState(); InitSharedInvalidationState();
...@@ -622,16 +529,14 @@ InitPostgres(char *name) /* database name */ ...@@ -622,16 +529,14 @@ InitPostgres(char *name) /* database name */
MyBackendId); MyBackendId);
} }
/* ---------------- /*
* initialize the access methods. * Initialize the access methods.
* Does not touch files (?) - thomas 1997-11-01 * Does not touch files (?) - thomas 1997-11-01
* ----------------
*/ */
initam(); initam();
/* ---------------- /*
* initialize all the system catalog caches. * Initialize all the system catalog caches.
* ----------------
*/ */
zerocaches(); zerocaches();
...@@ -641,34 +546,19 @@ InitPostgres(char *name) /* database name */ ...@@ -641,34 +546,19 @@ InitPostgres(char *name) /* database name */
*/ */
InitCatalogCache(); InitCatalogCache();
/* ---------------- /*
* set ourselves to the proper user id and figure out our postgres * Set ourselves to the proper user id and figure out our postgres
* user id. If we ever add security so that we check for valid * user id. If we ever add security so that we check for valid
* postgres users, we might do it here. * postgres users, we might do it here.
* ----------------
*/ */
InitUserid(); InitUserid();
/* ---------------- /*
* initialize local data in cache invalidation stuff * Initialize local data in cache invalidation stuff
* ----------------
*/ */
if (!bootstrap) if (!bootstrap)
InitLocalInvalidateData(); InitLocalInvalidateData();
/* ----------------
* ok, all done, now let's make sure we don't do it again.
* ----------------
*/
PostgresIsInitialized = true;
/* ----------------
* Done with "InitPostgres", now change to NormalProcessing unless
* we're in BootstrapProcessing mode.
* ----------------
*/
if (!bootstrap)
SetProcessingMode(NormalProcessing);
if (lockingOff) if (lockingOff)
LockDisable(true); LockDisable(true);
...@@ -680,3 +570,30 @@ InitPostgres(char *name) /* database name */ ...@@ -680,3 +570,30 @@ InitPostgres(char *name) /* database name */
if (!bootstrap) if (!bootstrap)
ReverifyMyDatabase(name); ReverifyMyDatabase(name);
} }
void
BaseInit(void)
{
/*
* Turn on the exception handler. Note: we cannot use elog, Assert,
* AssertState, etc. until after exception handling is on.
*/
EnableExceptionHandling(true);
/*
* Memory system initialization - we may call palloc after
* EnableMemoryContext()). Note that EnableMemoryContext()
* must happen before EnablePortalManager().
*/
EnableMemoryContext(true); /* initializes the "top context" */
EnablePortalManager(true); /* memory for portal/transaction stuff */
/*
* Attach to shared memory and semaphores, and initialize our
* input/output/debugging file descriptors.
*/
InitCommunication();
DebugFileOpen();
smgrinit();
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.31 1999/07/15 22:40:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.32 1999/10/06 21:58:11 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#include "utils/tqual.h" #include "utils/tqual.h"
extern bool PostgresIsInitialized;
SnapshotData SnapshotDirtyData; SnapshotData SnapshotDirtyData;
Snapshot SnapshotDirty = &SnapshotDirtyData; Snapshot SnapshotDirty = &SnapshotDirtyData;
...@@ -194,17 +192,6 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple) ...@@ -194,17 +192,6 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple)
if (AMI_OVERRIDE) if (AMI_OVERRIDE)
return true; return true;
/*
* If the transaction system isn't yet initialized, then we assume
* that transactions committed. We only look at system catalogs
* during startup, so this is less awful than it seems, but it's still
* pretty awful.
*/
if (!PostgresIsInitialized)
return ((bool) (TransactionIdIsValid(tuple->t_xmin) &&
!TransactionIdIsValid(tuple->t_xmax)));
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
{ {
if (tuple->t_infomask & HEAP_XMIN_INVALID) if (tuple->t_infomask & HEAP_XMIN_INVALID)
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.60 1999/05/20 16:50:06 wieck Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.61 1999/10/06 21:58:12 vadim Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -300,6 +300,12 @@ else ...@@ -300,6 +300,12 @@ else
mkdir $PGDATA/base mkdir $PGDATA/base
if [ $? -ne 0 ]; then exit 5; fi if [ $? -ne 0 ]; then exit 5; fi
fi fi
if [ ! -d $PGDATA/pg_xlog ]; then
echo "Creating Postgres database XLOG directory $PGDATA/pg_xlog"
echo
mkdir $PGDATA/pg_xlog
if [ $? -ne 0 ]; then exit 5; fi
fi
fi fi
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
...@@ -316,6 +322,7 @@ else ...@@ -316,6 +322,7 @@ else
fi fi
BACKENDARGS="-boot -C -F -D$PGDATA $BACKEND_TALK_ARG" BACKENDARGS="-boot -C -F -D$PGDATA $BACKEND_TALK_ARG"
FIRSTRUN="-boot -x -C -F -D$PGDATA $BACKEND_TALK_ARG"
echo "Creating template database in $PGDATA/base/template1" echo "Creating template database in $PGDATA/base/template1"
[ "$debug" -ne 0 ] && echo "Running: postgres $BACKENDARGS template1" [ "$debug" -ne 0 ] && echo "Running: postgres $BACKENDARGS template1"
...@@ -323,7 +330,7 @@ echo "Creating template database in $PGDATA/base/template1" ...@@ -323,7 +330,7 @@ echo "Creating template database in $PGDATA/base/template1"
cat $TEMPLATE \ cat $TEMPLATE \
| sed -e "s/postgres PGUID/$POSTGRES_SUPERUSERNAME $POSTGRES_SUPERUID/" \ | sed -e "s/postgres PGUID/$POSTGRES_SUPERUSERNAME $POSTGRES_SUPERUID/" \
-e "s/PGUID/$POSTGRES_SUPERUID/" \ -e "s/PGUID/$POSTGRES_SUPERUID/" \
| postgres $BACKENDARGS template1 | postgres $FIRSTRUN template1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: could not create template database" echo "$CMDNAME: could not create template database"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pqsignal.h,v 1.9 1999/02/13 23:21:36 momjian Exp $ * $Id: pqsignal.h,v 1.10 1999/10/06 21:58:16 vadim Exp $
* *
* NOTES * NOTES
* This shouldn't be in libpq, but the monitor and some other * This shouldn't be in libpq, but the monitor and some other
...@@ -17,6 +17,28 @@ ...@@ -17,6 +17,28 @@
#ifndef PQSIGNAL_H #ifndef PQSIGNAL_H
#define PQSIGNAL_H #define PQSIGNAL_H
#ifdef HAVE_SIGPROCMASK
extern sigset_t UnBlockSig,
BlockSig;
#define PG_INITMASK() ( \
sigemptyset(&UnBlockSig), \
sigfillset(&BlockSig) \
)
#define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
#else
extern int UnBlockSig,
BlockSig;
#define PG_INITMASK() ( \
UnBlockSig = 0, \
BlockSig = sigmask(SIGHUP) | sigmask(SIGQUIT) | \
sigmask(SIGTERM) | sigmask(SIGALRM) | \
sigmask(SIGINT) | sigmask(SIGUSR1) | \
sigmask(SIGUSR2) | sigmask(SIGCHLD) | \
sigmask(SIGWINCH) | sigmask(SIGFPE) \
)
#define PG_SETMASK(mask) sigsetmask(*((int*)(mask)))
#endif
typedef void (*pqsigfunc) (int); typedef void (*pqsigfunc) (int);
extern pqsigfunc pqsignal(int signo, pqsigfunc func); extern pqsigfunc pqsignal(int signo, pqsigfunc func);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: miscadmin.h,v 1.42 1999/09/27 20:27:26 momjian Exp $ * $Id: miscadmin.h,v 1.43 1999/10/06 21:58:13 vadim Exp $
* *
* NOTES * NOTES
* some of the information in this file will be moved to * some of the information in this file will be moved to
...@@ -143,28 +143,25 @@ extern int CheckPathAccess(char *path, char *name, int open_mode); ...@@ -143,28 +143,25 @@ extern int CheckPathAccess(char *path, char *name, int open_mode);
*****************************************************************************/ *****************************************************************************/
/* /*
* Description: * Description:
* There are four processing modes in POSTGRES. They are NoProcessing * There are three processing modes in POSTGRES. They are
* or "none," BootstrapProcessing or "bootstrap," InitProcessing or * "BootstrapProcessing or "bootstrap," InitProcessing or
* "initialization," and NormalProcessing or "normal." * "initialization," and NormalProcessing or "normal."
* *
* If a POSTGRES binary is in normal mode, then all code may be executed * The first two processing modes are used during special times. When the
* normally. In the none mode, only bookkeeping code may be called. In
* particular, access method calls may not occur in this mode since the
* execution state is outside a transaction.
*
* The final two processing modes are used during special times. When the
* system state indicates bootstrap processing, transactions are all given * system state indicates bootstrap processing, transactions are all given
* transaction id "one" and are consequently guarenteed to commit. This mode * transaction id "one" and are consequently guarenteed to commit. This mode
* is used during the initial generation of template databases. * is used during the initial generation of template databases.
* *
* Finally, the execution state is in initialization mode until all normal * Initialization mode until all normal initialization is complete.
* initialization is complete. Some code behaves differently when executed in * Some code behaves differently when executed in this mode to enable
* this mode to enable system bootstrapping. * system bootstrapping.
*
* If a POSTGRES binary is in normal mode, then all code may be executed
* normally.
*/ */
typedef enum ProcessingMode typedef enum ProcessingMode
{ {
NoProcessing, /* "nothing" can be done */
BootstrapProcessing, /* bootstrap creation of template database */ BootstrapProcessing, /* bootstrap creation of template database */
InitProcessing, /* initializing system */ InitProcessing, /* initializing system */
NormalProcessing /* normal processing */ NormalProcessing /* normal processing */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: ipc.h,v 1.35 1999/07/15 23:04:10 momjian Exp $ * $Id: ipc.h,v 1.36 1999/10/06 21:58:17 vadim Exp $
* *
* NOTES * NOTES
* This file is very architecture-specific. This stuff should actually * This file is very architecture-specific. This stuff should actually
...@@ -79,7 +79,7 @@ extern void on_exit_reset(void); ...@@ -79,7 +79,7 @@ extern void on_exit_reset(void);
extern IpcSemaphoreId IpcSemaphoreCreate(IpcSemaphoreKey semKey, extern IpcSemaphoreId IpcSemaphoreCreate(IpcSemaphoreKey semKey,
int semNum, int permission, int semStartValue, int semNum, int permission, int semStartValue,
int removeOnExit, int *status); int removeOnExit);
extern void IpcSemaphoreKill(IpcSemaphoreKey key); extern void IpcSemaphoreKill(IpcSemaphoreKey key);
extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock); extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock);
extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock); extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock);
...@@ -105,6 +105,8 @@ typedef enum _LockId_ ...@@ -105,6 +105,8 @@ typedef enum _LockId_
BUFMGRLOCKID, BUFMGRLOCKID,
LOCKLOCKID, LOCKLOCKID,
OIDGENLOCKID, OIDGENLOCKID,
XIDGENLOCKID,
CNTLFILELOCKID,
SHMEMLOCKID, SHMEMLOCKID,
SHMEMINDEXLOCKID, SHMEMINDEXLOCKID,
LOCKMGRLOCKID, LOCKMGRLOCKID,
...@@ -147,6 +149,8 @@ typedef enum _LockId_ ...@@ -147,6 +149,8 @@ typedef enum _LockId_
PROCSTRUCTLOCKID, PROCSTRUCTLOCKID,
OIDGENLOCKID, OIDGENLOCKID,
XIDGENLOCKID,
CNTLFILELOCKID,
FIRSTFREELOCKID FIRSTFREELOCKID
} _LockId_; } _LockId_;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: spin.h,v 1.9 1999/07/15 23:04:16 momjian Exp $ * $Id: spin.h,v 1.10 1999/10/06 21:58:17 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
typedef int SPINLOCK; typedef int SPINLOCK;
extern bool CreateSpinlocks(IPCKey key); extern void CreateSpinlocks(IPCKey key);
extern bool InitSpinLocks(int init, IPCKey key); extern void InitSpinLocks(void);
extern void SpinAcquire(SPINLOCK lockid); extern void SpinAcquire(SPINLOCK lockid);
extern void SpinRelease(SPINLOCK lockid); extern void SpinRelease(SPINLOCK lockid);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: tcopprot.h,v 1.21 1999/05/26 12:56:58 momjian Exp $ * $Id: tcopprot.h,v 1.22 1999/10/06 21:58:18 vadim Exp $
* *
* OLD COMMENTS * OLD COMMENTS
* This file was created so that other c files could get the two * This file was created so that other c files could get the two
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#endif #endif
extern DLLIMPORT sigjmp_buf Warn_restart; extern DLLIMPORT sigjmp_buf Warn_restart;
extern bool InError; extern bool InError;
extern bool ExitAfterAbort;
#ifndef BOOTSTRAP_INCLUDE #ifndef BOOTSTRAP_INCLUDE
extern List *pg_parse_and_plan(char *query_string, Oid *typev, int nargs, extern List *pg_parse_and_plan(char *query_string, Oid *typev, int nargs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment