blob: 6e17705fba7804bcf66b2e615089ca8adececb24 [file] [log] [blame]
drh348784e2000-05-29 20:41:49 +00001/*
2** Copyright (c) 1999, 2000 D. Richard Hipp
3**
4** This program is free software; you can redistribute it and/or
5** modify it under the terms of the GNU General Public
6** License as published by the Free Software Foundation; either
7** version 2 of the License, or (at your option) any later version.
8**
9** This program is distributed in the hope that it will be useful,
10** but WITHOUT ANY WARRANTY; without even the implied warranty of
11** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12** General Public License for more details.
13**
14** You should have received a copy of the GNU General Public
15** License along with this library; if not, write to the
16** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17** Boston, MA 02111-1307, USA.
18**
19** Author contact information:
20** drh@hwaci.com
21** http://www.hwaci.com/drh/
22**
23*************************************************************************
24** This file contains SQLite's grammar for SQL. Process this file
25** using the lemon parser generator to generate C code that runs
26** the parser. Lemon will also generate a header file containing
27** numeric codes for all of the tokens.
28**
drh31884b02000-06-09 14:14:32 +000029** @(#) $Id: parse.y,v 1.20 2000/06/09 14:14:33 drh Exp $
drh348784e2000-05-29 20:41:49 +000030*/
31%token_prefix TK_
32%token_type {Token}
33%extra_argument {Parse *pParse}
34%syntax_error {
drhc837e702000-06-08 16:26:24 +000035 sqliteSetString(&pParse->zErrMsg,"syntax error",0);
drh348784e2000-05-29 20:41:49 +000036 pParse->sErrToken = TOKEN;
37}
38%name sqliteParser
39%include {
40#include "sqliteInt.h"
41#include "parse.h"
42}
43
44
45// Input is zero or more commands.
46input ::= cmdlist.
47
48// These are extra tokens used by the lexer but never seen by the
49// parser. We put them in a rule so that the parser generator will
50// add them to the sqliteTokens.h output file.
51//
52input ::= END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
drh22827922000-06-06 17:27:05 +000053 UMINUS FIELD AGG_FUNCTION.
drh348784e2000-05-29 20:41:49 +000054
55// A list of commands is zero or more commands
56//
57cmdlist ::= ecmd.
58cmdlist ::= cmdlist SEMI ecmd.
59ecmd ::= explain cmd. {sqliteExec(pParse);}
60ecmd ::= cmd. {sqliteExec(pParse);}
61ecmd ::= .
62explain ::= EXPLAIN. {pParse->explain = 1;}
63
64// The first form of a command is a CREATE TABLE statement.
65//
66cmd ::= create_table create_table_args.
drh982cef72000-05-30 16:27:03 +000067create_table ::= CREATE(X) TABLE id(Y). {sqliteStartTable(pParse,&X,&Y);}
drh348784e2000-05-29 20:41:49 +000068create_table_args ::= LP columnlist conslist_opt RP(X).
69 {sqliteEndTable(pParse,&X);}
70columnlist ::= columnlist COMMA column.
71columnlist ::= column.
72
73// About the only information used for a column is the name of the
74// column. The type is always just "text". But the code will accept
75// an elaborate typename. Perhaps someday we'll do something with it.
76//
77column ::= columnid type carglist.
drh982cef72000-05-30 16:27:03 +000078columnid ::= id(X). {sqliteAddColumn(pParse,&X);}
79%type id {Token}
80id(A) ::= ID(X). {A = X;}
81id(A) ::= STRING(X). {A = X;}
drh348784e2000-05-29 20:41:49 +000082type ::= typename.
83type ::= typename LP signed RP.
84type ::= typename LP signed COMMA signed RP.
drh4cfa7932000-06-08 15:10:46 +000085typename ::= id.
86typename ::= typename id.
drh348784e2000-05-29 20:41:49 +000087signed ::= INTEGER.
88signed ::= PLUS INTEGER.
89signed ::= MINUS INTEGER.
90carglist ::= carglist carg.
91carglist ::= .
drh4cfa7932000-06-08 15:10:46 +000092carg ::= CONSTRAINT id ccons.
drh348784e2000-05-29 20:41:49 +000093carg ::= ccons.
drh7020f652000-06-03 18:06:52 +000094carg ::= DEFAULT STRING(X). {sqliteAddDefaultValue(pParse,&X,0);}
95carg ::= DEFAULT ID(X). {sqliteAddDefaultValue(pParse,&X,0);}
96carg ::= DEFAULT INTEGER(X). {sqliteAddDefaultValue(pParse,&X,0);}
97carg ::= DEFAULT PLUS INTEGER(X). {sqliteAddDefaultValue(pParse,&X,0);}
98carg ::= DEFAULT MINUS INTEGER(X). {sqliteAddDefaultValue(pParse,&X,1);}
99carg ::= DEFAULT FLOAT(X). {sqliteAddDefaultValue(pParse,&X,0);}
100carg ::= DEFAULT PLUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,0);}
101carg ::= DEFAULT MINUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,1);}
102carg ::= DEFAULT NULL.
drh348784e2000-05-29 20:41:49 +0000103
104// In addition to the type name, we also care about the primary key.
105//
106ccons ::= NOT NULL.
107ccons ::= PRIMARY KEY sortorder.
108 {sqliteCreateIndex(pParse,0,0,0,0,0);}
109ccons ::= UNIQUE.
drh4794b982000-06-06 13:54:14 +0000110ccons ::= CHECK LP expr RP.
drh348784e2000-05-29 20:41:49 +0000111
112// For the time being, the only constraint we care about is the primary
113// key.
114//
115conslist_opt ::= .
116conslist_opt ::= COMMA conslist.
117conslist ::= conslist COMMA tcons.
118conslist ::= tcons.
drh4cfa7932000-06-08 15:10:46 +0000119tcons ::= CONSTRAINT id tcons2.
drh348784e2000-05-29 20:41:49 +0000120tcons ::= tcons2.
121tcons2 ::= PRIMARY KEY LP idxlist(X) RP.
122 {sqliteCreateIndex(pParse,0,0,X,0,0);}
123tcons2 ::= UNIQUE LP idlist RP.
124tcons2 ::= CHECK expr.
drh982cef72000-05-30 16:27:03 +0000125idlist ::= idlist COMMA id.
126idlist ::= id.
drh348784e2000-05-29 20:41:49 +0000127
128// The next command format is dropping tables.
129//
drh982cef72000-05-30 16:27:03 +0000130cmd ::= DROP TABLE id(X). {sqliteDropTable(pParse,&X);}
drh348784e2000-05-29 20:41:49 +0000131
132// The select statement
133//
drh9bb61fe2000-06-05 16:01:39 +0000134cmd ::= select(X). {
drhfef52082000-06-06 01:50:43 +0000135 sqliteSelect(pParse, X, SRT_Callback, 0);
drh9bb61fe2000-06-05 16:01:39 +0000136 sqliteSelectDelete(X);
137}
drhefb72512000-05-31 20:00:52 +0000138
drh9bb61fe2000-06-05 16:01:39 +0000139%type select {Select*}
140%destructor select {sqliteSelectDelete($$);}
drh82c3d632000-06-06 21:56:07 +0000141%type oneselect {Select*}
142%destructor oneselect {sqliteSelectDelete($$);}
drh9bb61fe2000-06-05 16:01:39 +0000143
drh82c3d632000-06-06 21:56:07 +0000144select(A) ::= oneselect(X). {A = X;}
145select(A) ::= select(X) joinop(Y) oneselect(Z). {
146 Z->op = Y;
147 Z->pPrior = X;
148 A = Z;
149}
150%type joinop {int}
151joinop(A) ::= UNION. {A = TK_UNION;}
152joinop(A) ::= UNION ALL. {A = TK_ALL;}
153joinop(A) ::= INTERSECT. {A = TK_INTERSECT;}
154joinop(A) ::= EXCEPT. {A = TK_EXCEPT;}
155oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y)
156 groupby_opt(P) having_opt(Q) orderby_opt(Z). {
drh22827922000-06-06 17:27:05 +0000157 A = sqliteSelectNew(W,X,Y,P,Q,Z,D);
drh9bb61fe2000-06-05 16:01:39 +0000158}
159
160// The "distinct" nonterminal is true (1) if the DISTINCT keyword is
161// present and false (0) if it is not.
162//
drhefb72512000-05-31 20:00:52 +0000163%type distinct {int}
drhefb72512000-05-31 20:00:52 +0000164distinct(A) ::= DISTINCT. {A = 1;}
drhfef52082000-06-06 01:50:43 +0000165distinct(A) ::= ALL. {A = 0;}
drhefb72512000-05-31 20:00:52 +0000166distinct(A) ::= . {A = 0;}
drh348784e2000-05-29 20:41:49 +0000167
drh9bb61fe2000-06-05 16:01:39 +0000168// selcollist is a list of expressions that are to become the return
169// values of the SELECT statement. In the case of "SELECT * FROM ..."
170// the selcollist value is NULL.
171//
drh348784e2000-05-29 20:41:49 +0000172%type selcollist {ExprList*}
173%destructor selcollist {sqliteExprListDelete($$);}
174%type sclp {ExprList*}
175%destructor sclp {sqliteExprListDelete($$);}
drh348784e2000-05-29 20:41:49 +0000176sclp(A) ::= selcollist(X) COMMA. {A = X;}
177sclp(A) ::= . {A = 0;}
drh9bb61fe2000-06-05 16:01:39 +0000178selcollist(A) ::= STAR. {A = 0;}
drh348784e2000-05-29 20:41:49 +0000179selcollist(A) ::= sclp(P) expr(X). {A = sqliteExprListAppend(P,X,0);}
drh4cfa7932000-06-08 15:10:46 +0000180selcollist(A) ::= sclp(P) expr(X) as id(Y). {A = sqliteExprListAppend(P,X,&Y);}
drh9bb61fe2000-06-05 16:01:39 +0000181as ::= .
182as ::= AS.
183
drh348784e2000-05-29 20:41:49 +0000184
185%type seltablist {IdList*}
186%destructor seltablist {sqliteIdListDelete($$);}
187%type stl_prefix {IdList*}
188%destructor stl_prefix {sqliteIdListDelete($$);}
189%type from {IdList*}
190%destructor from {sqliteIdListDelete($$);}
191
192from(A) ::= FROM seltablist(X). {A = X;}
193stl_prefix(A) ::= seltablist(X) COMMA. {A = X;}
194stl_prefix(A) ::= . {A = 0;}
drh982cef72000-05-30 16:27:03 +0000195seltablist(A) ::= stl_prefix(X) id(Y). {A = sqliteIdListAppend(X,&Y);}
196seltablist(A) ::= stl_prefix(X) id(Y) AS id(Z).
drh348784e2000-05-29 20:41:49 +0000197 {A = sqliteIdListAppend(X,&Y);
198 sqliteIdListAddAlias(A,&Z);}
199
200%type orderby_opt {ExprList*}
201%destructor orderby_opt {sqliteExprListDelete($$);}
202%type sortlist {ExprList*}
203%destructor sortlist {sqliteExprListDelete($$);}
204%type sortitem {Expr*}
205%destructor sortitem {sqliteExprDelete($$);}
206
207orderby_opt(A) ::= . {A = 0;}
208orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
drh9bb61fe2000-06-05 16:01:39 +0000209sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). {
210 A = sqliteExprListAppend(X,Y,0);
drhd8bc7082000-06-07 23:51:50 +0000211 A->a[A->nExpr-1].sortOrder = Z; /* 0 for ascending order, 1 for decending */
drh9bb61fe2000-06-05 16:01:39 +0000212}
213sortlist(A) ::= sortitem(Y) sortorder(Z). {
214 A = sqliteExprListAppend(0,Y,0);
drhd8bc7082000-06-07 23:51:50 +0000215 A->a[0].sortOrder = Z;
drh9bb61fe2000-06-05 16:01:39 +0000216}
drhda9d6c42000-05-31 18:20:14 +0000217sortitem(A) ::= expr(X). {A = X;}
drh348784e2000-05-29 20:41:49 +0000218
219%type sortorder {int}
220
221sortorder(A) ::= ASC. {A = 0;}
222sortorder(A) ::= DESC. {A = 1;}
223sortorder(A) ::= . {A = 0;}
224
drh22827922000-06-06 17:27:05 +0000225%type groupby_opt {ExprList*}
226%destructor groupby_opt {sqliteExprListDelete($$);}
227groupby_opt(A) ::= . {A = 0;}
228groupby_opt(A) ::= GROUP BY exprlist(X). {A = X;}
229
230%type having_opt {Expr*}
231%destructor having_opt {sqliteExprDelete($$);}
232having_opt(A) ::= . {A = 0;}
233having_opt(A) ::= HAVING expr(X). {A = X;}
234
drh82c3d632000-06-06 21:56:07 +0000235
drh4cfa7932000-06-08 15:10:46 +0000236cmd ::= DELETE FROM id(X) where_opt(Y).
drh348784e2000-05-29 20:41:49 +0000237 {sqliteDeleteFrom(pParse, &X, Y);}
238
239%type where_opt {Expr*}
240%destructor where_opt {sqliteExprDelete($$);}
241
242where_opt(A) ::= . {A = 0;}
243where_opt(A) ::= WHERE expr(X). {A = X;}
244
245%type setlist {ExprList*}
246%destructor setlist {sqliteExprListDelete($$);}
247
drh4cfa7932000-06-08 15:10:46 +0000248cmd ::= UPDATE id(X) SET setlist(Y) where_opt(Z).
drh348784e2000-05-29 20:41:49 +0000249 {sqliteUpdate(pParse,&X,Y,Z);}
250
drh4cfa7932000-06-08 15:10:46 +0000251setlist(A) ::= id(X) EQ expr(Y) COMMA setlist(Z).
drh348784e2000-05-29 20:41:49 +0000252 {A = sqliteExprListAppend(Z,Y,&X);}
drh4cfa7932000-06-08 15:10:46 +0000253setlist(A) ::= id(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);}
drh348784e2000-05-29 20:41:49 +0000254
drh4cfa7932000-06-08 15:10:46 +0000255cmd ::= INSERT INTO id(X) fieldlist_opt(F) VALUES LP itemlist(Y) RP.
drh5974a302000-06-07 14:42:26 +0000256 {sqliteInsert(pParse, &X, Y, 0, F);}
drh4cfa7932000-06-08 15:10:46 +0000257cmd ::= INSERT INTO id(X) fieldlist_opt(F) select(S).
drh5974a302000-06-07 14:42:26 +0000258 {sqliteInsert(pParse, &X, 0, S, F);}
drh348784e2000-05-29 20:41:49 +0000259
260
261%type itemlist {ExprList*}
262%destructor itemlist {sqliteExprListDelete($$);}
263%type item {Expr*}
264%destructor item {sqliteExprDelete($$);}
265
266itemlist(A) ::= itemlist(X) COMMA item(Y). {A = sqliteExprListAppend(X,Y,0);}
267itemlist(A) ::= item(X). {A = sqliteExprListAppend(0,X,0);}
268item(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
drh7020f652000-06-03 18:06:52 +0000269item(A) ::= PLUS INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
270item(A) ::= MINUS INTEGER(X). {
drh6e142f52000-06-08 13:36:40 +0000271 A = sqliteExpr(TK_UMINUS, 0, 0, 0);
272 A->pLeft = sqliteExpr(TK_INTEGER, 0, 0, &X);
drh7020f652000-06-03 18:06:52 +0000273}
drh348784e2000-05-29 20:41:49 +0000274item(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
drh7020f652000-06-03 18:06:52 +0000275item(A) ::= PLUS FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
276item(A) ::= MINUS FLOAT(X). {
drh6e142f52000-06-08 13:36:40 +0000277 A = sqliteExpr(TK_UMINUS, 0, 0, 0);
278 A->pLeft = sqliteExpr(TK_FLOAT, 0, 0, &X);
drh7020f652000-06-03 18:06:52 +0000279}
drh348784e2000-05-29 20:41:49 +0000280item(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
drh8be51132000-06-03 19:19:41 +0000281item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
drh348784e2000-05-29 20:41:49 +0000282
283%type fieldlist_opt {IdList*}
284%destructor fieldlist_opt {sqliteIdListDelete($$);}
285%type fieldlist {IdList*}
286%destructor fieldlist {sqliteIdListDelete($$);}
287
288fieldlist_opt(A) ::= . {A = 0;}
289fieldlist_opt(A) ::= LP fieldlist(X) RP. {A = X;}
drh4cfa7932000-06-08 15:10:46 +0000290fieldlist(A) ::= fieldlist(X) COMMA id(Y). {A = sqliteIdListAppend(X,&Y);}
291fieldlist(A) ::= id(Y). {A = sqliteIdListAppend(0,&Y);}
drh348784e2000-05-29 20:41:49 +0000292
293%left OR.
294%left AND.
drh8be51132000-06-03 19:19:41 +0000295%right NOT.
drhfef52082000-06-06 01:50:43 +0000296%left EQ NE ISNULL NOTNULL IS LIKE GLOB BETWEEN IN.
drh348784e2000-05-29 20:41:49 +0000297%left GT GE LT LE.
298%left PLUS MINUS.
drh31884b02000-06-09 14:14:32 +0000299%left STAR SLASH.
drh8be51132000-06-03 19:19:41 +0000300%right UMINUS.
drh348784e2000-05-29 20:41:49 +0000301
302%type expr {Expr*}
303%destructor expr {sqliteExprDelete($$);}
304
305expr(A) ::= LP expr(X) RP. {A = X;}
306expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
307expr(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
drh4cfa7932000-06-08 15:10:46 +0000308expr(A) ::= id(X) DOT id(Y). {Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
drh348784e2000-05-29 20:41:49 +0000309 Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
310 A = sqliteExpr(TK_DOT, temp1, temp2, 0);}
311expr(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
312expr(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
313expr(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
drhcce7d172000-05-31 15:34:51 +0000314expr(A) ::= ID(X) LP exprlist(Y) RP. {A = sqliteExprFunction(Y, &X);}
315expr(A) ::= ID(X) LP STAR RP. {A = sqliteExprFunction(0, &X);}
drh348784e2000-05-29 20:41:49 +0000316expr(A) ::= expr(X) AND expr(Y). {A = sqliteExpr(TK_AND, X, Y, 0);}
317expr(A) ::= expr(X) OR expr(Y). {A = sqliteExpr(TK_OR, X, Y, 0);}
318expr(A) ::= expr(X) LT expr(Y). {A = sqliteExpr(TK_LT, X, Y, 0);}
319expr(A) ::= expr(X) GT expr(Y). {A = sqliteExpr(TK_GT, X, Y, 0);}
320expr(A) ::= expr(X) LE expr(Y). {A = sqliteExpr(TK_LE, X, Y, 0);}
321expr(A) ::= expr(X) GE expr(Y). {A = sqliteExpr(TK_GE, X, Y, 0);}
322expr(A) ::= expr(X) NE expr(Y). {A = sqliteExpr(TK_NE, X, Y, 0);}
323expr(A) ::= expr(X) EQ expr(Y). {A = sqliteExpr(TK_EQ, X, Y, 0);}
drhdce2cbe2000-05-31 02:27:49 +0000324expr(A) ::= expr(X) LIKE expr(Y). {A = sqliteExpr(TK_LIKE, X, Y, 0);}
drh4794b982000-06-06 13:54:14 +0000325expr(A) ::= expr(X) NOT LIKE expr(Y). {
326 A = sqliteExpr(TK_LIKE, X, Y, 0);
327 A = sqliteExpr(TK_NOT, A, 0, 0);
328}
drhfef52082000-06-06 01:50:43 +0000329expr(A) ::= expr(X) GLOB expr(Y). {A = sqliteExpr(TK_GLOB,X,Y,0);}
drh4794b982000-06-06 13:54:14 +0000330expr(A) ::= expr(X) NOT GLOB expr(Y). {
331 A = sqliteExpr(TK_GLOB, X, Y, 0);
332 A = sqliteExpr(TK_NOT, A, 0, 0);
333}
drh348784e2000-05-29 20:41:49 +0000334expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);}
335expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);}
336expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);}
337expr(A) ::= expr(X) SLASH expr(Y). {A = sqliteExpr(TK_SLASH, X, Y, 0);}
338expr(A) ::= expr(X) ISNULL. {A = sqliteExpr(TK_ISNULL, X, 0, 0);}
339expr(A) ::= expr(X) NOTNULL. {A = sqliteExpr(TK_NOTNULL, X, 0, 0);}
340expr(A) ::= NOT expr(X). {A = sqliteExpr(TK_NOT, X, 0, 0);}
drh8be51132000-06-03 19:19:41 +0000341expr(A) ::= MINUS expr(X). [UMINUS] {A = sqliteExpr(TK_UMINUS, X, 0, 0);}
342expr(A) ::= PLUS expr(X). [UMINUS] {A = X;}
drh19a775c2000-06-05 18:54:46 +0000343expr(A) ::= LP select(X) RP. {
344 A = sqliteExpr(TK_SELECT, 0, 0, 0);
345 A->pSelect = X;
346}
drhfef52082000-06-06 01:50:43 +0000347expr(A) ::= expr(W) BETWEEN expr(X) AND expr(Y). {
348 ExprList *pList = sqliteExprListAppend(0, X, 0);
349 pList = sqliteExprListAppend(pList, Y, 0);
350 A = sqliteExpr(TK_BETWEEN, W, 0, 0);
351 A->pList = pList;
352}
drh4794b982000-06-06 13:54:14 +0000353expr(A) ::= expr(W) NOT BETWEEN expr(X) AND expr(Y). {
354 ExprList *pList = sqliteExprListAppend(0, X, 0);
355 pList = sqliteExprListAppend(pList, Y, 0);
356 A = sqliteExpr(TK_BETWEEN, W, 0, 0);
357 A->pList = pList;
358 A = sqliteExpr(TK_NOT, A, 0, 0);
359}
drhfef52082000-06-06 01:50:43 +0000360expr(A) ::= expr(X) IN LP exprlist(Y) RP. {
361 A = sqliteExpr(TK_IN, X, 0, 0);
362 A->pList = Y;
363}
364expr(A) ::= expr(X) IN LP select(Y) RP. {
365 A = sqliteExpr(TK_IN, X, 0, 0);
366 A->pSelect = Y;
367}
drh4794b982000-06-06 13:54:14 +0000368expr(A) ::= expr(X) NOT IN LP exprlist(Y) RP. {
369 A = sqliteExpr(TK_IN, X, 0, 0);
370 A->pList = Y;
371 A = sqliteExpr(TK_NOT, A, 0, 0);
372}
373expr(A) ::= expr(X) NOT IN LP select(Y) RP. {
374 A = sqliteExpr(TK_IN, X, 0, 0);
375 A->pSelect = Y;
376 A = sqliteExpr(TK_NOT, A, 0, 0);
377}
drhfef52082000-06-06 01:50:43 +0000378
379
drh348784e2000-05-29 20:41:49 +0000380
381%type exprlist {ExprList*}
382%destructor exprlist {sqliteExprListDelete($$);}
383%type expritem {Expr*}
384%destructor expritem {sqliteExprDelete($$);}
385
drh348784e2000-05-29 20:41:49 +0000386exprlist(A) ::= exprlist(X) COMMA expritem(Y).
387 {A = sqliteExprListAppend(X,Y,0);}
388exprlist(A) ::= expritem(X). {A = sqliteExprListAppend(0,X,0);}
389expritem(A) ::= expr(X). {A = X;}
390expritem(A) ::= . {A = 0;}
drhcce7d172000-05-31 15:34:51 +0000391
drh348784e2000-05-29 20:41:49 +0000392
drh4cfa7932000-06-08 15:10:46 +0000393cmd ::= CREATE(S) uniqueflag INDEX id(X) ON id(Y) LP idxlist(Z) RP(E).
drh348784e2000-05-29 20:41:49 +0000394 {sqliteCreateIndex(pParse, &X, &Y, Z, &S, &E);}
395uniqueflag ::= UNIQUE.
396uniqueflag ::= .
397
398%type idxlist {IdList*}
399%destructor idxlist {sqliteIdListDelete($$);}
400%type idxitem {Token}
401
402idxlist(A) ::= idxlist(X) COMMA idxitem(Y).
403 {A = sqliteIdListAppend(X,&Y);}
404idxlist(A) ::= idxitem(Y).
405 {A = sqliteIdListAppend(0,&Y);}
drh4cfa7932000-06-08 15:10:46 +0000406idxitem(A) ::= id(X). {A = X;}
drh348784e2000-05-29 20:41:49 +0000407
drh982cef72000-05-30 16:27:03 +0000408cmd ::= DROP INDEX id(X). {sqliteDropIndex(pParse, &X);}
409
410cmd ::= COPY id(X) FROM id(Y) USING DELIMITERS STRING(Z).
411 {sqliteCopy(pParse,&X,&Y,&Z);}
412cmd ::= COPY id(X) FROM id(Y).
413 {sqliteCopy(pParse,&X,&Y,0);}
drhdce2cbe2000-05-31 02:27:49 +0000414
415cmd ::= VACUUM. {sqliteVacuum(pParse,0);}
416cmd ::= VACUUM id(X). {sqliteVacuum(pParse,&X);}