2 /*-------------------------------------------------------------------------
5 * yacc parser grammer for the "backend" initialization program.
7 * Copyright (c) 1994, Regents of the University of California
11 * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.24 1999/02/13 23:14:51 momjian Exp $
13 *-------------------------------------------------------------------------
21 #include "miscadmin.h"
23 #include "access/attnum.h"
24 #include "access/funcindex.h"
25 #include "access/htup.h"
26 #include "access/itup.h"
27 #include "access/skey.h"
28 #include "access/strat.h"
29 #include "access/tupdesc.h"
30 #include "access/xact.h"
31 #include "bootstrap/bootstrap.h"
32 #include "catalog/heap.h"
33 #include "catalog/pg_am.h"
34 #include "catalog/pg_attribute.h"
35 #include "catalog/pg_class.h"
36 #include "commands/defrem.h"
37 #include "nodes/nodes.h"
38 #include "nodes/parsenodes.h"
39 #include "nodes/pg_list.h"
40 #include "nodes/primnodes.h"
41 #include "rewrite/prs2lock.h"
42 #include "storage/block.h"
43 #include "storage/fd.h"
44 #include "storage/ipc.h"
45 #include "storage/itemptr.h"
46 #include "storage/off.h"
47 #include "storage/smgr.h"
48 #include "storage/spin.h"
49 #include "tcop/dest.h"
50 #include "utils/nabstime.h"
51 #include "utils/rel.h"
54 StartTransactionCommand();\
58 CommitTransactionCommand();\
59 if (!Quiet) { EMITPROMPT; }\
63 int num_tuples_read = 0;
76 %type <list> boot_index_params
77 %type <ielem> boot_index_param
78 %type <ival> boot_const boot_ident
79 %type <ival> optbootstrap optoideq boot_tuple boot_tuplelist
81 %token <ival> CONST ID
82 %token OPEN XCLOSE XCREATE INSERT_TUPLE
84 %token XDECLARE INDEX ON USING XBUILD INDICES
85 %token COMMA EQUALS LPAREN RPAREN
86 %token OBJ_ID XBOOTSTRAP NULLVAL
101 | Boot_Queries Boot_Query
109 | Boot_DeclareIndexStmt
117 boot_openrel(LexIDStr($2));
123 XCLOSE boot_ident %prec low
126 closerel(LexIDStr($2));
138 XCREATE optbootstrap boot_ident LPAREN
155 extern Relation reldesc;
160 puts("create bootstrap: Warning, open relation");
161 puts("exists, closing first");
165 puts("creating bootstrap relation");
166 tupdesc = CreateTupleDesc(numattr,attrtypes);
167 reldesc = heap_create(LexIDStr($3), tupdesc,
170 puts("bootstrap relation created ok");
177 tupdesc = CreateTupleDesc(numattr,attrtypes);
178 id = heap_create_with_catalog(LexIDStr($3),
179 tupdesc, RELKIND_RELATION, false);
181 printf("CREATED relation %s with OID %d\n",
191 INSERT_TUPLE optoideq
195 printf("tuple %d<", $2);
198 LPAREN boot_tuplelist RPAREN
200 if (num_tuples_read != numattr)
201 elog(ERROR,"incorrect number of values for tuple");
202 if (reldesc == (Relation)NULL)
204 elog(ERROR,"must OPEN RELATION before INSERT\n");
208 puts("Insert Begin");
210 InsertOneTuple(objectid);
217 puts("Transaction End");
221 Boot_DeclareIndexStmt:
222 XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
226 DefineIndex(LexIDStr($5),
229 $9, NIL, 0, 0, 0, NIL);
235 XBUILD INDICES { build_indices(); }
239 boot_index_params COMMA boot_index_param { $$ = lappend($1, $3); }
240 | boot_index_param { $$ = lcons($1, NIL); }
244 boot_ident boot_ident
246 IndexElem *n = makeNode(IndexElem);
247 n->name = LexIDStr($1);
248 n->class = LexIDStr($2);
253 XBOOTSTRAP { $$ = 1; }
259 | boot_typelist COMMA boot_type_thing
263 boot_ident EQUALS boot_ident
265 if(++numattr > MAXATTR)
266 elog(FATAL,"Too many attributes\n");
267 DefineAttr(LexIDStr($1),LexIDStr($3),numattr-1);
274 OBJ_ID EQUALS boot_ident { $$ = atol(LexIDStr($3)); }
275 | { extern Oid newoid(); $$ = newoid(); }
280 | boot_tuplelist boot_tuple
281 | boot_tuplelist COMMA boot_tuple
285 boot_ident {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); }
286 | boot_const {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); }
288 { InsertOneNull(num_tuples_read++); }
292 CONST { $$=yylval.ival; }
296 ID { $$=yylval.ival; }