diff options
Diffstat (limited to 'src/backend/bootstrap')
-rw-r--r-- | src/backend/bootstrap/bootparse.y | 52 | ||||
-rw-r--r-- | src/backend/bootstrap/bootscanner.l | 5 | ||||
-rw-r--r-- | src/backend/bootstrap/bootstrap.c | 40 |
3 files changed, 54 insertions, 43 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y index e98eae3a423..e6250d0c501 100644 --- a/src/backend/bootstrap/bootparse.y +++ b/src/backend/bootstrap/bootparse.y @@ -1,15 +1,15 @@ %{ /*------------------------------------------------------------------------- * - * backendparse.y - * yacc parser grammer for the "backend" initialization program. + * bootparse.y + * yacc parser grammar for the "backend" initialization program. * * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.45 2002/04/17 20:57:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.46 2002/04/27 21:24:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -88,8 +88,9 @@ int num_columns_read = 0; %type <list> boot_index_params %type <ielem> boot_index_param -%type <ival> boot_const boot_ident -%type <ival> optbootstrap optwithoutoids boot_tuple boot_tuplelist +%type <ival> boot_const boot_ident +%type <ival> optbootstrap optsharedrelation optwithoutoids +%type <ival> boot_tuple boot_tuplelist %type <oidval> optoideq %token <ival> CONST ID @@ -97,7 +98,7 @@ int num_columns_read = 0; %token STRING XDEFINE %token XDECLARE INDEX ON USING XBUILD INDICES UNIQUE %token COMMA EQUALS LPAREN RPAREN -%token OBJ_ID XBOOTSTRAP XWITHOUT_OIDS NULLVAL +%token OBJ_ID XBOOTSTRAP XSHARED_RELATION XWITHOUT_OIDS NULLVAL %start TopLevel %nonassoc low @@ -150,16 +151,14 @@ Boot_CloseStmt: ; Boot_CreateStmt: - XCREATE optbootstrap optwithoutoids boot_ident LPAREN + XCREATE optbootstrap optsharedrelation optwithoutoids boot_ident LPAREN { do_start(); numattr = 0; - if ($2) - elog(DEBUG3, "creating bootstrap relation %s...", - LexIDStr($4)); - else - elog(DEBUG3, "creating relation %s...", - LexIDStr($4)); + elog(DEBUG3, "creating%s%s relation %s...", + $2 ? " bootstrap" : "", + $3 ? " shared" : "", + LexIDStr($5)); } boot_typelist { @@ -171,21 +170,22 @@ Boot_CreateStmt: if ($2) { - extern Relation reldesc; TupleDesc tupdesc; - if (reldesc) + if (boot_reldesc) { elog(DEBUG3, "create bootstrap: warning, open relation exists, closing first"); closerel(NULL); } tupdesc = CreateTupleDesc(numattr, attrtypes); - reldesc = heap_create(LexIDStr($4), - PG_CATALOG_NAMESPACE, - tupdesc, - true, true); - reldesc->rd_rel->relhasoids = ! ($3); + boot_reldesc = heap_create(LexIDStr($5), + PG_CATALOG_NAMESPACE, + tupdesc, + $3, + true, + true); + boot_reldesc->rd_rel->relhasoids = ! ($4); elog(DEBUG3, "bootstrap relation created"); } else @@ -194,11 +194,12 @@ Boot_CreateStmt: TupleDesc tupdesc; tupdesc = CreateTupleDesc(numattr,attrtypes); - id = heap_create_with_catalog(LexIDStr($4), + id = heap_create_with_catalog(LexIDStr($5), PG_CATALOG_NAMESPACE, tupdesc, RELKIND_RELATION, - ! ($3), + $3, + ! ($4), true); elog(DEBUG3, "relation created with oid %u", id); } @@ -221,7 +222,7 @@ Boot_InsertStmt: if (num_columns_read != numattr) elog(ERROR, "incorrect number of columns in row (expected %d, got %d)", numattr, num_columns_read); - if (reldesc == (Relation)NULL) + if (boot_reldesc == (Relation) NULL) { elog(ERROR, "relation not open"); err_out(); @@ -283,6 +284,11 @@ optbootstrap: | { $$ = 0; } ; +optsharedrelation: + XSHARED_RELATION { $$ = 1; } + | { $$ = 0; } + ; + optwithoutoids: XWITHOUT_OIDS { $$ = 1; } | { $$ = 0; } diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l index 47f0c8c1313..b471dcc66e9 100644 --- a/src/backend/bootstrap/bootscanner.l +++ b/src/backend/bootstrap/bootscanner.l @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.21 2001/08/10 18:57:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.22 2002/04/27 21:24:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -71,6 +71,8 @@ create { return(XCREATE); } OID { return(OBJ_ID); } bootstrap { return(XBOOTSTRAP); } +"shared_relation" { return(XSHARED_RELATION); } +"without_oids" { return(XWITHOUT_OIDS); } _null_ { return(NULLVAL); } insert { return(INSERT_TUPLE); } @@ -94,7 +96,6 @@ insert { return(INSERT_TUPLE); } "index" { return(INDEX); } "on" { return(ON); } "using" { return(USING); } -"without_oids" { return(XWITHOUT_OIDS); } {arrayid} { yylval.ival = EnterString(MapArrayTypeName((char*)yytext)); diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 07d013232c7..6028b2db484 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.126 2002/04/25 02:56:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.127 2002/04/27 21:24:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -59,6 +59,9 @@ static void cleanup(void); * global variables * ---------------- */ + +Relation boot_reldesc; /* current relation descriptor */ + /* * In the lexical analyzer, we need to get the reference number quickly from * the string, and the string from the reference number. Thus we have @@ -500,20 +503,20 @@ boot_openrel(char *relname) heap_close(rel, NoLock); } - if (reldesc != NULL) + if (boot_reldesc != NULL) closerel(NULL); elog(DEBUG3, "open relation %s, attrsize %d", relname ? relname : "(null)", (int) ATTRIBUTE_TUPLE_SIZE); - reldesc = heap_openr(relname, NoLock); - numattr = reldesc->rd_rel->relnatts; + boot_reldesc = heap_openr(relname, NoLock); + numattr = boot_reldesc->rd_rel->relnatts; for (i = 0; i < numattr; i++) { if (attrtypes[i] == NULL) attrtypes[i] = AllocateAttribute(); memmove((char *) attrtypes[i], - (char *) reldesc->rd_att->attrs[i], + (char *) boot_reldesc->rd_att->attrs[i], ATTRIBUTE_TUPLE_SIZE); /* Some old pg_attribute tuples might not have attisset. */ @@ -523,8 +526,9 @@ boot_openrel(char *relname) * defined yet. */ if (namestrcmp(&attrtypes[i]->attname, "attisset") == 0) - attrtypes[i]->attisset = get_attisset(RelationGetRelid(reldesc), - NameStr(attrtypes[i]->attname)); + attrtypes[i]->attisset = + get_attisset(RelationGetRelid(boot_reldesc), + NameStr(attrtypes[i]->attname)); else attrtypes[i]->attisset = false; @@ -547,9 +551,9 @@ closerel(char *name) { if (name) { - if (reldesc) + if (boot_reldesc) { - if (strcmp(RelationGetRelationName(reldesc), name) != 0) + if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0) elog(ERROR, "closerel: close of '%s' when '%s' was expected", name, relname ? relname : "(null)"); } @@ -559,13 +563,13 @@ closerel(char *name) } - if (reldesc == NULL) + if (boot_reldesc == NULL) elog(ERROR, "no open relation to close"); else { elog(DEBUG3, "close relation %s", relname ? relname : "(null)"); - heap_close(reldesc, NoLock); - reldesc = (Relation) NULL; + heap_close(boot_reldesc, NoLock); + boot_reldesc = (Relation) NULL; } } @@ -585,7 +589,7 @@ DefineAttr(char *name, char *type, int attnum) int attlen; Oid typeoid; - if (reldesc != NULL) + if (boot_reldesc != NULL) { elog(LOG, "warning: no open relations allowed with 'create' command"); closerel(relname); @@ -674,7 +678,7 @@ InsertOneTuple(Oid objectid) if (objectid != (Oid) 0) tuple->t_data->t_oid = objectid; - heap_insert(reldesc, tuple); + heap_insert(boot_reldesc, tuple); heap_freetuple(tuple); elog(DEBUG3, "row inserted"); @@ -706,13 +710,13 @@ InsertOneValue(char *value, int i) elog(DEBUG3, "Typ != NULL"); app = Typ; - while (*app && (*app)->am_oid != reldesc->rd_att->attrs[i]->atttypid) + while (*app && (*app)->am_oid != boot_reldesc->rd_att->attrs[i]->atttypid) ++app; ap = *app; if (ap == NULL) { elog(FATAL, "unable to find atttypid %u in Typ list", - reldesc->rd_att->attrs[i]->atttypid); + boot_reldesc->rd_att->attrs[i]->atttypid); } values[i] = OidFunctionCall3(ap->am_typ.typinput, CStringGetDatum(value), @@ -806,8 +810,8 @@ cleanup() elog(FATAL, "Memory manager fault: cleanup called twice.\n"); proc_exit(1); } - if (reldesc != (Relation) NULL) - heap_close(reldesc, NoLock); + if (boot_reldesc != (Relation) NULL) + heap_close(boot_reldesc, NoLock); CommitTransactionCommand(); proc_exit(Warnings); } |