Force a checkpoint in CREATE DATABASE before starting to copy the files,
[PostgreSQL.git] / src / backend / bootstrap / bootscanner.l
blob43a400f722cf24237e57f7cc2b2e5f5b5574a622
1 %{
2 /*-------------------------------------------------------------------------
3  *
4  * bootscanner.l
5  *        a lexical scanner for the bootstrap parser
6  *
7  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  *
11  * IDENTIFICATION
12  *        $PostgreSQL$
13  *
14  *-------------------------------------------------------------------------
15  */
16 #include "postgres.h"
18 #include "access/attnum.h"
19 #include "access/htup.h"
20 #include "access/itup.h"
21 #include "access/skey.h"
22 #include "access/tupdesc.h"
23 #include "bootstrap/bootstrap.h"
24 #include "catalog/pg_am.h"
25 #include "catalog/pg_attribute.h"
26 #include "catalog/pg_class.h"
27 #include "nodes/nodes.h"
28 #include "nodes/parsenodes.h"
29 #include "nodes/pg_list.h"
30 #include "nodes/primnodes.h"
31 #include "parser/scansup.h"
32 #include "rewrite/prs2lock.h"
33 #include "storage/block.h"
34 #include "storage/fd.h"
35 #include "storage/itemptr.h"
36 #include "storage/off.h"
37 #include "utils/rel.h"
39 /* Not needed now that this file is compiled as part of bootparse. */
40 /* #include "bootparse.h" */
43 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
44 #undef fprintf
45 #define fprintf(file, fmt, msg)  ereport(ERROR, (errmsg_internal("%s", msg)))
48 static int      yyline = 1;                     /* line number for error reporting */
52 %option 8bit
53 %option never-interactive
54 %option nodefault
55 %option noinput
56 %option nounput
57 %option noyywrap
58 %option prefix="boot_yy"
61 D               [0-9]
62 oct             \\{D}{D}{D}
63 Exp             [Ee][-+]?{D}+
64 id              ([A-Za-z0-9_]|{oct}|\-)+
65 sid             \"([^\"])*\"
66 arrayid [A-Za-z0-9_]+\[{D}*\]
70 open                    { return(OPEN); }
72 close                   { return(XCLOSE); }
74 create                  { return(XCREATE); }
76 OID                             { return(OBJ_ID); }
77 bootstrap               { return(XBOOTSTRAP); }
78 "shared_relation"       { return(XSHARED_RELATION); }
79 "without_oids"  { return(XWITHOUT_OIDS); }
80 _null_                  { return(NULLVAL); }
82 insert                  { return(INSERT_TUPLE); }
84 ","                             { return(COMMA); }
85 "="                             { return(EQUALS); }
86 "("                             { return(LPAREN); }
87 ")"                             { return(RPAREN); }
89 [\n]                    { yyline++; }
90 [\t]                    ;
91 " "                             ;
93 ^\#[^\n]* ; /* drop everything after "#" for comments */
96 "declare"               { return(XDECLARE); }
97 "build"                 { return(XBUILD); }
98 "indices"               { return(INDICES); }
99 "unique"                { return(UNIQUE); }
100 "index"                 { return(INDEX); }
101 "on"                    { return(ON); }
102 "using"                 { return(USING); }
103 "toast"                 { return(XTOAST); }
105 {arrayid}               {
106                                         yylval.ival = EnterString(MapArrayTypeName((char*)yytext));
107                                         return(ID);
108                                 }
109 {id}                    {
110                                         char   *newid = scanstr((char*)yytext);
111                                         yylval.ival = EnterString(newid);
112                                         pfree(newid);
113                                         return(ID);
114                                 }
115 {sid}                   {
116                                         char   *newid;
117                                         yytext[strlen(yytext)-1] = '\0'; /* strip off quotes */
118                                         newid = scanstr((char*)yytext+1);
119                                         yylval.ival = EnterString(newid);
120                                         pfree(newid);
121                                         yytext[strlen(yytext)] = '"'; /* restore quotes */
122                                         return(ID);
123                                 }
125 (-)?{D}+"."{D}*({Exp})? |
126 (-)?{D}*"."{D}+({Exp})? |
127 (-)?{D}+{Exp}                   {
128                                                         yylval.ival = EnterString((char*)yytext);
129                                                         return(CONST_P);
130                                                 }
132 .                               {
133                                         elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
134                                 }
140 void
141 yyerror(const char *message)
143         elog(ERROR, "%s at line %d", message, yyline);