aboutsummaryrefslogtreecommitdiff
path: root/src/backend/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/bootstrap')
-rw-r--r--src/backend/bootstrap/bootparse.y42
-rw-r--r--src/backend/bootstrap/bootstrap.c74
2 files changed, 48 insertions, 68 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 825620a6fb9..04f68adee7f 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.39 2001/09/29 04:02:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.40 2002/03/02 21:39:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,8 +54,7 @@ static void
do_start()
{
StartTransactionCommand();
- if (DebugMode)
- elog(DEBUG, "start transaction");
+ elog(DEBUG3, "start transaction");
}
@@ -63,8 +62,7 @@ static void
do_end()
{
CommitTransactionCommand();
- if (DebugMode)
- elog(DEBUG, "commit transaction");
+ elog(DEBUG3, "commit transaction");
if (isatty(0))
{
printf("bootstrap> ");
@@ -154,15 +152,12 @@ Boot_CreateStmt:
{
do_start();
numattr = 0;
- if (DebugMode)
- {
- if ($2)
- elog(DEBUG, "creating bootstrap relation %s...",
- LexIDStr($4));
- else
- elog(DEBUG, "creating relation %s...",
- LexIDStr($4));
- }
+ if ($2)
+ elog(DEBUG3, "creating bootstrap relation %s...",
+ LexIDStr($4));
+ else
+ elog(DEBUG3, "creating relation %s...",
+ LexIDStr($4));
}
boot_typelist
{
@@ -179,7 +174,7 @@ Boot_CreateStmt:
if (reldesc)
{
- elog(DEBUG, "create bootstrap: warning, open relation exists, closing first");
+ elog(DEBUG3, "create bootstrap: warning, open relation exists, closing first");
closerel(NULL);
}
@@ -187,8 +182,7 @@ Boot_CreateStmt:
reldesc = heap_create(LexIDStr($4), tupdesc,
false, true, true);
reldesc->rd_rel->relhasoids = ! ($3);
- if (DebugMode)
- elog(DEBUG, "bootstrap relation created");
+ elog(DEBUG3, "bootstrap relation created");
}
else
{
@@ -202,8 +196,7 @@ Boot_CreateStmt:
! ($3),
false,
true);
- if (DebugMode)
- elog(DEBUG, "relation created with oid %u", id);
+ elog(DEBUG3, "relation created with oid %u", id);
}
do_end();
}
@@ -213,13 +206,10 @@ Boot_InsertStmt:
INSERT_TUPLE optoideq
{
do_start();
- if (DebugMode)
- {
- if ($2)
- elog(DEBUG, "inserting row with oid %u...", $2);
- else
- elog(DEBUG, "inserting row...");
- }
+ if ($2)
+ elog(DEBUG3, "inserting row with oid %u...", $2);
+ else
+ elog(DEBUG3, "inserting row...");
num_columns_read = 0;
}
LPAREN boot_tuplelist RPAREN
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 48cbf570e83..192303f9d61 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.121 2002/02/23 01:31:34 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.122 2002/03/02 21:39:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -140,8 +140,6 @@ Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
static Datum values[MAXATTR]; /* corresponding attribute values */
int numattr; /* number of attributes for cur. rel */
-int DebugMode;
-
static MemoryContext nogc = NULL; /* special no-gc mem context */
extern int optind;
@@ -188,8 +186,8 @@ usage(void)
{
fprintf(stderr,
gettext("Usage:\n"
- " postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n"
- " -d debug mode\n"
+ " postgres -boot [-d level] [-D datadir] [-F] [-o file] [-x num] dbname\n"
+ " -d 1-5 debug mode\n"
" -D datadir data directory\n"
" -F turn off fsync\n"
" -o file send debug output to file\n"
@@ -258,9 +256,17 @@ BootstrapMain(int argc, char *argv[])
potential_DataDir = optarg;
break;
case 'd':
- DebugMode = true; /* print out debugging info while
- * parsing */
+ {
+ /* Turn on debugging for the postmaster. */
+ char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
+ sprintf(debugstr, "debug%s", optarg);
+ /* We use PGC_S_SESSION because we will reset in backend */
+ SetConfigOption("server_min_messages", debugstr, PGC_POSTMASTER, PGC_S_ARGV);
+ SetConfigOption("client_min_messages", debugstr, PGC_POSTMASTER, PGC_S_ARGV);
+ pfree(debugstr);
break;
+ }
+ break;
case 'F':
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
break;
@@ -392,7 +398,7 @@ BootstrapMain(int argc, char *argv[])
proc_exit(0); /* done */
default:
- elog(STOP, "Unsupported XLOG op %d", xlogop);
+ elog(PANIC, "Unsupported XLOG op %d", xlogop);
proc_exit(0);
}
@@ -495,9 +501,8 @@ boot_openrel(char *relname)
if (reldesc != NULL)
closerel(NULL);
- if (DebugMode)
- elog(DEBUG, "open relation %s, attrsize %d", relname ? relname : "(null)",
- (int) ATTRIBUTE_TUPLE_SIZE);
+ elog(DEBUG3, "open relation %s, attrsize %d", relname ? relname : "(null)",
+ (int) ATTRIBUTE_TUPLE_SIZE);
reldesc = heap_openr(relname, NoLock);
numattr = reldesc->rd_rel->relnatts;
@@ -521,14 +526,12 @@ boot_openrel(char *relname)
else
attrtypes[i]->attisset = false;
- if (DebugMode)
{
Form_pg_attribute at = attrtypes[i];
- elog(DEBUG, "create attribute %d name %s len %d num %d type %u",
+ elog(DEBUG3, "create attribute %d name %s len %d num %d type %u",
i, NameStr(at->attname), at->attlen, at->attnum,
- at->atttypid
- );
+ at->atttypid);
}
}
}
@@ -558,8 +561,7 @@ closerel(char *name)
elog(ERROR, "no open relation to close");
else
{
- if (DebugMode)
- elog(DEBUG, "close relation %s", relname ? relname : "(null)");
+ elog(DEBUG3, "close relation %s", relname ? relname : "(null)");
heap_close(reldesc, NoLock);
reldesc = (Relation) NULL;
}
@@ -583,7 +585,7 @@ DefineAttr(char *name, char *type, int attnum)
if (reldesc != NULL)
{
- elog(DEBUG, "warning: no open relations allowed with 'create' command");
+ elog(LOG, "warning: no open relations allowed with 'create' command");
closerel(relname);
}
@@ -594,8 +596,7 @@ DefineAttr(char *name, char *type, int attnum)
{
attrtypes[attnum]->atttypid = Ap->am_oid;
namestrcpy(&attrtypes[attnum]->attname, name);
- if (DebugMode)
- elog(DEBUG, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
+ elog(DEBUG3, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
attlen = attrtypes[attnum]->attlen = Ap->am_typ.typlen;
attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
@@ -606,8 +607,7 @@ DefineAttr(char *name, char *type, int attnum)
{
attrtypes[attnum]->atttypid = Procid[typeoid].oid;
namestrcpy(&attrtypes[attnum]->attname, name);
- if (DebugMode)
- elog(DEBUG, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
+ elog(DEBUG3, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
attlen = attrtypes[attnum]->attlen = Procid[typeoid].len;
attrtypes[attnum]->attstorage = 'p';
@@ -655,8 +655,7 @@ InsertOneTuple(Oid objectid)
TupleDesc tupDesc;
int i;
- if (DebugMode)
- elog(DEBUG, "inserting row oid %u, %d columns", objectid, numattr);
+ elog(DEBUG3, "inserting row oid %u, %d columns", objectid, numattr);
tupDesc = CreateTupleDesc(numattr, attrtypes);
tuple = heap_formtuple(tupDesc, values, Blanks);
@@ -666,8 +665,7 @@ InsertOneTuple(Oid objectid)
tuple->t_data->t_oid = objectid;
heap_insert(reldesc, tuple);
heap_freetuple(tuple);
- if (DebugMode)
- elog(DEBUG, "row inserted");
+ elog(DEBUG3, "row inserted");
/*
* Reset blanks for next tuple
@@ -689,15 +687,13 @@ InsertOneValue(char *value, int i)
AssertArg(i >= 0 || i < MAXATTR);
- if (DebugMode)
- elog(DEBUG, "inserting column %d value '%s'", i, value);
+ elog(DEBUG3, "inserting column %d value '%s'", i, value);
if (Typ != (struct typmap **) NULL)
{
struct typmap *ap;
- if (DebugMode)
- elog(DEBUG, "Typ != NULL");
+ elog(DEBUG3, "Typ != NULL");
app = Typ;
while (*app && (*app)->am_oid != reldesc->rd_att->attrs[i]->atttypid)
++app;
@@ -715,8 +711,7 @@ InsertOneValue(char *value, int i)
values[i],
ObjectIdGetDatum(ap->am_typ.typelem),
Int32GetDatum(-1)));
- if (DebugMode)
- elog(DEBUG, " -> %s", prt);
+ elog(DEBUG3, " -> %s", prt);
pfree(prt);
}
else
@@ -728,8 +723,7 @@ InsertOneValue(char *value, int i)
}
if (typeindex >= n_types)
elog(ERROR, "type oid %u not found", attrtypes[i]->atttypid);
- if (DebugMode)
- elog(DEBUG, "Typ == NULL, typeindex = %u", typeindex);
+ elog(DEBUG3, "Typ == NULL, typeindex = %u", typeindex);
values[i] = OidFunctionCall3(Procid[typeindex].inproc,
CStringGetDatum(value),
ObjectIdGetDatum(Procid[typeindex].elem),
@@ -738,12 +732,10 @@ InsertOneValue(char *value, int i)
values[i],
ObjectIdGetDatum(Procid[typeindex].elem),
Int32GetDatum(-1)));
- if (DebugMode)
- elog(DEBUG, " -> %s", prt);
+ elog(DEBUG3, " -> %s", prt);
pfree(prt);
}
- if (DebugMode)
- elog(DEBUG, "inserted");
+ elog(DEBUG3, "inserted");
}
/* ----------------
@@ -753,8 +745,7 @@ InsertOneValue(char *value, int i)
void
InsertOneNull(int i)
{
- if (DebugMode)
- elog(DEBUG, "inserting column %d NULL", i);
+ elog(DEBUG3, "inserting column %d NULL", i);
Assert(i >= 0 || i < MAXATTR);
values[i] = PointerGetDatum(NULL);
Blanks[i] = 'n';
@@ -841,8 +832,7 @@ gettype(char *type)
if (strncmp(type, Procid[i].name, NAMEDATALEN) == 0)
return i;
}
- if (DebugMode)
- elog(DEBUG, "external type: %s", type);
+ elog(DEBUG3, "external type: %s", type);
rel = heap_openr(TypeRelationName, NoLock);
scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
i = 0;