summaryrefslogtreecommitdiff
path: root/src/backend/bootstrap/bootstrap.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-06-28 03:33:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-06-28 03:33:33 +0000
commit1aebc3618a0be13451918581ad390ad9a3518702 (patch)
treee8ab228245c43ff086bd8e9d65baf3d1d9a5f96a /src/backend/bootstrap/bootstrap.c
parentb601c8d8828ee02ffb195dead82b233b9572fe32 (diff)
First phase of memory management rewrite (see backend/utils/mmgr/README
for details). It doesn't really do that much yet, since there are no short-term memory contexts in the executor, but the infrastructure is in place and long-term contexts are handled reasonably. A few long- standing bugs have been fixed, such as 'VACUUM; anything' in a single query string crashing. Also, out-of-memory is now considered a recoverable ERROR, not FATAL. Eliminate a large amount of crufty, now-dead code in and around memory management. Fix problem with holding off SIGTRAP, SIGSEGV, etc in postmaster and backend startup.
Diffstat (limited to 'src/backend/bootstrap/bootstrap.c')
-rw-r--r--src/backend/bootstrap/bootstrap.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index b49d5ef8bf3..54d4ab8139c 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.87 2000/06/22 22:31:17 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.88 2000/06/28 03:31:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,14 +34,14 @@
#include "miscadmin.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
+#include "utils/exc.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
-#include "utils/portal.h"
+
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
-extern void BaseInit(void);
extern void StartupXLOG(void);
extern void ShutdownXLOG(void);
extern void BootStrapXLOG(void);
@@ -144,8 +144,8 @@ static Datum values[MAXATTR]; /* corresponding attribute values */
int numattr; /* number of attributes for cur. rel */
int DebugMode;
-static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem
- * context */
+
+static MemoryContext nogc = NULL; /* special no-gc mem context */
extern int optind;
extern char *optarg;
@@ -240,6 +240,17 @@ BootstrapMain(int argc, char *argv[])
MyProcPid = getpid();
+ /*
+ * Fire up essential subsystems: error and memory management
+ *
+ * If we are running under the postmaster, this is done already.
+ */
+ if (!IsUnderPostmaster)
+ {
+ EnableExceptionHandling(true);
+ MemoryContextInit();
+ }
+
/* ----------------
* process command arguments
* ----------------
@@ -428,7 +439,6 @@ boot_openrel(char *relname)
if (Typ == (struct typmap **) NULL)
{
- StartPortalAllocMode(DefaultAllocMode, 0);
rel = heap_openr(TypeRelationName, NoLock);
Assert(rel);
scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
@@ -445,13 +455,13 @@ boot_openrel(char *relname)
while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
{
(*app)->am_oid = tup->t_data->t_oid;
- memmove((char *) &(*app++)->am_typ,
- (char *) GETSTRUCT(tup),
- sizeof((*app)->am_typ));
+ memcpy((char *) &(*app)->am_typ,
+ (char *) GETSTRUCT(tup),
+ sizeof((*app)->am_typ));
+ app++;
}
heap_endscan(scan);
heap_close(rel, NoLock);
- EndPortalAllocMode();
}
if (reldesc != NULL)
@@ -1088,10 +1098,14 @@ index_register(char *heap,
* them later.
*/
- if (nogc == (GlobalMemory) NULL)
- nogc = CreateGlobalMemory("BootstrapNoGC");
+ if (nogc == NULL)
+ nogc = AllocSetContextCreate((MemoryContext) NULL,
+ "BootstrapNoGC",
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
- oldcxt = MemoryContextSwitchTo((MemoryContext) nogc);
+ oldcxt = MemoryContextSwitchTo(nogc);
newind = (IndexList *) palloc(sizeof(IndexList));
newind->il_heap = pstrdup(heap);