Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/src/parse.y

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2001 September 15 2 ** 2001 September 15
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ** automaton. 54 ** automaton.
55 */ 55 */
56 #define YYNOERRORRECOVERY 1 56 #define YYNOERRORRECOVERY 1
57 57
58 /* 58 /*
59 ** Make yytestcase() the same as testcase() 59 ** Make yytestcase() the same as testcase()
60 */ 60 */
61 #define yytestcase(X) testcase(X) 61 #define yytestcase(X) testcase(X)
62 62
63 /* 63 /*
64 ** Indicate that sqlite3ParserFree() will never be called with a null
65 ** pointer.
66 */
67 #define YYPARSEFREENEVERNULL 1
68
69 /*
70 ** Alternative datatype for the argument to the malloc() routine passed
71 ** into sqlite3ParserAlloc(). The default is size_t.
72 */
73 #define YYMALLOCARGTYPE u64
74
75 /*
64 ** An instance of this structure holds information about the 76 ** An instance of this structure holds information about the
65 ** LIMIT clause of a SELECT statement. 77 ** LIMIT clause of a SELECT statement.
66 */ 78 */
67 struct LimitVal { 79 struct LimitVal {
68 Expr *pLimit; /* The LIMIT expression. NULL if there is no limit */ 80 Expr *pLimit; /* The LIMIT expression. NULL if there is no limit */
69 Expr *pOffset; /* The OFFSET expression. NULL if there is none */ 81 Expr *pOffset; /* The OFFSET expression. NULL if there is none */
70 }; 82 };
71 83
72 /* 84 /*
73 ** An instance of this structure is used to store the LIKE, 85 ** An instance of this structure is used to store the LIKE,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 temp(A) ::= TEMP. {A = 1;} 167 temp(A) ::= TEMP. {A = 1;}
156 %endif SQLITE_OMIT_TEMPDB 168 %endif SQLITE_OMIT_TEMPDB
157 temp(A) ::= . {A = 0;} 169 temp(A) ::= . {A = 0;}
158 create_table_args ::= LP columnlist conslist_opt(X) RP(E) table_options(F). { 170 create_table_args ::= LP columnlist conslist_opt(X) RP(E) table_options(F). {
159 sqlite3EndTable(pParse,&X,&E,F,0); 171 sqlite3EndTable(pParse,&X,&E,F,0);
160 } 172 }
161 create_table_args ::= AS select(S). { 173 create_table_args ::= AS select(S). {
162 sqlite3EndTable(pParse,0,0,0,S); 174 sqlite3EndTable(pParse,0,0,0,S);
163 sqlite3SelectDelete(pParse->db, S); 175 sqlite3SelectDelete(pParse->db, S);
164 } 176 }
165 %type table_options {u8} 177 %type table_options {int}
166 table_options(A) ::= . {A = 0;} 178 table_options(A) ::= . {A = 0;}
167 table_options(A) ::= WITHOUT nm(X). { 179 table_options(A) ::= WITHOUT nm(X). {
168 if( X.n==5 && sqlite3_strnicmp(X.z,"rowid",5)==0 ){ 180 if( X.n==5 && sqlite3_strnicmp(X.z,"rowid",5)==0 ){
169 A = TF_WithoutRowid; 181 A = TF_WithoutRowid | TF_NoVisibleRowid;
170 }else{ 182 }else{
171 A = 0; 183 A = 0;
172 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", X.n, X.z); 184 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", X.n, X.z);
173 } 185 }
174 } 186 }
175 columnlist ::= columnlist COMMA column. 187 columnlist ::= columnlist COMMA column.
176 columnlist ::= column. 188 columnlist ::= column.
177 189
178 // A "column" is a complete description of a single column in a 190 // A "column" is a complete description of a single column in a
179 // CREATE TABLE statement. This includes the column name, its 191 // CREATE TABLE statement. This includes the column name, its
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 306
295 // In addition to the type name, we also care about the primary key and 307 // In addition to the type name, we also care about the primary key and
296 // UNIQUE constraints. 308 // UNIQUE constraints.
297 // 309 //
298 ccons ::= NULL onconf. 310 ccons ::= NULL onconf.
299 ccons ::= NOT NULL onconf(R). {sqlite3AddNotNull(pParse, R);} 311 ccons ::= NOT NULL onconf(R). {sqlite3AddNotNull(pParse, R);}
300 ccons ::= PRIMARY KEY sortorder(Z) onconf(R) autoinc(I). 312 ccons ::= PRIMARY KEY sortorder(Z) onconf(R) autoinc(I).
301 {sqlite3AddPrimaryKey(pParse,0,R,I,Z);} 313 {sqlite3AddPrimaryKey(pParse,0,R,I,Z);}
302 ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0);} 314 ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0);}
303 ccons ::= CHECK LP expr(X) RP. {sqlite3AddCheckConstraint(pParse,X.pExpr);} 315 ccons ::= CHECK LP expr(X) RP. {sqlite3AddCheckConstraint(pParse,X.pExpr);}
304 ccons ::= REFERENCES nm(T) idxlist_opt(TA) refargs(R). 316 ccons ::= REFERENCES nm(T) eidlist_opt(TA) refargs(R).
305 {sqlite3CreateForeignKey(pParse,0,&T,TA,R);} 317 {sqlite3CreateForeignKey(pParse,0,&T,TA,R);}
306 ccons ::= defer_subclause(D). {sqlite3DeferForeignKey(pParse,D);} 318 ccons ::= defer_subclause(D). {sqlite3DeferForeignKey(pParse,D);}
307 ccons ::= COLLATE ids(C). {sqlite3AddCollateType(pParse, &C);} 319 ccons ::= COLLATE ids(C). {sqlite3AddCollateType(pParse, &C);}
308 320
309 // The optional AUTOINCREMENT keyword 321 // The optional AUTOINCREMENT keyword
310 %type autoinc {int} 322 %type autoinc {int}
311 autoinc(X) ::= . {X = 0;} 323 autoinc(X) ::= . {X = 0;}
312 autoinc(X) ::= AUTOINCR. {X = 1;} 324 autoinc(X) ::= AUTOINCR. {X = 1;}
313 325
314 // The next group of rules parses the arguments to a REFERENCES clause 326 // The next group of rules parses the arguments to a REFERENCES clause
(...skipping 23 matching lines...) Expand all
338 init_deferred_pred_opt(A) ::= INITIALLY DEFERRED. {A = 1;} 350 init_deferred_pred_opt(A) ::= INITIALLY DEFERRED. {A = 1;}
339 init_deferred_pred_opt(A) ::= INITIALLY IMMEDIATE. {A = 0;} 351 init_deferred_pred_opt(A) ::= INITIALLY IMMEDIATE. {A = 0;}
340 352
341 conslist_opt(A) ::= . {A.n = 0; A.z = 0;} 353 conslist_opt(A) ::= . {A.n = 0; A.z = 0;}
342 conslist_opt(A) ::= COMMA(X) conslist. {A = X;} 354 conslist_opt(A) ::= COMMA(X) conslist. {A = X;}
343 conslist ::= conslist tconscomma tcons. 355 conslist ::= conslist tconscomma tcons.
344 conslist ::= tcons. 356 conslist ::= tcons.
345 tconscomma ::= COMMA. {pParse->constraintName.n = 0;} 357 tconscomma ::= COMMA. {pParse->constraintName.n = 0;}
346 tconscomma ::= . 358 tconscomma ::= .
347 tcons ::= CONSTRAINT nm(X). {pParse->constraintName = X;} 359 tcons ::= CONSTRAINT nm(X). {pParse->constraintName = X;}
348 tcons ::= PRIMARY KEY LP idxlist(X) autoinc(I) RP onconf(R). 360 tcons ::= PRIMARY KEY LP sortlist(X) autoinc(I) RP onconf(R).
349 {sqlite3AddPrimaryKey(pParse,X,R,I,0);} 361 {sqlite3AddPrimaryKey(pParse,X,R,I,0);}
350 tcons ::= UNIQUE LP idxlist(X) RP onconf(R). 362 tcons ::= UNIQUE LP sortlist(X) RP onconf(R).
351 {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0);} 363 {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0);}
352 tcons ::= CHECK LP expr(E) RP onconf. 364 tcons ::= CHECK LP expr(E) RP onconf.
353 {sqlite3AddCheckConstraint(pParse,E.pExpr);} 365 {sqlite3AddCheckConstraint(pParse,E.pExpr);}
354 tcons ::= FOREIGN KEY LP idxlist(FA) RP 366 tcons ::= FOREIGN KEY LP eidlist(FA) RP
355 REFERENCES nm(T) idxlist_opt(TA) refargs(R) defer_subclause_opt(D). { 367 REFERENCES nm(T) eidlist_opt(TA) refargs(R) defer_subclause_opt(D). {
356 sqlite3CreateForeignKey(pParse, FA, &T, TA, R); 368 sqlite3CreateForeignKey(pParse, FA, &T, TA, R);
357 sqlite3DeferForeignKey(pParse, D); 369 sqlite3DeferForeignKey(pParse, D);
358 } 370 }
359 %type defer_subclause_opt {int} 371 %type defer_subclause_opt {int}
360 defer_subclause_opt(A) ::= . {A = 0;} 372 defer_subclause_opt(A) ::= . {A = 0;}
361 defer_subclause_opt(A) ::= defer_subclause(X). {A = X;} 373 defer_subclause_opt(A) ::= defer_subclause(X). {A = X;}
362 374
363 // The following is a non-standard extension that allows us to declare the 375 // The following is a non-standard extension that allows us to declare the
364 // default behavior when there is a constraint conflict. 376 // default behavior when there is a constraint conflict.
365 // 377 //
366 %type onconf {int} 378 %type onconf {int}
367 %type orconf {u8} 379 %type orconf {int}
368 %type resolvetype {int} 380 %type resolvetype {int}
369 onconf(A) ::= . {A = OE_Default;} 381 onconf(A) ::= . {A = OE_Default;}
370 onconf(A) ::= ON CONFLICT resolvetype(X). {A = X;} 382 onconf(A) ::= ON CONFLICT resolvetype(X). {A = X;}
371 orconf(A) ::= . {A = OE_Default;} 383 orconf(A) ::= . {A = OE_Default;}
372 orconf(A) ::= OR resolvetype(X). {A = (u8)X;} 384 orconf(A) ::= OR resolvetype(X). {A = X;}
373 resolvetype(A) ::= raisetype(X). {A = X;} 385 resolvetype(A) ::= raisetype(X). {A = X;}
374 resolvetype(A) ::= IGNORE. {A = OE_Ignore;} 386 resolvetype(A) ::= IGNORE. {A = OE_Ignore;}
375 resolvetype(A) ::= REPLACE. {A = OE_Replace;} 387 resolvetype(A) ::= REPLACE. {A = OE_Replace;}
376 388
377 ////////////////////////// The DROP TABLE ///////////////////////////////////// 389 ////////////////////////// The DROP TABLE /////////////////////////////////////
378 // 390 //
379 cmd ::= DROP TABLE ifexists(E) fullname(X). { 391 cmd ::= DROP TABLE ifexists(E) fullname(X). {
380 sqlite3DropTable(pParse, X, 0, E); 392 sqlite3DropTable(pParse, X, 0, E);
381 } 393 }
382 %type ifexists {int} 394 %type ifexists {int}
383 ifexists(A) ::= IF EXISTS. {A = 1;} 395 ifexists(A) ::= IF EXISTS. {A = 1;}
384 ifexists(A) ::= . {A = 0;} 396 ifexists(A) ::= . {A = 0;}
385 397
386 ///////////////////// The CREATE VIEW statement ///////////////////////////// 398 ///////////////////// The CREATE VIEW statement /////////////////////////////
387 // 399 //
388 %ifndef SQLITE_OMIT_VIEW 400 %ifndef SQLITE_OMIT_VIEW
389 cmd ::= createkw(X) temp(T) VIEW ifnotexists(E) nm(Y) dbnm(Z) AS select(S). { 401 cmd ::= createkw(X) temp(T) VIEW ifnotexists(E) nm(Y) dbnm(Z) eidlist_opt(C)
390 sqlite3CreateView(pParse, &X, &Y, &Z, S, T, E); 402 AS select(S). {
403 sqlite3CreateView(pParse, &X, &Y, &Z, C, S, T, E);
391 } 404 }
392 cmd ::= DROP VIEW ifexists(E) fullname(X). { 405 cmd ::= DROP VIEW ifexists(E) fullname(X). {
393 sqlite3DropTable(pParse, X, 1, E); 406 sqlite3DropTable(pParse, X, 1, E);
394 } 407 }
395 %endif SQLITE_OMIT_VIEW 408 %endif SQLITE_OMIT_VIEW
396 409
397 //////////////////////// The SELECT statement ///////////////////////////////// 410 //////////////////////// The SELECT statement /////////////////////////////////
398 // 411 //
399 cmd ::= select(X). { 412 cmd ::= select(X). {
400 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0}; 413 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
401 sqlite3Select(pParse, X, &dest); 414 sqlite3Select(pParse, X, &dest);
402 sqlite3SelectDelete(pParse->db, X); 415 sqlite3SelectDelete(pParse->db, X);
403 } 416 }
404 417
405 %type select {Select*} 418 %type select {Select*}
406 %destructor select {sqlite3SelectDelete(pParse->db, $$);} 419 %destructor select {sqlite3SelectDelete(pParse->db, $$);}
407 %type selectnowith {Select*} 420 %type selectnowith {Select*}
408 %destructor selectnowith {sqlite3SelectDelete(pParse->db, $$);} 421 %destructor selectnowith {sqlite3SelectDelete(pParse->db, $$);}
409 %type oneselect {Select*} 422 %type oneselect {Select*}
410 %destructor oneselect {sqlite3SelectDelete(pParse->db, $$);} 423 %destructor oneselect {sqlite3SelectDelete(pParse->db, $$);}
411 424
412 select(A) ::= with(W) selectnowith(X). { 425 %include {
413 Select *p = X, *pNext, *pLoop; 426 /*
414 if( p ){ 427 ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
415 int cnt = 0, mxSelect; 428 ** all elements in the list. And make sure list length does not exceed
416 p->pWith = W; 429 ** SQLITE_LIMIT_COMPOUND_SELECT.
430 */
431 static void parserDoubleLinkSelect(Parse *pParse, Select *p){
417 if( p->pPrior ){ 432 if( p->pPrior ){
418 pNext = 0; 433 Select *pNext = 0, *pLoop;
434 int mxSelect, cnt = 0;
419 for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){ 435 for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
420 pLoop->pNext = pNext; 436 pLoop->pNext = pNext;
421 pLoop->selFlags |= SF_Compound; 437 pLoop->selFlags |= SF_Compound;
422 } 438 }
423 mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT]; 439 if( (p->selFlags & SF_MultiValue)==0 &&
424 if( mxSelect && cnt>mxSelect ){ 440 (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
441 cnt>mxSelect
442 ){
425 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT"); 443 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
426 } 444 }
427 } 445 }
446 }
447 }
448
449 select(A) ::= with(W) selectnowith(X). {
450 Select *p = X;
451 if( p ){
452 p->pWith = W;
453 parserDoubleLinkSelect(pParse, p);
428 }else{ 454 }else{
429 sqlite3WithDelete(pParse->db, W); 455 sqlite3WithDelete(pParse->db, W);
430 } 456 }
431 A = p; 457 A = p;
432 } 458 }
433 459
434 selectnowith(A) ::= oneselect(X). {A = X;} 460 selectnowith(A) ::= oneselect(X). {A = X;}
435 %ifndef SQLITE_OMIT_COMPOUND_SELECT 461 %ifndef SQLITE_OMIT_COMPOUND_SELECT
436 selectnowith(A) ::= selectnowith(X) multiselect_op(Y) oneselect(Z). { 462 selectnowith(A) ::= selectnowith(X) multiselect_op(Y) oneselect(Z). {
437 Select *pRhs = Z; 463 Select *pRhs = Z;
464 Select *pLhs = X;
438 if( pRhs && pRhs->pPrior ){ 465 if( pRhs && pRhs->pPrior ){
439 SrcList *pFrom; 466 SrcList *pFrom;
440 Token x; 467 Token x;
441 x.n = 0; 468 x.n = 0;
469 parserDoubleLinkSelect(pParse, pRhs);
442 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); 470 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
443 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0); 471 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
444 } 472 }
445 if( pRhs ){ 473 if( pRhs ){
446 pRhs->op = (u8)Y; 474 pRhs->op = (u8)Y;
447 pRhs->pPrior = X; 475 pRhs->pPrior = pLhs;
476 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
477 pRhs->selFlags &= ~SF_MultiValue;
448 if( Y!=TK_ALL ) pParse->hasCompound = 1; 478 if( Y!=TK_ALL ) pParse->hasCompound = 1;
449 }else{ 479 }else{
450 sqlite3SelectDelete(pParse->db, X); 480 sqlite3SelectDelete(pParse->db, pLhs);
451 } 481 }
452 A = pRhs; 482 A = pRhs;
453 } 483 }
454 %type multiselect_op {int} 484 %type multiselect_op {int}
455 multiselect_op(A) ::= UNION(OP). {A = @OP;} 485 multiselect_op(A) ::= UNION(OP). {A = @OP;}
456 multiselect_op(A) ::= UNION ALL. {A = TK_ALL;} 486 multiselect_op(A) ::= UNION ALL. {A = TK_ALL;}
457 multiselect_op(A) ::= EXCEPT|INTERSECT(OP). {A = @OP;} 487 multiselect_op(A) ::= EXCEPT|INTERSECT(OP). {A = @OP;}
458 %endif SQLITE_OMIT_COMPOUND_SELECT 488 %endif SQLITE_OMIT_COMPOUND_SELECT
459 oneselect(A) ::= SELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y) 489 oneselect(A) ::= SELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y)
460 groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). { 490 groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {
(...skipping 24 matching lines...) Expand all
485 #endif /* SELECTRACE_ENABLED */ 515 #endif /* SELECTRACE_ENABLED */
486 } 516 }
487 oneselect(A) ::= values(X). {A = X;} 517 oneselect(A) ::= values(X). {A = X;}
488 518
489 %type values {Select*} 519 %type values {Select*}
490 %destructor values {sqlite3SelectDelete(pParse->db, $$);} 520 %destructor values {sqlite3SelectDelete(pParse->db, $$);}
491 values(A) ::= VALUES LP nexprlist(X) RP. { 521 values(A) ::= VALUES LP nexprlist(X) RP. {
492 A = sqlite3SelectNew(pParse,X,0,0,0,0,0,SF_Values,0,0); 522 A = sqlite3SelectNew(pParse,X,0,0,0,0,0,SF_Values,0,0);
493 } 523 }
494 values(A) ::= values(X) COMMA LP exprlist(Y) RP. { 524 values(A) ::= values(X) COMMA LP exprlist(Y) RP. {
495 Select *pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values,0,0); 525 Select *pRight, *pLeft = X;
526 pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
527 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
496 if( pRight ){ 528 if( pRight ){
497 pRight->op = TK_ALL; 529 pRight->op = TK_ALL;
498 pRight->pPrior = X; 530 pLeft = X;
531 pRight->pPrior = pLeft;
499 A = pRight; 532 A = pRight;
500 }else{ 533 }else{
501 A = X; 534 A = pLeft;
502 } 535 }
503 } 536 }
504 537
505 // The "distinct" nonterminal is true (1) if the DISTINCT keyword is 538 // The "distinct" nonterminal is true (1) if the DISTINCT keyword is
506 // present and false (0) if it is not. 539 // present and false (0) if it is not.
507 // 540 //
508 %type distinct {u16} 541 %type distinct {int}
509 distinct(A) ::= DISTINCT. {A = SF_Distinct;} 542 distinct(A) ::= DISTINCT. {A = SF_Distinct;}
510 distinct(A) ::= ALL. {A = 0;} 543 distinct(A) ::= ALL. {A = SF_All;}
511 distinct(A) ::= . {A = 0;} 544 distinct(A) ::= . {A = 0;}
512 545
513 // selcollist is a list of expressions that are to become the return 546 // selcollist is a list of expressions that are to become the return
514 // values of the SELECT statement. The "*" in statements like 547 // values of the SELECT statement. The "*" in statements like
515 // "SELECT * FROM ..." is encoded as a special expression with an 548 // "SELECT * FROM ..." is encoded as a special expression with an
516 // opcode of TK_ALL. 549 // opcode of TK_ASTERISK.
517 // 550 //
518 %type selcollist {ExprList*} 551 %type selcollist {ExprList*}
519 %destructor selcollist {sqlite3ExprListDelete(pParse->db, $$);} 552 %destructor selcollist {sqlite3ExprListDelete(pParse->db, $$);}
520 %type sclp {ExprList*} 553 %type sclp {ExprList*}
521 %destructor sclp {sqlite3ExprListDelete(pParse->db, $$);} 554 %destructor sclp {sqlite3ExprListDelete(pParse->db, $$);}
522 sclp(A) ::= selcollist(X) COMMA. {A = X;} 555 sclp(A) ::= selcollist(X) COMMA. {A = X;}
523 sclp(A) ::= . {A = 0;} 556 sclp(A) ::= . {A = 0;}
524 selcollist(A) ::= sclp(P) expr(X) as(Y). { 557 selcollist(A) ::= sclp(P) expr(X) as(Y). {
525 A = sqlite3ExprListAppend(pParse, P, X.pExpr); 558 A = sqlite3ExprListAppend(pParse, P, X.pExpr);
526 if( Y.n>0 ) sqlite3ExprListSetName(pParse, A, &Y, 1); 559 if( Y.n>0 ) sqlite3ExprListSetName(pParse, A, &Y, 1);
527 sqlite3ExprListSetSpan(pParse,A,&X); 560 sqlite3ExprListSetSpan(pParse,A,&X);
528 } 561 }
529 selcollist(A) ::= sclp(P) STAR. { 562 selcollist(A) ::= sclp(P) STAR. {
530 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); 563 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
531 A = sqlite3ExprListAppend(pParse, P, p); 564 A = sqlite3ExprListAppend(pParse, P, p);
532 } 565 }
533 selcollist(A) ::= sclp(P) nm(X) DOT STAR(Y). { 566 selcollist(A) ::= sclp(P) nm(X) DOT STAR(Y). {
534 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &Y); 567 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &Y);
535 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &X); 568 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &X);
536 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); 569 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
537 A = sqlite3ExprListAppend(pParse,P, pDot); 570 A = sqlite3ExprListAppend(pParse,P, pDot);
538 } 571 }
539 572
540 // An option "AS <id>" phrase that can follow one of the expressions that 573 // An option "AS <id>" phrase that can follow one of the expressions that
541 // define the result set, or one of the tables in the FROM clause. 574 // define the result set, or one of the tables in the FROM clause.
542 // 575 //
543 %type as {Token} 576 %type as {Token}
544 as(X) ::= AS nm(Y). {X = Y;} 577 as(X) ::= AS nm(Y). {X = Y;}
(...skipping 14 matching lines...) Expand all
559 from(A) ::= FROM seltablist(X). { 592 from(A) ::= FROM seltablist(X). {
560 A = X; 593 A = X;
561 sqlite3SrcListShiftJoinType(A); 594 sqlite3SrcListShiftJoinType(A);
562 } 595 }
563 596
564 // "seltablist" is a "Select Table List" - the content of the FROM clause 597 // "seltablist" is a "Select Table List" - the content of the FROM clause
565 // in a SELECT statement. "stl_prefix" is a prefix of this list. 598 // in a SELECT statement. "stl_prefix" is a prefix of this list.
566 // 599 //
567 stl_prefix(A) ::= seltablist(X) joinop(Y). { 600 stl_prefix(A) ::= seltablist(X) joinop(Y). {
568 A = X; 601 A = X;
569 if( ALWAYS(A && A->nSrc>0) ) A->a[A->nSrc-1].jointype = (u8)Y; 602 if( ALWAYS(A && A->nSrc>0) ) A->a[A->nSrc-1].fg.jointype = (u8)Y;
570 } 603 }
571 stl_prefix(A) ::= . {A = 0;} 604 stl_prefix(A) ::= . {A = 0;}
572 seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I) 605 seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I)
573 on_opt(N) using_opt(U). { 606 on_opt(N) using_opt(U). {
574 A = sqlite3SrcListAppendFromTerm(pParse,X,&Y,&D,&Z,0,N,U); 607 A = sqlite3SrcListAppendFromTerm(pParse,X,&Y,&D,&Z,0,N,U);
575 sqlite3SrcListIndexedBy(pParse, A, &I); 608 sqlite3SrcListIndexedBy(pParse, A, &I);
576 } 609 }
610 seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) LP exprlist(E) RP as(Z)
611 on_opt(N) using_opt(U). {
612 A = sqlite3SrcListAppendFromTerm(pParse,X,&Y,&D,&Z,0,N,U);
613 sqlite3SrcListFuncArgs(pParse, A, E);
614 }
577 %ifndef SQLITE_OMIT_SUBQUERY 615 %ifndef SQLITE_OMIT_SUBQUERY
578 seltablist(A) ::= stl_prefix(X) LP select(S) RP 616 seltablist(A) ::= stl_prefix(X) LP select(S) RP
579 as(Z) on_opt(N) using_opt(U). { 617 as(Z) on_opt(N) using_opt(U). {
580 A = sqlite3SrcListAppendFromTerm(pParse,X,0,0,&Z,S,N,U); 618 A = sqlite3SrcListAppendFromTerm(pParse,X,0,0,&Z,S,N,U);
581 } 619 }
582 seltablist(A) ::= stl_prefix(X) LP seltablist(F) RP 620 seltablist(A) ::= stl_prefix(X) LP seltablist(F) RP
583 as(Z) on_opt(N) using_opt(U). { 621 as(Z) on_opt(N) using_opt(U). {
584 if( X==0 && Z.n==0 && N==0 && U==0 ){ 622 if( X==0 && Z.n==0 && N==0 && U==0 ){
585 A = F; 623 A = F;
586 }else if( F->nSrc==1 ){ 624 }else if( F->nSrc==1 ){
(...skipping 19 matching lines...) Expand all
606 644
607 %type dbnm {Token} 645 %type dbnm {Token}
608 dbnm(A) ::= . {A.z=0; A.n=0;} 646 dbnm(A) ::= . {A.z=0; A.n=0;}
609 dbnm(A) ::= DOT nm(X). {A = X;} 647 dbnm(A) ::= DOT nm(X). {A = X;}
610 648
611 %type fullname {SrcList*} 649 %type fullname {SrcList*}
612 %destructor fullname {sqlite3SrcListDelete(pParse->db, $$);} 650 %destructor fullname {sqlite3SrcListDelete(pParse->db, $$);}
613 fullname(A) ::= nm(X) dbnm(Y). {A = sqlite3SrcListAppend(pParse->db,0,&X,&Y);} 651 fullname(A) ::= nm(X) dbnm(Y). {A = sqlite3SrcListAppend(pParse->db,0,&X,&Y);}
614 652
615 %type joinop {int} 653 %type joinop {int}
616 %type joinop2 {int}
617 joinop(X) ::= COMMA|JOIN. { X = JT_INNER; } 654 joinop(X) ::= COMMA|JOIN. { X = JT_INNER; }
618 joinop(X) ::= JOIN_KW(A) JOIN. { X = sqlite3JoinType(pParse,&A,0,0); } 655 joinop(X) ::= JOIN_KW(A) JOIN. { X = sqlite3JoinType(pParse,&A,0,0); }
619 joinop(X) ::= JOIN_KW(A) nm(B) JOIN. { X = sqlite3JoinType(pParse,&A,&B,0); } 656 joinop(X) ::= JOIN_KW(A) nm(B) JOIN. { X = sqlite3JoinType(pParse,&A,&B,0); }
620 joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN. 657 joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN.
621 { X = sqlite3JoinType(pParse,&A,&B,&C); } 658 { X = sqlite3JoinType(pParse,&A,&B,&C); }
622 659
623 %type on_opt {Expr*} 660 %type on_opt {Expr*}
624 %destructor on_opt {sqlite3ExprDelete(pParse->db, $$);} 661 %destructor on_opt {sqlite3ExprDelete(pParse->db, $$);}
625 on_opt(N) ::= ON expr(E). {N = E.pExpr;} 662 on_opt(N) ::= ON expr(E). {N = E.pExpr;}
626 on_opt(N) ::= . {N = 0;} 663 on_opt(N) ::= . {N = 0;}
(...skipping 14 matching lines...) Expand all
641 indexed_opt(A) ::= NOT INDEXED. {A.z=0; A.n=1;} 678 indexed_opt(A) ::= NOT INDEXED. {A.z=0; A.n=1;}
642 679
643 %type using_opt {IdList*} 680 %type using_opt {IdList*}
644 %destructor using_opt {sqlite3IdListDelete(pParse->db, $$);} 681 %destructor using_opt {sqlite3IdListDelete(pParse->db, $$);}
645 using_opt(U) ::= USING LP idlist(L) RP. {U = L;} 682 using_opt(U) ::= USING LP idlist(L) RP. {U = L;}
646 using_opt(U) ::= . {U = 0;} 683 using_opt(U) ::= . {U = 0;}
647 684
648 685
649 %type orderby_opt {ExprList*} 686 %type orderby_opt {ExprList*}
650 %destructor orderby_opt {sqlite3ExprListDelete(pParse->db, $$);} 687 %destructor orderby_opt {sqlite3ExprListDelete(pParse->db, $$);}
688
689 // the sortlist non-terminal stores a list of expression where each
690 // expression is optionally followed by ASC or DESC to indicate the
691 // sort order.
692 //
651 %type sortlist {ExprList*} 693 %type sortlist {ExprList*}
652 %destructor sortlist {sqlite3ExprListDelete(pParse->db, $$);} 694 %destructor sortlist {sqlite3ExprListDelete(pParse->db, $$);}
653 695
654 orderby_opt(A) ::= . {A = 0;} 696 orderby_opt(A) ::= . {A = 0;}
655 orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;} 697 orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
656 sortlist(A) ::= sortlist(X) COMMA expr(Y) sortorder(Z). { 698 sortlist(A) ::= sortlist(X) COMMA expr(Y) sortorder(Z). {
657 A = sqlite3ExprListAppend(pParse,X,Y.pExpr); 699 A = sqlite3ExprListAppend(pParse,X,Y.pExpr);
658 if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z; 700 sqlite3ExprListSetSortOrder(A,Z);
659 } 701 }
660 sortlist(A) ::= expr(Y) sortorder(Z). { 702 sortlist(A) ::= expr(Y) sortorder(Z). {
661 A = sqlite3ExprListAppend(pParse,0,Y.pExpr); 703 A = sqlite3ExprListAppend(pParse,0,Y.pExpr);
662 if( A && ALWAYS(A->a) ) A->a[0].sortOrder = (u8)Z; 704 sqlite3ExprListSetSortOrder(A,Z);
663 } 705 }
664 706
665 %type sortorder {int} 707 %type sortorder {int}
666 708
667 sortorder(A) ::= ASC. {A = SQLITE_SO_ASC;} 709 sortorder(A) ::= ASC. {A = SQLITE_SO_ASC;}
668 sortorder(A) ::= DESC. {A = SQLITE_SO_DESC;} 710 sortorder(A) ::= DESC. {A = SQLITE_SO_DESC;}
669 sortorder(A) ::= . {A = SQLITE_SO_ASC;} 711 sortorder(A) ::= . {A = SQLITE_SO_UNDEFINED;}
670 712
671 %type groupby_opt {ExprList*} 713 %type groupby_opt {ExprList*}
672 %destructor groupby_opt {sqlite3ExprListDelete(pParse->db, $$);} 714 %destructor groupby_opt {sqlite3ExprListDelete(pParse->db, $$);}
673 groupby_opt(A) ::= . {A = 0;} 715 groupby_opt(A) ::= . {A = 0;}
674 groupby_opt(A) ::= GROUP BY nexprlist(X). {A = X;} 716 groupby_opt(A) ::= GROUP BY nexprlist(X). {A = X;}
675 717
676 %type having_opt {Expr*} 718 %type having_opt {Expr*}
677 %destructor having_opt {sqlite3ExprDelete(pParse->db, $$);} 719 %destructor having_opt {sqlite3ExprDelete(pParse->db, $$);}
678 having_opt(A) ::= . {A = 0;} 720 having_opt(A) ::= . {A = 0;}
679 having_opt(A) ::= HAVING expr(X). {A = X.pExpr;} 721 having_opt(A) ::= HAVING expr(X). {A = X.pExpr;}
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 A = sqlite3ExprListAppend(pParse, Z, Y.pExpr); 794 A = sqlite3ExprListAppend(pParse, Z, Y.pExpr);
753 sqlite3ExprListSetName(pParse, A, &X, 1); 795 sqlite3ExprListSetName(pParse, A, &X, 1);
754 } 796 }
755 setlist(A) ::= nm(X) EQ expr(Y). { 797 setlist(A) ::= nm(X) EQ expr(Y). {
756 A = sqlite3ExprListAppend(pParse, 0, Y.pExpr); 798 A = sqlite3ExprListAppend(pParse, 0, Y.pExpr);
757 sqlite3ExprListSetName(pParse, A, &X, 1); 799 sqlite3ExprListSetName(pParse, A, &X, 1);
758 } 800 }
759 801
760 ////////////////////////// The INSERT command ///////////////////////////////// 802 ////////////////////////// The INSERT command /////////////////////////////////
761 // 803 //
762 cmd ::= with(W) insert_cmd(R) INTO fullname(X) inscollist_opt(F) select(S). { 804 cmd ::= with(W) insert_cmd(R) INTO fullname(X) idlist_opt(F) select(S). {
763 sqlite3WithPush(pParse, W, 1); 805 sqlite3WithPush(pParse, W, 1);
764 sqlite3Insert(pParse, X, S, F, R); 806 sqlite3Insert(pParse, X, S, F, R);
765 } 807 }
766 cmd ::= with(W) insert_cmd(R) INTO fullname(X) inscollist_opt(F) DEFAULT VALUES. 808 cmd ::= with(W) insert_cmd(R) INTO fullname(X) idlist_opt(F) DEFAULT VALUES.
767 { 809 {
768 sqlite3WithPush(pParse, W, 1); 810 sqlite3WithPush(pParse, W, 1);
769 sqlite3Insert(pParse, X, 0, F, R); 811 sqlite3Insert(pParse, X, 0, F, R);
770 } 812 }
771 813
772 %type insert_cmd {u8} 814 %type insert_cmd {int}
773 insert_cmd(A) ::= INSERT orconf(R). {A = R;} 815 insert_cmd(A) ::= INSERT orconf(R). {A = R;}
774 insert_cmd(A) ::= REPLACE. {A = OE_Replace;} 816 insert_cmd(A) ::= REPLACE. {A = OE_Replace;}
775 817
776 %type inscollist_opt {IdList*} 818 %type idlist_opt {IdList*}
777 %destructor inscollist_opt {sqlite3IdListDelete(pParse->db, $$);} 819 %destructor idlist_opt {sqlite3IdListDelete(pParse->db, $$);}
778 %type idlist {IdList*} 820 %type idlist {IdList*}
779 %destructor idlist {sqlite3IdListDelete(pParse->db, $$);} 821 %destructor idlist {sqlite3IdListDelete(pParse->db, $$);}
780 822
781 inscollist_opt(A) ::= . {A = 0;} 823 idlist_opt(A) ::= . {A = 0;}
782 inscollist_opt(A) ::= LP idlist(X) RP. {A = X;} 824 idlist_opt(A) ::= LP idlist(X) RP. {A = X;}
783 idlist(A) ::= idlist(X) COMMA nm(Y). 825 idlist(A) ::= idlist(X) COMMA nm(Y).
784 {A = sqlite3IdListAppend(pParse->db,X,&Y);} 826 {A = sqlite3IdListAppend(pParse->db,X,&Y);}
785 idlist(A) ::= nm(Y). 827 idlist(A) ::= nm(Y).
786 {A = sqlite3IdListAppend(pParse->db,0,&Y);} 828 {A = sqlite3IdListAppend(pParse->db,0,&Y);}
787 829
788 /////////////////////////// Expression Processing ///////////////////////////// 830 /////////////////////////// Expression Processing /////////////////////////////
789 // 831 //
790 832
791 %type expr {ExprSpan} 833 %type expr {ExprSpan}
792 %destructor expr {sqlite3ExprDelete(pParse->db, $$.pExpr);} 834 %destructor expr {sqlite3ExprDelete(pParse->db, $$.pExpr);}
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 A.pExpr = sqlite3PExpr(pParse, TK_CAST, E.pExpr, 0, &T); 905 A.pExpr = sqlite3PExpr(pParse, TK_CAST, E.pExpr, 0, &T);
864 spanSet(&A,&X,&Y); 906 spanSet(&A,&X,&Y);
865 } 907 }
866 %endif SQLITE_OMIT_CAST 908 %endif SQLITE_OMIT_CAST
867 expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). { 909 expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). {
868 if( Y && Y->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ 910 if( Y && Y->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
869 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X); 911 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
870 } 912 }
871 A.pExpr = sqlite3ExprFunction(pParse, Y, &X); 913 A.pExpr = sqlite3ExprFunction(pParse, Y, &X);
872 spanSet(&A,&X,&E); 914 spanSet(&A,&X,&E);
873 if( D && A.pExpr ){ 915 if( D==SF_Distinct && A.pExpr ){
874 A.pExpr->flags |= EP_Distinct; 916 A.pExpr->flags |= EP_Distinct;
875 } 917 }
876 } 918 }
877 expr(A) ::= id(X) LP STAR RP(E). { 919 expr(A) ::= id(X) LP STAR RP(E). {
878 A.pExpr = sqlite3ExprFunction(pParse, 0, &X); 920 A.pExpr = sqlite3ExprFunction(pParse, 0, &X);
879 spanSet(&A,&X,&E); 921 spanSet(&A,&X,&E);
880 } 922 }
881 term(A) ::= CTIME_KW(OP). { 923 term(A) ::= CTIME_KW(OP). {
882 A.pExpr = sqlite3ExprFunction(pParse, 0, &OP); 924 A.pExpr = sqlite3ExprFunction(pParse, 0, &OP);
883 spanSet(&A, &OP, &OP); 925 spanSet(&A, &OP, &OP);
884 } 926 }
885 927
886 %include { 928 %include {
887 /* This routine constructs a binary expression node out of two ExprSpan 929 /* This routine constructs a binary expression node out of two ExprSpan
888 ** objects and uses the result to populate a new ExprSpan object. 930 ** objects and uses the result to populate a new ExprSpan object.
889 */ 931 */
890 static void spanBinaryExpr( 932 static void spanBinaryExpr(
891 ExprSpan *pOut, /* Write the result here */ 933 ExprSpan *pOut, /* Write the result here */
892 Parse *pParse, /* The parsing context. Errors accumulate here */ 934 Parse *pParse, /* The parsing context. Errors accumulate here */
893 int op, /* The binary operation */ 935 int op, /* The binary operation */
894 ExprSpan *pLeft, /* The left operand */ 936 ExprSpan *pLeft, /* The left operand */
895 ExprSpan *pRight /* The right operand */ 937 ExprSpan *pRight /* The right operand */
896 ){ 938 ){
897 pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0); 939 pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0);
898 pOut->zStart = pLeft->zStart; 940 pOut->zStart = pLeft->zStart;
899 pOut->zEnd = pRight->zEnd; 941 pOut->zEnd = pRight->zEnd;
900 } 942 }
943
944 /* If doNot is true, then add a TK_NOT Expr-node wrapper around the
945 ** outside of *ppExpr.
946 */
947 static void exprNot(Parse *pParse, int doNot, Expr **ppExpr){
948 if( doNot ) *ppExpr = sqlite3PExpr(pParse, TK_NOT, *ppExpr, 0, 0);
949 }
901 } 950 }
902 951
903 expr(A) ::= expr(X) AND(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 952 expr(A) ::= expr(X) AND(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
904 expr(A) ::= expr(X) OR(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 953 expr(A) ::= expr(X) OR(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
905 expr(A) ::= expr(X) LT|GT|GE|LE(OP) expr(Y). 954 expr(A) ::= expr(X) LT|GT|GE|LE(OP) expr(Y).
906 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 955 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
907 expr(A) ::= expr(X) EQ|NE(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 956 expr(A) ::= expr(X) EQ|NE(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
908 expr(A) ::= expr(X) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y). 957 expr(A) ::= expr(X) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).
909 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 958 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
910 expr(A) ::= expr(X) PLUS|MINUS(OP) expr(Y). 959 expr(A) ::= expr(X) PLUS|MINUS(OP) expr(Y).
911 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 960 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
912 expr(A) ::= expr(X) STAR|SLASH|REM(OP) expr(Y). 961 expr(A) ::= expr(X) STAR|SLASH|REM(OP) expr(Y).
913 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 962 {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
914 expr(A) ::= expr(X) CONCAT(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);} 963 expr(A) ::= expr(X) CONCAT(OP) expr(Y). {spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
915 %type likeop {struct LikeOp} 964 %type likeop {struct LikeOp}
916 likeop(A) ::= LIKE_KW|MATCH(X). {A.eOperator = X; A.bNot = 0;} 965 likeop(A) ::= LIKE_KW|MATCH(X). {A.eOperator = X; A.bNot = 0;}
917 likeop(A) ::= NOT LIKE_KW|MATCH(X). {A.eOperator = X; A.bNot = 1;} 966 likeop(A) ::= NOT LIKE_KW|MATCH(X). {A.eOperator = X; A.bNot = 1;}
918 expr(A) ::= expr(X) likeop(OP) expr(Y). [LIKE_KW] { 967 expr(A) ::= expr(X) likeop(OP) expr(Y). [LIKE_KW] {
919 ExprList *pList; 968 ExprList *pList;
920 pList = sqlite3ExprListAppend(pParse,0, Y.pExpr); 969 pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);
921 pList = sqlite3ExprListAppend(pParse,pList, X.pExpr); 970 pList = sqlite3ExprListAppend(pParse,pList, X.pExpr);
922 A.pExpr = sqlite3ExprFunction(pParse, pList, &OP.eOperator); 971 A.pExpr = sqlite3ExprFunction(pParse, pList, &OP.eOperator);
923 if( OP.bNot ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0); 972 exprNot(pParse, OP.bNot, &A.pExpr);
924 A.zStart = X.zStart; 973 A.zStart = X.zStart;
925 A.zEnd = Y.zEnd; 974 A.zEnd = Y.zEnd;
926 if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc; 975 if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;
927 } 976 }
928 expr(A) ::= expr(X) likeop(OP) expr(Y) ESCAPE expr(E). [LIKE_KW] { 977 expr(A) ::= expr(X) likeop(OP) expr(Y) ESCAPE expr(E). [LIKE_KW] {
929 ExprList *pList; 978 ExprList *pList;
930 pList = sqlite3ExprListAppend(pParse,0, Y.pExpr); 979 pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);
931 pList = sqlite3ExprListAppend(pParse,pList, X.pExpr); 980 pList = sqlite3ExprListAppend(pParse,pList, X.pExpr);
932 pList = sqlite3ExprListAppend(pParse,pList, E.pExpr); 981 pList = sqlite3ExprListAppend(pParse,pList, E.pExpr);
933 A.pExpr = sqlite3ExprFunction(pParse, pList, &OP.eOperator); 982 A.pExpr = sqlite3ExprFunction(pParse, pList, &OP.eOperator);
934 if( OP.bNot ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0); 983 exprNot(pParse, OP.bNot, &A.pExpr);
935 A.zStart = X.zStart; 984 A.zStart = X.zStart;
936 A.zEnd = E.zEnd; 985 A.zEnd = E.zEnd;
937 if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc; 986 if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;
938 } 987 }
939 988
940 %include { 989 %include {
941 /* Construct an expression node for a unary postfix operator 990 /* Construct an expression node for a unary postfix operator
942 */ 991 */
943 static void spanUnaryPostfix( 992 static void spanUnaryPostfix(
944 ExprSpan *pOut, /* Write the new expression node here */ 993 ExprSpan *pOut, /* Write the new expression node here */
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 between_op(A) ::= NOT BETWEEN. {A = 1;} 1063 between_op(A) ::= NOT BETWEEN. {A = 1;}
1015 expr(A) ::= expr(W) between_op(N) expr(X) AND expr(Y). [BETWEEN] { 1064 expr(A) ::= expr(W) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
1016 ExprList *pList = sqlite3ExprListAppend(pParse,0, X.pExpr); 1065 ExprList *pList = sqlite3ExprListAppend(pParse,0, X.pExpr);
1017 pList = sqlite3ExprListAppend(pParse,pList, Y.pExpr); 1066 pList = sqlite3ExprListAppend(pParse,pList, Y.pExpr);
1018 A.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, W.pExpr, 0, 0); 1067 A.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, W.pExpr, 0, 0);
1019 if( A.pExpr ){ 1068 if( A.pExpr ){
1020 A.pExpr->x.pList = pList; 1069 A.pExpr->x.pList = pList;
1021 }else{ 1070 }else{
1022 sqlite3ExprListDelete(pParse->db, pList); 1071 sqlite3ExprListDelete(pParse->db, pList);
1023 } 1072 }
1024 if( N ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0); 1073 exprNot(pParse, N, &A.pExpr);
1025 A.zStart = W.zStart; 1074 A.zStart = W.zStart;
1026 A.zEnd = Y.zEnd; 1075 A.zEnd = Y.zEnd;
1027 } 1076 }
1028 %ifndef SQLITE_OMIT_SUBQUERY 1077 %ifndef SQLITE_OMIT_SUBQUERY
1029 %type in_op {int} 1078 %type in_op {int}
1030 in_op(A) ::= IN. {A = 0;} 1079 in_op(A) ::= IN. {A = 0;}
1031 in_op(A) ::= NOT IN. {A = 1;} 1080 in_op(A) ::= NOT IN. {A = 1;}
1032 expr(A) ::= expr(X) in_op(N) LP exprlist(Y) RP(E). [IN] { 1081 expr(A) ::= expr(X) in_op(N) LP exprlist(Y) RP(E). [IN] {
1033 if( Y==0 ){ 1082 if( Y==0 ){
1034 /* Expressions of the form 1083 /* Expressions of the form
(...skipping 30 matching lines...) Expand all
1065 ** before now and control would have never reached this point */ 1114 ** before now and control would have never reached this point */
1066 if( ALWAYS(pRHS) ){ 1115 if( ALWAYS(pRHS) ){
1067 pRHS->flags &= ~EP_Collate; 1116 pRHS->flags &= ~EP_Collate;
1068 pRHS->flags |= EP_Generic; 1117 pRHS->flags |= EP_Generic;
1069 } 1118 }
1070 A.pExpr = sqlite3PExpr(pParse, N ? TK_NE : TK_EQ, X.pExpr, pRHS, 0); 1119 A.pExpr = sqlite3PExpr(pParse, N ? TK_NE : TK_EQ, X.pExpr, pRHS, 0);
1071 }else{ 1120 }else{
1072 A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0); 1121 A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0);
1073 if( A.pExpr ){ 1122 if( A.pExpr ){
1074 A.pExpr->x.pList = Y; 1123 A.pExpr->x.pList = Y;
1075 sqlite3ExprSetHeight(pParse, A.pExpr); 1124 sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
1076 }else{ 1125 }else{
1077 sqlite3ExprListDelete(pParse->db, Y); 1126 sqlite3ExprListDelete(pParse->db, Y);
1078 } 1127 }
1079 if( N ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0); 1128 exprNot(pParse, N, &A.pExpr);
1080 } 1129 }
1081 A.zStart = X.zStart; 1130 A.zStart = X.zStart;
1082 A.zEnd = &E.z[E.n]; 1131 A.zEnd = &E.z[E.n];
1083 } 1132 }
1084 expr(A) ::= LP(B) select(X) RP(E). { 1133 expr(A) ::= LP(B) select(X) RP(E). {
1085 A.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); 1134 A.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
1086 if( A.pExpr ){ 1135 if( A.pExpr ){
1087 A.pExpr->x.pSelect = X; 1136 A.pExpr->x.pSelect = X;
1088 ExprSetProperty(A.pExpr, EP_xIsSelect); 1137 ExprSetProperty(A.pExpr, EP_xIsSelect|EP_Subquery);
1089 sqlite3ExprSetHeight(pParse, A.pExpr); 1138 sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
1090 }else{ 1139 }else{
1091 sqlite3SelectDelete(pParse->db, X); 1140 sqlite3SelectDelete(pParse->db, X);
1092 } 1141 }
1093 A.zStart = B.z; 1142 A.zStart = B.z;
1094 A.zEnd = &E.z[E.n]; 1143 A.zEnd = &E.z[E.n];
1095 } 1144 }
1096 expr(A) ::= expr(X) in_op(N) LP select(Y) RP(E). [IN] { 1145 expr(A) ::= expr(X) in_op(N) LP select(Y) RP(E). [IN] {
1097 A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0); 1146 A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0);
1098 if( A.pExpr ){ 1147 if( A.pExpr ){
1099 A.pExpr->x.pSelect = Y; 1148 A.pExpr->x.pSelect = Y;
1100 ExprSetProperty(A.pExpr, EP_xIsSelect); 1149 ExprSetProperty(A.pExpr, EP_xIsSelect|EP_Subquery);
1101 sqlite3ExprSetHeight(pParse, A.pExpr); 1150 sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
1102 }else{ 1151 }else{
1103 sqlite3SelectDelete(pParse->db, Y); 1152 sqlite3SelectDelete(pParse->db, Y);
1104 } 1153 }
1105 if( N ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0); 1154 exprNot(pParse, N, &A.pExpr);
1106 A.zStart = X.zStart; 1155 A.zStart = X.zStart;
1107 A.zEnd = &E.z[E.n]; 1156 A.zEnd = &E.z[E.n];
1108 } 1157 }
1109 expr(A) ::= expr(X) in_op(N) nm(Y) dbnm(Z). [IN] { 1158 expr(A) ::= expr(X) in_op(N) nm(Y) dbnm(Z). [IN] {
1110 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z); 1159 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);
1111 A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0); 1160 A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0);
1112 if( A.pExpr ){ 1161 if( A.pExpr ){
1113 A.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); 1162 A.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
1114 ExprSetProperty(A.pExpr, EP_xIsSelect); 1163 ExprSetProperty(A.pExpr, EP_xIsSelect|EP_Subquery);
1115 sqlite3ExprSetHeight(pParse, A.pExpr); 1164 sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
1116 }else{ 1165 }else{
1117 sqlite3SrcListDelete(pParse->db, pSrc); 1166 sqlite3SrcListDelete(pParse->db, pSrc);
1118 } 1167 }
1119 if( N ) A.pExpr = sqlite3PExpr(pParse, TK_NOT, A.pExpr, 0, 0); 1168 exprNot(pParse, N, &A.pExpr);
1120 A.zStart = X.zStart; 1169 A.zStart = X.zStart;
1121 A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n]; 1170 A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n];
1122 } 1171 }
1123 expr(A) ::= EXISTS(B) LP select(Y) RP(E). { 1172 expr(A) ::= EXISTS(B) LP select(Y) RP(E). {
1124 Expr *p = A.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); 1173 Expr *p = A.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
1125 if( p ){ 1174 if( p ){
1126 p->x.pSelect = Y; 1175 p->x.pSelect = Y;
1127 ExprSetProperty(p, EP_xIsSelect); 1176 ExprSetProperty(p, EP_xIsSelect|EP_Subquery);
1128 sqlite3ExprSetHeight(pParse, p); 1177 sqlite3ExprSetHeightAndFlags(pParse, p);
1129 }else{ 1178 }else{
1130 sqlite3SelectDelete(pParse->db, Y); 1179 sqlite3SelectDelete(pParse->db, Y);
1131 } 1180 }
1132 A.zStart = B.z; 1181 A.zStart = B.z;
1133 A.zEnd = &E.z[E.n]; 1182 A.zEnd = &E.z[E.n];
1134 } 1183 }
1135 %endif SQLITE_OMIT_SUBQUERY 1184 %endif SQLITE_OMIT_SUBQUERY
1136 1185
1137 /* CASE expressions */ 1186 /* CASE expressions */
1138 expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). { 1187 expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
1139 A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, 0, 0); 1188 A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, 0, 0);
1140 if( A.pExpr ){ 1189 if( A.pExpr ){
1141 A.pExpr->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y; 1190 A.pExpr->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y;
1142 sqlite3ExprSetHeight(pParse, A.pExpr); 1191 sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
1143 }else{ 1192 }else{
1144 sqlite3ExprListDelete(pParse->db, Y); 1193 sqlite3ExprListDelete(pParse->db, Y);
1145 sqlite3ExprDelete(pParse->db, Z); 1194 sqlite3ExprDelete(pParse->db, Z);
1146 } 1195 }
1147 A.zStart = C.z; 1196 A.zStart = C.z;
1148 A.zEnd = &E.z[E.n]; 1197 A.zEnd = &E.z[E.n];
1149 } 1198 }
1150 %type case_exprlist {ExprList*} 1199 %type case_exprlist {ExprList*}
1151 %destructor case_exprlist {sqlite3ExprListDelete(pParse->db, $$);} 1200 %destructor case_exprlist {sqlite3ExprListDelete(pParse->db, $$);}
1152 case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). { 1201 case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
(...skipping 22 matching lines...) Expand all
1175 exprlist(A) ::= . {A = 0;} 1224 exprlist(A) ::= . {A = 0;}
1176 nexprlist(A) ::= nexprlist(X) COMMA expr(Y). 1225 nexprlist(A) ::= nexprlist(X) COMMA expr(Y).
1177 {A = sqlite3ExprListAppend(pParse,X,Y.pExpr);} 1226 {A = sqlite3ExprListAppend(pParse,X,Y.pExpr);}
1178 nexprlist(A) ::= expr(Y). 1227 nexprlist(A) ::= expr(Y).
1179 {A = sqlite3ExprListAppend(pParse,0,Y.pExpr);} 1228 {A = sqlite3ExprListAppend(pParse,0,Y.pExpr);}
1180 1229
1181 1230
1182 ///////////////////////////// The CREATE INDEX command /////////////////////// 1231 ///////////////////////////// The CREATE INDEX command ///////////////////////
1183 // 1232 //
1184 cmd ::= createkw(S) uniqueflag(U) INDEX ifnotexists(NE) nm(X) dbnm(D) 1233 cmd ::= createkw(S) uniqueflag(U) INDEX ifnotexists(NE) nm(X) dbnm(D)
1185 ON nm(Y) LP idxlist(Z) RP where_opt(W). { 1234 ON nm(Y) LP sortlist(Z) RP where_opt(W). {
1186 sqlite3CreateIndex(pParse, &X, &D, 1235 sqlite3CreateIndex(pParse, &X, &D,
1187 sqlite3SrcListAppend(pParse->db,0,&Y,0), Z, U, 1236 sqlite3SrcListAppend(pParse->db,0,&Y,0), Z, U,
1188 &S, W, SQLITE_SO_ASC, NE); 1237 &S, W, SQLITE_SO_ASC, NE);
1189 } 1238 }
1190 1239
1191 %type uniqueflag {int} 1240 %type uniqueflag {int}
1192 uniqueflag(A) ::= UNIQUE. {A = OE_Abort;} 1241 uniqueflag(A) ::= UNIQUE. {A = OE_Abort;}
1193 uniqueflag(A) ::= . {A = OE_None;} 1242 uniqueflag(A) ::= . {A = OE_None;}
1194 1243
1195 %type idxlist {ExprList*}
1196 %destructor idxlist {sqlite3ExprListDelete(pParse->db, $$);}
1197 %type idxlist_opt {ExprList*}
1198 %destructor idxlist_opt {sqlite3ExprListDelete(pParse->db, $$);}
1199 1244
1200 idxlist_opt(A) ::= . {A = 0;} 1245 // The eidlist non-terminal (Expression Id List) generates an ExprList
1201 idxlist_opt(A) ::= LP idxlist(X) RP. {A = X;} 1246 // from a list of identifiers. The identifier names are in ExprList.a[].zName.
1202 idxlist(A) ::= idxlist(X) COMMA nm(Y) collate(C) sortorder(Z). { 1247 // This list is stored in an ExprList rather than an IdList so that it
1203 Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &C, 1); 1248 // can be easily sent to sqlite3ColumnsExprList().
1204 A = sqlite3ExprListAppend(pParse,X, p); 1249 //
1205 sqlite3ExprListSetName(pParse,A,&Y,1); 1250 // eidlist is grouped with CREATE INDEX because it used to be the non-terminal
1206 sqlite3ExprListCheckLength(pParse, A, "index"); 1251 // used for the arguments to an index. That is just an historical accident.
1207 if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z; 1252 //
1253 // IMPORTANT COMPATIBILITY NOTE: Some prior versions of SQLite accepted
1254 // COLLATE clauses and ASC or DESC keywords on ID lists in inappropriate
1255 // places - places that might have been stored in the sqlite_master schema.
1256 // Those extra features were ignored. But because they might be in some
1257 // (busted) old databases, we need to continue parsing them when loading
1258 // historical schemas.
1259 //
1260 %type eidlist {ExprList*}
1261 %destructor eidlist {sqlite3ExprListDelete(pParse->db, $$);}
1262 %type eidlist_opt {ExprList*}
1263 %destructor eidlist_opt {sqlite3ExprListDelete(pParse->db, $$);}
1264
1265 %include {
1266 /* Add a single new term to an ExprList that is used to store a
1267 ** list of identifiers. Report an error if the ID list contains
1268 ** a COLLATE clause or an ASC or DESC keyword, except ignore the
1269 ** error while parsing a legacy schema.
1270 */
1271 static ExprList *parserAddExprIdListTerm(
1272 Parse *pParse,
1273 ExprList *pPrior,
1274 Token *pIdToken,
1275 int hasCollate,
1276 int sortOrder
1277 ){
1278 ExprList *p = sqlite3ExprListAppend(pParse, pPrior, 0);
1279 if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED)
1280 && pParse->db->init.busy==0
1281 ){
1282 sqlite3ErrorMsg(pParse, "syntax error after column name \"%.*s\"",
1283 pIdToken->n, pIdToken->z);
1284 }
1285 sqlite3ExprListSetName(pParse, p, pIdToken, 1);
1286 return p;
1287 }
1288 } // end %include
1289
1290 eidlist_opt(A) ::= . {A = 0;}
1291 eidlist_opt(A) ::= LP eidlist(X) RP. {A = X;}
1292 eidlist(A) ::= eidlist(X) COMMA nm(Y) collate(C) sortorder(Z). {
1293 A = parserAddExprIdListTerm(pParse, X, &Y, C, Z);
1208 } 1294 }
1209 idxlist(A) ::= nm(Y) collate(C) sortorder(Z). { 1295 eidlist(A) ::= nm(Y) collate(C) sortorder(Z). {
1210 Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &C, 1); 1296 A = parserAddExprIdListTerm(pParse, 0, &Y, C, Z);
1211 A = sqlite3ExprListAppend(pParse,0, p);
1212 sqlite3ExprListSetName(pParse, A, &Y, 1);
1213 sqlite3ExprListCheckLength(pParse, A, "index");
1214 if( A ) A->a[A->nExpr-1].sortOrder = (u8)Z;
1215 } 1297 }
1216 1298
1217 %type collate {Token} 1299 %type collate {int}
1218 collate(C) ::= . {C.z = 0; C.n = 0;} 1300 collate(C) ::= . {C = 0;}
1219 collate(C) ::= COLLATE ids(X). {C = X;} 1301 collate(C) ::= COLLATE ids. {C = 1;}
1220 1302
1221 1303
1222 ///////////////////////////// The DROP INDEX command ///////////////////////// 1304 ///////////////////////////// The DROP INDEX command /////////////////////////
1223 // 1305 //
1224 cmd ::= DROP INDEX ifexists(E) fullname(X). {sqlite3DropIndex(pParse, X, E);} 1306 cmd ::= DROP INDEX ifexists(E) fullname(X). {sqlite3DropIndex(pParse, X, E);}
1225 1307
1226 ///////////////////////////// The VACUUM command ///////////////////////////// 1308 ///////////////////////////// The VACUUM command /////////////////////////////
1227 // 1309 //
1228 %ifndef SQLITE_OMIT_VACUUM 1310 %ifndef SQLITE_OMIT_VACUUM
1229 %ifndef SQLITE_OMIT_ATTACH 1311 %ifndef SQLITE_OMIT_ATTACH
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 1419
1338 1420
1339 %type trigger_cmd {TriggerStep*} 1421 %type trigger_cmd {TriggerStep*}
1340 %destructor trigger_cmd {sqlite3DeleteTriggerStep(pParse->db, $$);} 1422 %destructor trigger_cmd {sqlite3DeleteTriggerStep(pParse->db, $$);}
1341 // UPDATE 1423 // UPDATE
1342 trigger_cmd(A) ::= 1424 trigger_cmd(A) ::=
1343 UPDATE orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z). 1425 UPDATE orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z).
1344 { A = sqlite3TriggerUpdateStep(pParse->db, &X, Y, Z, R); } 1426 { A = sqlite3TriggerUpdateStep(pParse->db, &X, Y, Z, R); }
1345 1427
1346 // INSERT 1428 // INSERT
1347 trigger_cmd(A) ::= insert_cmd(R) INTO trnm(X) inscollist_opt(F) select(S). 1429 trigger_cmd(A) ::= insert_cmd(R) INTO trnm(X) idlist_opt(F) select(S).
1348 {A = sqlite3TriggerInsertStep(pParse->db, &X, F, S, R);} 1430 {A = sqlite3TriggerInsertStep(pParse->db, &X, F, S, R);}
1349 1431
1350 // DELETE 1432 // DELETE
1351 trigger_cmd(A) ::= DELETE FROM trnm(X) tridxby where_opt(Y). 1433 trigger_cmd(A) ::= DELETE FROM trnm(X) tridxby where_opt(Y).
1352 {A = sqlite3TriggerDeleteStep(pParse->db, &X, Y);} 1434 {A = sqlite3TriggerDeleteStep(pParse->db, &X, Y);}
1353 1435
1354 // SELECT 1436 // SELECT
1355 trigger_cmd(A) ::= select(X). {A = sqlite3TriggerSelectStep(pParse->db, X); } 1437 trigger_cmd(A) ::= select(X). {A = sqlite3TriggerSelectStep(pParse->db, X); }
1356 1438
1357 // The special RAISE expression that may occur in trigger programs 1439 // The special RAISE expression that may occur in trigger programs
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 %type with {With*} 1539 %type with {With*}
1458 %type wqlist {With*} 1540 %type wqlist {With*}
1459 %destructor with {sqlite3WithDelete(pParse->db, $$);} 1541 %destructor with {sqlite3WithDelete(pParse->db, $$);}
1460 %destructor wqlist {sqlite3WithDelete(pParse->db, $$);} 1542 %destructor wqlist {sqlite3WithDelete(pParse->db, $$);}
1461 1543
1462 with(A) ::= . {A = 0;} 1544 with(A) ::= . {A = 0;}
1463 %ifndef SQLITE_OMIT_CTE 1545 %ifndef SQLITE_OMIT_CTE
1464 with(A) ::= WITH wqlist(W). { A = W; } 1546 with(A) ::= WITH wqlist(W). { A = W; }
1465 with(A) ::= WITH RECURSIVE wqlist(W). { A = W; } 1547 with(A) ::= WITH RECURSIVE wqlist(W). { A = W; }
1466 1548
1467 wqlist(A) ::= nm(X) idxlist_opt(Y) AS LP select(Z) RP. { 1549 wqlist(A) ::= nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
1468 A = sqlite3WithAdd(pParse, 0, &X, Y, Z); 1550 A = sqlite3WithAdd(pParse, 0, &X, Y, Z);
1469 } 1551 }
1470 wqlist(A) ::= wqlist(W) COMMA nm(X) idxlist_opt(Y) AS LP select(Z) RP. { 1552 wqlist(A) ::= wqlist(W) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
1471 A = sqlite3WithAdd(pParse, W, &X, Y, Z); 1553 A = sqlite3WithAdd(pParse, W, &X, Y, Z);
1472 } 1554 }
1473 %endif SQLITE_OMIT_CTE 1555 %endif SQLITE_OMIT_CTE
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3100200/src/pager.c ('k') | third_party/sqlite/sqlite-src-3100200/src/pcache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698