2
/*-------------------------------------------------------------------------
5
* yacc parser grammar for the "backend" initialization program.
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
* Portions Copyright (c) 1994, Regents of the University of California
12
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.75 2004-12-31 21:59:34 pgsql Exp $
14
*-------------------------------------------------------------------------
21
#include "access/attnum.h"
22
#include "access/htup.h"
23
#include "access/itup.h"
24
#include "access/skey.h"
25
#include "access/tupdesc.h"
26
#include "access/xact.h"
27
#include "bootstrap/bootstrap.h"
28
#include "catalog/catalog.h"
29
#include "catalog/heap.h"
30
#include "catalog/pg_am.h"
31
#include "catalog/pg_attribute.h"
32
#include "catalog/pg_class.h"
33
#include "catalog/pg_namespace.h"
34
#include "catalog/pg_tablespace.h"
35
#include "commands/defrem.h"
36
#include "miscadmin.h"
37
#include "nodes/makefuncs.h"
38
#include "nodes/nodes.h"
39
#include "nodes/parsenodes.h"
40
#include "nodes/pg_list.h"
41
#include "nodes/primnodes.h"
42
#include "rewrite/prs2lock.h"
43
#include "storage/block.h"
44
#include "storage/fd.h"
45
#include "storage/ipc.h"
46
#include "storage/itemptr.h"
47
#include "storage/off.h"
48
#include "storage/smgr.h"
49
#include "tcop/dest.h"
50
#include "utils/nabstime.h"
51
#include "utils/rel.h"
57
StartTransactionCommand();
58
elog(DEBUG4, "start transaction");
65
CommitTransactionCommand();
66
elog(DEBUG4, "commit transaction");
67
CHECK_FOR_INTERRUPTS(); /* allow SIGINT to kill bootstrap run */
70
printf("bootstrap> ");
76
int num_columns_read = 0;
89
%type <list> boot_index_params
90
%type <ielem> boot_index_param
91
%type <ival> boot_const boot_ident
92
%type <ival> optbootstrap optsharedrelation optwithoutoids
93
%type <ival> boot_tuple boot_tuplelist
94
%type <oidval> optoideq
96
%token <ival> CONST_P ID
97
%token OPEN XCLOSE XCREATE INSERT_TUPLE
99
%token XDECLARE INDEX ON USING XBUILD INDICES UNIQUE
100
%token COMMA EQUALS LPAREN RPAREN
101
%token OBJ_ID XBOOTSTRAP XSHARED_RELATION XWITHOUT_OIDS NULLVAL
116
| Boot_Queries Boot_Query
124
| Boot_DeclareIndexStmt
125
| Boot_DeclareUniqueIndexStmt
133
boot_openrel(LexIDStr($2));
139
XCLOSE boot_ident %prec low
142
closerel(LexIDStr($2));
154
XCREATE optbootstrap optsharedrelation optwithoutoids boot_ident LPAREN
158
elog(DEBUG4, "creating%s%s relation %s",
159
$2 ? " bootstrap" : "",
173
tupdesc = CreateTupleDesc(numattr, !($4), attrtypes);
179
elog(DEBUG4, "create bootstrap: warning, open relation exists, closing first");
183
boot_reldesc = heap_create(LexIDStr($5),
184
PG_CATALOG_NAMESPACE,
185
$3 ? GLOBALTABLESPACE_OID : 0,
190
elog(DEBUG4, "bootstrap relation created");
196
id = heap_create_with_catalog(LexIDStr($5),
197
PG_CATALOG_NAMESPACE,
198
$3 ? GLOBALTABLESPACE_OID : 0,
206
elog(DEBUG4, "relation created with oid %u", id);
213
INSERT_TUPLE optoideq
217
elog(DEBUG4, "inserting row with oid %u", $2);
219
elog(DEBUG4, "inserting row");
220
num_columns_read = 0;
222
LPAREN boot_tuplelist RPAREN
224
if (num_columns_read != numattr)
225
elog(ERROR, "incorrect number of columns in row (expected %d, got %d)",
226
numattr, num_columns_read);
227
if (boot_reldesc == NULL)
229
elog(ERROR, "relation not open");
237
Boot_DeclareIndexStmt:
238
XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
242
DefineIndex(makeRangeVar(NULL, LexIDStr($5)),
249
false, false, true, false);
254
Boot_DeclareUniqueIndexStmt:
255
XDECLARE UNIQUE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
259
DefineIndex(makeRangeVar(NULL, LexIDStr($6)),
266
false, false, true, false);
282
boot_index_params COMMA boot_index_param { $$ = lappend($1, $3); }
283
| boot_index_param { $$ = list_make1($1); }
287
boot_ident boot_ident
289
IndexElem *n = makeNode(IndexElem);
290
n->name = LexIDStr($1);
292
n->opclass = list_make1(makeString(LexIDStr($2)));
298
XBOOTSTRAP { $$ = 1; }
303
XSHARED_RELATION { $$ = 1; }
308
XWITHOUT_OIDS { $$ = 1; }
314
| boot_typelist COMMA boot_type_thing
318
boot_ident EQUALS boot_ident
320
if (++numattr > MAXATTR)
321
elog(FATAL, "too many columns");
322
DefineAttr(LexIDStr($1),LexIDStr($3),numattr-1);
327
OBJ_ID EQUALS boot_ident { $$ = atol(LexIDStr($3)); }
333
| boot_tuplelist boot_tuple
334
| boot_tuplelist COMMA boot_tuple
339
{ InsertOneValue(LexIDStr($1), num_columns_read++); }
341
{ InsertOneValue(LexIDStr($1), num_columns_read++); }
343
{ InsertOneNull(num_columns_read++); }
347
CONST_P { $$=yylval.ival; }
351
ID { $$=yylval.ival; }
355
#include "bootscanner.c"