Change lots of internal symbols from sqliteXXX to sqlite3XXX so that the

library links again. It doesn't work yet, due to changes in the btree layer
calling convention. (CVS 1324)

FossilOrigin-Name: 8af6474c49263ae26216dff9465b33f76b500cf4
This commit is contained in:
danielk1977
2004-05-08 08:23:19 +00:00
parent 9b17127705
commit 4adee20fcb
50 changed files with 3343 additions and 2874 deletions
+242 -239
View File
@@ -14,7 +14,7 @@
** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.112 2004/02/22 18:40:57 drh Exp $
** @(#) $Id: parse.y,v 1.113 2004/05/08 08:23:30 danielk1977 Exp $
*/
%token_prefix TK_
%token_type {Token}
@@ -23,13 +23,13 @@
%syntax_error {
if( pParse->zErrMsg==0 ){
if( TOKEN.z[0] ){
sqliteErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
}else{
sqliteErrorMsg(pParse, "incomplete SQL statement");
sqlite3ErrorMsg(pParse, "incomplete SQL statement");
}
}
}
%name sqliteParser
%name sqlite3Parser
%include {
#include "sqliteInt.h"
#include "parse.h"
@@ -69,36 +69,36 @@ cmdlist ::= cmdlist ecmd.
cmdlist ::= ecmd.
ecmd ::= explain cmdx SEMI.
ecmd ::= SEMI.
cmdx ::= cmd. { sqliteExec(pParse); }
explain ::= EXPLAIN. { sqliteBeginParse(pParse, 1); }
explain ::= . { sqliteBeginParse(pParse, 0); }
cmdx ::= cmd. { sqlite3Exec(pParse); }
explain ::= EXPLAIN. { sqlite3BeginParse(pParse, 1); }
explain ::= . { sqlite3BeginParse(pParse, 0); }
///////////////////// Begin and end transactions. ////////////////////////////
//
cmd ::= BEGIN trans_opt onconf(R). {sqliteBeginTransaction(pParse,R);}
cmd ::= BEGIN trans_opt onconf(R). {sqlite3BeginTransaction(pParse,R);}
trans_opt ::= .
trans_opt ::= TRANSACTION.
trans_opt ::= TRANSACTION nm.
cmd ::= COMMIT trans_opt. {sqliteCommitTransaction(pParse);}
cmd ::= END trans_opt. {sqliteCommitTransaction(pParse);}
cmd ::= ROLLBACK trans_opt. {sqliteRollbackTransaction(pParse);}
cmd ::= COMMIT trans_opt. {sqlite3CommitTransaction(pParse);}
cmd ::= END trans_opt. {sqlite3CommitTransaction(pParse);}
cmd ::= ROLLBACK trans_opt. {sqlite3RollbackTransaction(pParse);}
///////////////////// The CREATE TABLE statement ////////////////////////////
//
cmd ::= create_table create_table_args.
create_table ::= CREATE(X) temp(T) TABLE nm(Y). {
sqliteStartTable(pParse,&X,&Y,T,0);
sqlite3StartTable(pParse,&X,&Y,T,0);
}
%type temp {int}
temp(A) ::= TEMP. {A = 1;}
temp(A) ::= . {A = 0;}
create_table_args ::= LP columnlist conslist_opt RP(X). {
sqliteEndTable(pParse,&X,0);
sqlite3EndTable(pParse,&X,0);
}
create_table_args ::= AS select(S). {
sqliteEndTable(pParse,0,S);
sqliteSelectDelete(S);
sqlite3EndTable(pParse,0,S);
sqlite3SelectDelete(S);
}
columnlist ::= columnlist COMMA column.
columnlist ::= column.
@@ -108,7 +108,7 @@ columnlist ::= column.
// an elaborate typename. Perhaps someday we'll do something with it.
//
column ::= columnid type carglist.
columnid ::= nm(X). {sqliteAddColumn(pParse,&X);}
columnid ::= nm(X). {sqlite3AddColumn(pParse,&X);}
// An IDENTIFIER can be a generic identifier, or one of several
// keywords. Any non-standard keyword can also be an identifier.
@@ -157,10 +157,10 @@ nm(A) ::= STRING(X). {A = X;}
nm(A) ::= JOIN_KW(X). {A = X;}
type ::= .
type ::= typename(X). {sqliteAddColumnType(pParse,&X,&X);}
type ::= typename(X) LP signed RP(Y). {sqliteAddColumnType(pParse,&X,&Y);}
type ::= typename(X). {sqlite3AddColumnType(pParse,&X,&X);}
type ::= typename(X) LP signed RP(Y). {sqlite3AddColumnType(pParse,&X,&Y);}
type ::= typename(X) LP signed COMMA signed RP(Y).
{sqliteAddColumnType(pParse,&X,&Y);}
{sqlite3AddColumnType(pParse,&X,&Y);}
%type typename {Token}
typename(A) ::= ids(X). {A = X;}
typename(A) ::= typename(X) ids. {A = X;}
@@ -172,29 +172,29 @@ carglist ::= carglist carg.
carglist ::= .
carg ::= CONSTRAINT nm ccons.
carg ::= ccons.
carg ::= DEFAULT STRING(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT ID(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT INTEGER(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT PLUS INTEGER(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT MINUS INTEGER(X). {sqliteAddDefaultValue(pParse,&X,1);}
carg ::= DEFAULT FLOAT(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT PLUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT MINUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,1);}
carg ::= DEFAULT STRING(X). {sqlite3AddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT ID(X). {sqlite3AddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT INTEGER(X). {sqlite3AddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT PLUS INTEGER(X). {sqlite3AddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT MINUS INTEGER(X). {sqlite3AddDefaultValue(pParse,&X,1);}
carg ::= DEFAULT FLOAT(X). {sqlite3AddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT PLUS FLOAT(X). {sqlite3AddDefaultValue(pParse,&X,0);}
carg ::= DEFAULT MINUS FLOAT(X). {sqlite3AddDefaultValue(pParse,&X,1);}
carg ::= DEFAULT NULL.
// In addition to the type name, we also care about the primary key and
// UNIQUE constraints.
//
ccons ::= NULL onconf.
ccons ::= NOT NULL onconf(R). {sqliteAddNotNull(pParse, R);}
ccons ::= PRIMARY KEY sortorder onconf(R). {sqliteAddPrimaryKey(pParse,0,R);}
ccons ::= UNIQUE onconf(R). {sqliteCreateIndex(pParse,0,0,0,R,0,0);}
ccons ::= NOT NULL onconf(R). {sqlite3AddNotNull(pParse, R);}
ccons ::= PRIMARY KEY sortorder onconf(R). {sqlite3AddPrimaryKey(pParse,0,R);}
ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,R,0,0);}
ccons ::= CHECK LP expr RP onconf.
ccons ::= REFERENCES nm(T) idxlist_opt(TA) refargs(R).
{sqliteCreateForeignKey(pParse,0,&T,TA,R);}
ccons ::= defer_subclause(D). {sqliteDeferForeignKey(pParse,D);}
{sqlite3CreateForeignKey(pParse,0,&T,TA,R);}
ccons ::= defer_subclause(D). {sqlite3DeferForeignKey(pParse,D);}
ccons ::= COLLATE id(C). {
sqliteAddCollateType(pParse, sqliteCollateType(C.z, C.n));
sqlite3AddCollateType(pParse, sqlite3CollateType(C.z, C.n));
}
// The next group of rules parses the arguments to a REFERENCES clause
@@ -233,14 +233,14 @@ conslist ::= conslist tcons.
conslist ::= tcons.
tcons ::= CONSTRAINT nm.
tcons ::= PRIMARY KEY LP idxlist(X) RP onconf(R).
{sqliteAddPrimaryKey(pParse,X,R);}
{sqlite3AddPrimaryKey(pParse,X,R);}
tcons ::= UNIQUE LP idxlist(X) RP onconf(R).
{sqliteCreateIndex(pParse,0,0,X,R,0,0);}
{sqlite3CreateIndex(pParse,0,0,X,R,0,0);}
tcons ::= CHECK expr onconf.
tcons ::= FOREIGN KEY LP idxlist(FA) RP
REFERENCES nm(T) idxlist_opt(TA) refargs(R) defer_subclause_opt(D). {
sqliteCreateForeignKey(pParse, FA, &T, TA, R);
sqliteDeferForeignKey(pParse, D);
sqlite3CreateForeignKey(pParse, FA, &T, TA, R);
sqlite3DeferForeignKey(pParse, D);
}
%type defer_subclause_opt {int}
defer_subclause_opt(A) ::= . {A = 0;}
@@ -264,28 +264,28 @@ resolvetype(A) ::= REPLACE. { A = OE_Replace; }
////////////////////////// The DROP TABLE /////////////////////////////////////
//
cmd ::= DROP TABLE nm(X). {sqliteDropTable(pParse,&X,0);}
cmd ::= DROP TABLE nm(X). {sqlite3DropTable(pParse,&X,0);}
///////////////////// The CREATE VIEW statement /////////////////////////////
//
cmd ::= CREATE(X) temp(T) VIEW nm(Y) AS select(S). {
sqliteCreateView(pParse, &X, &Y, S, T);
sqlite3CreateView(pParse, &X, &Y, S, T);
}
cmd ::= DROP VIEW nm(X). {
sqliteDropTable(pParse, &X, 1);
sqlite3DropTable(pParse, &X, 1);
}
//////////////////////// The SELECT statement /////////////////////////////////
//
cmd ::= select(X). {
sqliteSelect(pParse, X, SRT_Callback, 0, 0, 0, 0);
sqliteSelectDelete(X);
sqlite3Select(pParse, X, SRT_Callback, 0, 0, 0, 0);
sqlite3SelectDelete(X);
}
%type select {Select*}
%destructor select {sqliteSelectDelete($$);}
%destructor select {sqlite3SelectDelete($$);}
%type oneselect {Select*}
%destructor oneselect {sqliteSelectDelete($$);}
%destructor oneselect {sqlite3SelectDelete($$);}
select(A) ::= oneselect(X). {A = X;}
select(A) ::= select(X) multiselect_op(Y) oneselect(Z). {
@@ -302,7 +302,7 @@ multiselect_op(A) ::= INTERSECT. {A = TK_INTERSECT;}
multiselect_op(A) ::= EXCEPT. {A = TK_EXCEPT;}
oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y)
groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {
A = sqliteSelectNew(W,X,Y,P,Q,Z,D,L.limit,L.offset);
A = sqlite3SelectNew(W,X,Y,P,Q,Z,D,L.limit,L.offset);
}
// The "distinct" nonterminal is true (1) if the DISTINCT keyword is
@@ -319,21 +319,21 @@ distinct(A) ::= . {A = 0;}
// opcode of TK_ALL.
//
%type selcollist {ExprList*}
%destructor selcollist {sqliteExprListDelete($$);}
%destructor selcollist {sqlite3ExprListDelete($$);}
%type sclp {ExprList*}
%destructor sclp {sqliteExprListDelete($$);}
%destructor sclp {sqlite3ExprListDelete($$);}
sclp(A) ::= selcollist(X) COMMA. {A = X;}
sclp(A) ::= . {A = 0;}
selcollist(A) ::= sclp(P) expr(X) as(Y). {
A = sqliteExprListAppend(P,X,Y.n?&Y:0);
A = sqlite3ExprListAppend(P,X,Y.n?&Y:0);
}
selcollist(A) ::= sclp(P) STAR. {
A = sqliteExprListAppend(P, sqliteExpr(TK_ALL, 0, 0, 0), 0);
A = sqlite3ExprListAppend(P, sqlite3Expr(TK_ALL, 0, 0, 0), 0);
}
selcollist(A) ::= sclp(P) nm(X) DOT STAR. {
Expr *pRight = sqliteExpr(TK_ALL, 0, 0, 0);
Expr *pLeft = sqliteExpr(TK_ID, 0, 0, &X);
A = sqliteExprListAppend(P, sqliteExpr(TK_DOT, pLeft, pRight, 0), 0);
Expr *pRight = sqlite3Expr(TK_ALL, 0, 0, 0);
Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, &X);
A = sqlite3ExprListAppend(P, sqlite3Expr(TK_DOT, pLeft, pRight, 0), 0);
}
// An option "AS <id>" phrase that can follow one of the expressions that
@@ -346,11 +346,11 @@ as(X) ::= . { X.n = 0; }
%type seltablist {SrcList*}
%destructor seltablist {sqliteSrcListDelete($$);}
%destructor seltablist {sqlite3SrcListDelete($$);}
%type stl_prefix {SrcList*}
%destructor stl_prefix {sqliteSrcListDelete($$);}
%destructor stl_prefix {sqlite3SrcListDelete($$);}
%type from {SrcList*}
%destructor from {sqliteSrcListDelete($$);}
%destructor from {sqlite3SrcListDelete($$);}
// A complete FROM clause.
//
@@ -366,29 +366,29 @@ stl_prefix(A) ::= seltablist(X) joinop(Y). {
}
stl_prefix(A) ::= . {A = 0;}
seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) on_opt(N) using_opt(U). {
A = sqliteSrcListAppend(X,&Y,&D);
if( Z.n ) sqliteSrcListAddAlias(A,&Z);
A = sqlite3SrcListAppend(X,&Y,&D);
if( Z.n ) sqlite3SrcListAddAlias(A,&Z);
if( N ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; }
else { sqliteExprDelete(N); }
else { sqlite3ExprDelete(N); }
}
if( U ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; }
else { sqliteIdListDelete(U); }
else { sqlite3IdListDelete(U); }
}
}
seltablist(A) ::= stl_prefix(X) LP seltablist_paren(S) RP
as(Z) on_opt(N) using_opt(U). {
A = sqliteSrcListAppend(X,0,0);
A = sqlite3SrcListAppend(X,0,0);
A->a[A->nSrc-1].pSelect = S;
if( Z.n ) sqliteSrcListAddAlias(A,&Z);
if( Z.n ) sqlite3SrcListAddAlias(A,&Z);
if( N ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; }
else { sqliteExprDelete(N); }
else { sqlite3ExprDelete(N); }
}
if( U ){
if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; }
else { sqliteIdListDelete(U); }
else { sqlite3IdListDelete(U); }
}
}
@@ -397,10 +397,10 @@ seltablist(A) ::= stl_prefix(X) LP seltablist_paren(S) RP
// a grouping of table and subqueries.
//
%type seltablist_paren {Select*}
%destructor seltablist_paren {sqliteSelectDelete($$);}
%destructor seltablist_paren {sqlite3SelectDelete($$);}
seltablist_paren(A) ::= select(S). {A = S;}
seltablist_paren(A) ::= seltablist(F). {
A = sqliteSelectNew(0,F,0,0,0,0,0,-1,0);
A = sqlite3SelectNew(0,F,0,0,0,0,0,-1,0);
}
%type dbnm {Token}
@@ -411,37 +411,37 @@ dbnm(A) ::= DOT nm(X). {A = X;}
%type joinop2 {int}
joinop(X) ::= COMMA. { X = JT_INNER; }
joinop(X) ::= JOIN. { X = JT_INNER; }
joinop(X) ::= JOIN_KW(A) JOIN. { X = sqliteJoinType(pParse,&A,0,0); }
joinop(X) ::= JOIN_KW(A) nm(B) JOIN. { X = sqliteJoinType(pParse,&A,&B,0); }
joinop(X) ::= JOIN_KW(A) JOIN. { X = sqlite3JoinType(pParse,&A,0,0); }
joinop(X) ::= JOIN_KW(A) nm(B) JOIN. { X = sqlite3JoinType(pParse,&A,&B,0); }
joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN.
{ X = sqliteJoinType(pParse,&A,&B,&C); }
{ X = sqlite3JoinType(pParse,&A,&B,&C); }
%type on_opt {Expr*}
%destructor on_opt {sqliteExprDelete($$);}
%destructor on_opt {sqlite3ExprDelete($$);}
on_opt(N) ::= ON expr(E). {N = E;}
on_opt(N) ::= . {N = 0;}
%type using_opt {IdList*}
%destructor using_opt {sqliteIdListDelete($$);}
%destructor using_opt {sqlite3IdListDelete($$);}
using_opt(U) ::= USING LP idxlist(L) RP. {U = L;}
using_opt(U) ::= . {U = 0;}
%type orderby_opt {ExprList*}
%destructor orderby_opt {sqliteExprListDelete($$);}
%destructor orderby_opt {sqlite3ExprListDelete($$);}
%type sortlist {ExprList*}
%destructor sortlist {sqliteExprListDelete($$);}
%destructor sortlist {sqlite3ExprListDelete($$);}
%type sortitem {Expr*}
%destructor sortitem {sqliteExprDelete($$);}
%destructor sortitem {sqlite3ExprDelete($$);}
orderby_opt(A) ::= . {A = 0;}
orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
sortlist(A) ::= sortlist(X) COMMA sortitem(Y) collate(C) sortorder(Z). {
A = sqliteExprListAppend(X,Y,0);
A = sqlite3ExprListAppend(X,Y,0);
if( A ) A->a[A->nExpr-1].sortOrder = C+Z;
}
sortlist(A) ::= sortitem(Y) collate(C) sortorder(Z). {
A = sqliteExprListAppend(0,Y,0);
A = sqlite3ExprListAppend(0,Y,0);
if( A ) A->a[0].sortOrder = C+Z;
}
sortitem(A) ::= expr(X). {A = X;}
@@ -453,15 +453,15 @@ sortorder(A) ::= ASC. {A = SQLITE_SO_ASC;}
sortorder(A) ::= DESC. {A = SQLITE_SO_DESC;}
sortorder(A) ::= . {A = SQLITE_SO_ASC;}
collate(C) ::= . {C = SQLITE_SO_UNK;}
collate(C) ::= COLLATE id(X). {C = sqliteCollateType(X.z, X.n);}
collate(C) ::= COLLATE id(X). {C = sqlite3CollateType(X.z, X.n);}
%type groupby_opt {ExprList*}
%destructor groupby_opt {sqliteExprListDelete($$);}
%destructor groupby_opt {sqlite3ExprListDelete($$);}
groupby_opt(A) ::= . {A = 0;}
groupby_opt(A) ::= GROUP BY exprlist(X). {A = X;}
%type having_opt {Expr*}
%destructor having_opt {sqliteExprDelete($$);}
%destructor having_opt {sqlite3ExprDelete($$);}
having_opt(A) ::= . {A = 0;}
having_opt(A) ::= HAVING expr(X). {A = X;}
@@ -476,34 +476,34 @@ limit_opt(A) ::= LIMIT signed(X) COMMA signed(Y).
/////////////////////////// The DELETE statement /////////////////////////////
//
cmd ::= DELETE FROM nm(X) dbnm(D) where_opt(Y). {
sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&X,&D), Y);
sqlite3DeleteFrom(pParse, sqlite3SrcListAppend(0,&X,&D), Y);
}
%type where_opt {Expr*}
%destructor where_opt {sqliteExprDelete($$);}
%destructor where_opt {sqlite3ExprDelete($$);}
where_opt(A) ::= . {A = 0;}
where_opt(A) ::= WHERE expr(X). {A = X;}
%type setlist {ExprList*}
%destructor setlist {sqliteExprListDelete($$);}
%destructor setlist {sqlite3ExprListDelete($$);}
////////////////////////// The UPDATE command ////////////////////////////////
//
cmd ::= UPDATE orconf(R) nm(X) dbnm(D) SET setlist(Y) where_opt(Z).
{sqliteUpdate(pParse,sqliteSrcListAppend(0,&X,&D),Y,Z,R);}
{sqlite3Update(pParse,sqlite3SrcListAppend(0,&X,&D),Y,Z,R);}
setlist(A) ::= setlist(Z) COMMA nm(X) EQ expr(Y).
{A = sqliteExprListAppend(Z,Y,&X);}
setlist(A) ::= nm(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);}
{A = sqlite3ExprListAppend(Z,Y,&X);}
setlist(A) ::= nm(X) EQ expr(Y). {A = sqlite3ExprListAppend(0,Y,&X);}
////////////////////////// The INSERT command /////////////////////////////////
//
cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F)
VALUES LP itemlist(Y) RP.
{sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), Y, 0, F, R);}
{sqlite3Insert(pParse, sqlite3SrcListAppend(0,&X,&D), Y, 0, F, R);}
cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) select(S).
{sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), 0, S, F, R);}
{sqlite3Insert(pParse, sqlite3SrcListAppend(0,&X,&D), 0, S, F, R);}
%type insert_cmd {int}
insert_cmd(A) ::= INSERT orconf(R). {A = R;}
@@ -511,202 +511,202 @@ insert_cmd(A) ::= REPLACE. {A = OE_Replace;}
%type itemlist {ExprList*}
%destructor itemlist {sqliteExprListDelete($$);}
%destructor itemlist {sqlite3ExprListDelete($$);}
itemlist(A) ::= itemlist(X) COMMA expr(Y). {A = sqliteExprListAppend(X,Y,0);}
itemlist(A) ::= expr(X). {A = sqliteExprListAppend(0,X,0);}
itemlist(A) ::= itemlist(X) COMMA expr(Y). {A = sqlite3ExprListAppend(X,Y,0);}
itemlist(A) ::= expr(X). {A = sqlite3ExprListAppend(0,X,0);}
%type inscollist_opt {IdList*}
%destructor inscollist_opt {sqliteIdListDelete($$);}
%destructor inscollist_opt {sqlite3IdListDelete($$);}
%type inscollist {IdList*}
%destructor inscollist {sqliteIdListDelete($$);}
%destructor inscollist {sqlite3IdListDelete($$);}
inscollist_opt(A) ::= . {A = 0;}
inscollist_opt(A) ::= LP inscollist(X) RP. {A = X;}
inscollist(A) ::= inscollist(X) COMMA nm(Y). {A = sqliteIdListAppend(X,&Y);}
inscollist(A) ::= nm(Y). {A = sqliteIdListAppend(0,&Y);}
inscollist(A) ::= inscollist(X) COMMA nm(Y). {A = sqlite3IdListAppend(X,&Y);}
inscollist(A) ::= nm(Y). {A = sqlite3IdListAppend(0,&Y);}
/////////////////////////// Expression Processing /////////////////////////////
//
%type expr {Expr*}
%destructor expr {sqliteExprDelete($$);}
%destructor expr {sqlite3ExprDelete($$);}
expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqliteExprSpan(A,&B,&E); }
expr(A) ::= NULL(X). {A = sqliteExpr(TK_NULL, 0, 0, &X);}
expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
expr(A) ::= JOIN_KW(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqlite3ExprSpan(A,&B,&E); }
expr(A) ::= NULL(X). {A = sqlite3Expr(TK_NULL, 0, 0, &X);}
expr(A) ::= ID(X). {A = sqlite3Expr(TK_ID, 0, 0, &X);}
expr(A) ::= JOIN_KW(X). {A = sqlite3Expr(TK_ID, 0, 0, &X);}
expr(A) ::= nm(X) DOT nm(Y). {
Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
A = sqliteExpr(TK_DOT, temp1, temp2, 0);
Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &X);
Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &Y);
A = sqlite3Expr(TK_DOT, temp1, temp2, 0);
}
expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {
Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
Expr *temp3 = sqliteExpr(TK_ID, 0, 0, &Z);
Expr *temp4 = sqliteExpr(TK_DOT, temp2, temp3, 0);
A = sqliteExpr(TK_DOT, temp1, temp4, 0);
Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &X);
Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &Y);
Expr *temp3 = sqlite3Expr(TK_ID, 0, 0, &Z);
Expr *temp4 = sqlite3Expr(TK_DOT, temp2, temp3, 0);
A = sqlite3Expr(TK_DOT, temp1, temp4, 0);
}
expr(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
expr(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
expr(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
expr(A) ::= INTEGER(X). {A = sqlite3Expr(TK_INTEGER, 0, 0, &X);}
expr(A) ::= FLOAT(X). {A = sqlite3Expr(TK_FLOAT, 0, 0, &X);}
expr(A) ::= STRING(X). {A = sqlite3Expr(TK_STRING, 0, 0, &X);}
expr(A) ::= VARIABLE(X). {
A = sqliteExpr(TK_VARIABLE, 0, 0, &X);
A = sqlite3Expr(TK_VARIABLE, 0, 0, &X);
if( A ) A->iTable = ++pParse->nVar;
}
expr(A) ::= ID(X) LP exprlist(Y) RP(E). {
A = sqliteExprFunction(Y, &X);
sqliteExprSpan(A,&X,&E);
A = sqlite3ExprFunction(Y, &X);
sqlite3ExprSpan(A,&X,&E);
}
expr(A) ::= ID(X) LP STAR RP(E). {
A = sqliteExprFunction(0, &X);
sqliteExprSpan(A,&X,&E);
A = sqlite3ExprFunction(0, &X);
sqlite3ExprSpan(A,&X,&E);
}
expr(A) ::= expr(X) AND expr(Y). {A = sqliteExpr(TK_AND, X, Y, 0);}
expr(A) ::= expr(X) OR expr(Y). {A = sqliteExpr(TK_OR, X, Y, 0);}
expr(A) ::= expr(X) LT expr(Y). {A = sqliteExpr(TK_LT, X, Y, 0);}
expr(A) ::= expr(X) GT expr(Y). {A = sqliteExpr(TK_GT, X, Y, 0);}
expr(A) ::= expr(X) LE expr(Y). {A = sqliteExpr(TK_LE, X, Y, 0);}
expr(A) ::= expr(X) GE expr(Y). {A = sqliteExpr(TK_GE, X, Y, 0);}
expr(A) ::= expr(X) NE expr(Y). {A = sqliteExpr(TK_NE, X, Y, 0);}
expr(A) ::= expr(X) EQ expr(Y). {A = sqliteExpr(TK_EQ, X, Y, 0);}
expr(A) ::= expr(X) BITAND expr(Y). {A = sqliteExpr(TK_BITAND, X, Y, 0);}
expr(A) ::= expr(X) BITOR expr(Y). {A = sqliteExpr(TK_BITOR, X, Y, 0);}
expr(A) ::= expr(X) LSHIFT expr(Y). {A = sqliteExpr(TK_LSHIFT, X, Y, 0);}
expr(A) ::= expr(X) RSHIFT expr(Y). {A = sqliteExpr(TK_RSHIFT, X, Y, 0);}
expr(A) ::= expr(X) AND expr(Y). {A = sqlite3Expr(TK_AND, X, Y, 0);}
expr(A) ::= expr(X) OR expr(Y). {A = sqlite3Expr(TK_OR, X, Y, 0);}
expr(A) ::= expr(X) LT expr(Y). {A = sqlite3Expr(TK_LT, X, Y, 0);}
expr(A) ::= expr(X) GT expr(Y). {A = sqlite3Expr(TK_GT, X, Y, 0);}
expr(A) ::= expr(X) LE expr(Y). {A = sqlite3Expr(TK_LE, X, Y, 0);}
expr(A) ::= expr(X) GE expr(Y). {A = sqlite3Expr(TK_GE, X, Y, 0);}
expr(A) ::= expr(X) NE expr(Y). {A = sqlite3Expr(TK_NE, X, Y, 0);}
expr(A) ::= expr(X) EQ expr(Y). {A = sqlite3Expr(TK_EQ, X, Y, 0);}
expr(A) ::= expr(X) BITAND expr(Y). {A = sqlite3Expr(TK_BITAND, X, Y, 0);}
expr(A) ::= expr(X) BITOR expr(Y). {A = sqlite3Expr(TK_BITOR, X, Y, 0);}
expr(A) ::= expr(X) LSHIFT expr(Y). {A = sqlite3Expr(TK_LSHIFT, X, Y, 0);}
expr(A) ::= expr(X) RSHIFT expr(Y). {A = sqlite3Expr(TK_RSHIFT, X, Y, 0);}
expr(A) ::= expr(X) likeop(OP) expr(Y). [LIKE] {
ExprList *pList = sqliteExprListAppend(0, Y, 0);
pList = sqliteExprListAppend(pList, X, 0);
A = sqliteExprFunction(pList, 0);
ExprList *pList = sqlite3ExprListAppend(0, Y, 0);
pList = sqlite3ExprListAppend(pList, X, 0);
A = sqlite3ExprFunction(pList, 0);
if( A ) A->op = OP;
sqliteExprSpan(A, &X->span, &Y->span);
sqlite3ExprSpan(A, &X->span, &Y->span);
}
expr(A) ::= expr(X) NOT likeop(OP) expr(Y). [LIKE] {
ExprList *pList = sqliteExprListAppend(0, Y, 0);
pList = sqliteExprListAppend(pList, X, 0);
A = sqliteExprFunction(pList, 0);
ExprList *pList = sqlite3ExprListAppend(0, Y, 0);
pList = sqlite3ExprListAppend(pList, X, 0);
A = sqlite3ExprFunction(pList, 0);
if( A ) A->op = OP;
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,&Y->span);
A = sqlite3Expr(TK_NOT, A, 0, 0);
sqlite3ExprSpan(A,&X->span,&Y->span);
}
%type likeop {int}
likeop(A) ::= LIKE. {A = TK_LIKE;}
likeop(A) ::= GLOB. {A = TK_GLOB;}
expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);}
expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);}
expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);}
expr(A) ::= expr(X) SLASH expr(Y). {A = sqliteExpr(TK_SLASH, X, Y, 0);}
expr(A) ::= expr(X) REM expr(Y). {A = sqliteExpr(TK_REM, X, Y, 0);}
expr(A) ::= expr(X) CONCAT expr(Y). {A = sqliteExpr(TK_CONCAT, X, Y, 0);}
expr(A) ::= expr(X) PLUS expr(Y). {A = sqlite3Expr(TK_PLUS, X, Y, 0);}
expr(A) ::= expr(X) MINUS expr(Y). {A = sqlite3Expr(TK_MINUS, X, Y, 0);}
expr(A) ::= expr(X) STAR expr(Y). {A = sqlite3Expr(TK_STAR, X, Y, 0);}
expr(A) ::= expr(X) SLASH expr(Y). {A = sqlite3Expr(TK_SLASH, X, Y, 0);}
expr(A) ::= expr(X) REM expr(Y). {A = sqlite3Expr(TK_REM, X, Y, 0);}
expr(A) ::= expr(X) CONCAT expr(Y). {A = sqlite3Expr(TK_CONCAT, X, Y, 0);}
expr(A) ::= expr(X) ISNULL(E). {
A = sqliteExpr(TK_ISNULL, X, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_ISNULL, X, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) IS NULL(E). {
A = sqliteExpr(TK_ISNULL, X, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_ISNULL, X, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) NOTNULL(E). {
A = sqliteExpr(TK_NOTNULL, X, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_NOTNULL, X, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) NOT NULL(E). {
A = sqliteExpr(TK_NOTNULL, X, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_NOTNULL, X, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) IS NOT NULL(E). {
A = sqliteExpr(TK_NOTNULL, X, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_NOTNULL, X, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= NOT(B) expr(X). {
A = sqliteExpr(TK_NOT, X, 0, 0);
sqliteExprSpan(A,&B,&X->span);
A = sqlite3Expr(TK_NOT, X, 0, 0);
sqlite3ExprSpan(A,&B,&X->span);
}
expr(A) ::= BITNOT(B) expr(X). {
A = sqliteExpr(TK_BITNOT, X, 0, 0);
sqliteExprSpan(A,&B,&X->span);
A = sqlite3Expr(TK_BITNOT, X, 0, 0);
sqlite3ExprSpan(A,&B,&X->span);
}
expr(A) ::= MINUS(B) expr(X). [UMINUS] {
A = sqliteExpr(TK_UMINUS, X, 0, 0);
sqliteExprSpan(A,&B,&X->span);
A = sqlite3Expr(TK_UMINUS, X, 0, 0);
sqlite3ExprSpan(A,&B,&X->span);
}
expr(A) ::= PLUS(B) expr(X). [UPLUS] {
A = sqliteExpr(TK_UPLUS, X, 0, 0);
sqliteExprSpan(A,&B,&X->span);
A = sqlite3Expr(TK_UPLUS, X, 0, 0);
sqlite3ExprSpan(A,&B,&X->span);
}
expr(A) ::= LP(B) select(X) RP(E). {
A = sqliteExpr(TK_SELECT, 0, 0, 0);
A = sqlite3Expr(TK_SELECT, 0, 0, 0);
if( A ) A->pSelect = X;
sqliteExprSpan(A,&B,&E);
sqlite3ExprSpan(A,&B,&E);
}
expr(A) ::= expr(W) BETWEEN expr(X) AND expr(Y). {
ExprList *pList = sqliteExprListAppend(0, X, 0);
pList = sqliteExprListAppend(pList, Y, 0);
A = sqliteExpr(TK_BETWEEN, W, 0, 0);
ExprList *pList = sqlite3ExprListAppend(0, X, 0);
pList = sqlite3ExprListAppend(pList, Y, 0);
A = sqlite3Expr(TK_BETWEEN, W, 0, 0);
if( A ) A->pList = pList;
sqliteExprSpan(A,&W->span,&Y->span);
sqlite3ExprSpan(A,&W->span,&Y->span);
}
expr(A) ::= expr(W) NOT BETWEEN expr(X) AND expr(Y). {
ExprList *pList = sqliteExprListAppend(0, X, 0);
pList = sqliteExprListAppend(pList, Y, 0);
A = sqliteExpr(TK_BETWEEN, W, 0, 0);
ExprList *pList = sqlite3ExprListAppend(0, X, 0);
pList = sqlite3ExprListAppend(pList, Y, 0);
A = sqlite3Expr(TK_BETWEEN, W, 0, 0);
if( A ) A->pList = pList;
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&W->span,&Y->span);
A = sqlite3Expr(TK_NOT, A, 0, 0);
sqlite3ExprSpan(A,&W->span,&Y->span);
}
expr(A) ::= expr(X) IN LP exprlist(Y) RP(E). {
A = sqliteExpr(TK_IN, X, 0, 0);
A = sqlite3Expr(TK_IN, X, 0, 0);
if( A ) A->pList = Y;
sqliteExprSpan(A,&X->span,&E);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) IN LP select(Y) RP(E). {
A = sqliteExpr(TK_IN, X, 0, 0);
A = sqlite3Expr(TK_IN, X, 0, 0);
if( A ) A->pSelect = Y;
sqliteExprSpan(A,&X->span,&E);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) NOT IN LP exprlist(Y) RP(E). {
A = sqliteExpr(TK_IN, X, 0, 0);
A = sqlite3Expr(TK_IN, X, 0, 0);
if( A ) A->pList = Y;
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_NOT, A, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) NOT IN LP select(Y) RP(E). {
A = sqliteExpr(TK_IN, X, 0, 0);
A = sqlite3Expr(TK_IN, X, 0, 0);
if( A ) A->pSelect = Y;
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,&E);
A = sqlite3Expr(TK_NOT, A, 0, 0);
sqlite3ExprSpan(A,&X->span,&E);
}
expr(A) ::= expr(X) IN nm(Y) dbnm(D). {
SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
A = sqliteExpr(TK_IN, X, 0, 0);
if( A ) A->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0);
sqliteExprSpan(A,&X->span,D.z?&D:&Y);
SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D);
A = sqlite3Expr(TK_IN, X, 0, 0);
if( A ) A->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,-1,0);
sqlite3ExprSpan(A,&X->span,D.z?&D:&Y);
}
expr(A) ::= expr(X) NOT IN nm(Y) dbnm(D). {
SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
A = sqliteExpr(TK_IN, X, 0, 0);
if( A ) A->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0);
A = sqliteExpr(TK_NOT, A, 0, 0);
sqliteExprSpan(A,&X->span,D.z?&D:&Y);
SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D);
A = sqlite3Expr(TK_IN, X, 0, 0);
if( A ) A->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,-1,0);
A = sqlite3Expr(TK_NOT, A, 0, 0);
sqlite3ExprSpan(A,&X->span,D.z?&D:&Y);
}
/* CASE expressions */
expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
A = sqliteExpr(TK_CASE, X, Z, 0);
A = sqlite3Expr(TK_CASE, X, Z, 0);
if( A ) A->pList = Y;
sqliteExprSpan(A, &C, &E);
sqlite3ExprSpan(A, &C, &E);
}
%type case_exprlist {ExprList*}
%destructor case_exprlist {sqliteExprListDelete($$);}
%destructor case_exprlist {sqlite3ExprListDelete($$);}
case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
A = sqliteExprListAppend(X, Y, 0);
A = sqliteExprListAppend(A, Z, 0);
A = sqlite3ExprListAppend(X, Y, 0);
A = sqlite3ExprListAppend(A, Z, 0);
}
case_exprlist(A) ::= WHEN expr(Y) THEN expr(Z). {
A = sqliteExprListAppend(0, Y, 0);
A = sqliteExprListAppend(A, Z, 0);
A = sqlite3ExprListAppend(0, Y, 0);
A = sqlite3ExprListAppend(A, Z, 0);
}
%type case_else {Expr*}
case_else(A) ::= ELSE expr(X). {A = X;}
@@ -716,13 +716,13 @@ case_operand(A) ::= expr(X). {A = X;}
case_operand(A) ::= . {A = 0;}
%type exprlist {ExprList*}
%destructor exprlist {sqliteExprListDelete($$);}
%destructor exprlist {sqlite3ExprListDelete($$);}
%type expritem {Expr*}
%destructor expritem {sqliteExprDelete($$);}
%destructor expritem {sqlite3ExprDelete($$);}
exprlist(A) ::= exprlist(X) COMMA expritem(Y).
{A = sqliteExprListAppend(X,Y,0);}
exprlist(A) ::= expritem(X). {A = sqliteExprListAppend(0,X,0);}
{A = sqlite3ExprListAppend(X,Y,0);}
exprlist(A) ::= expritem(X). {A = sqlite3ExprListAppend(0,X,0);}
expritem(A) ::= expr(X). {A = X;}
expritem(A) ::= . {A = 0;}
@@ -730,10 +730,10 @@ expritem(A) ::= . {A = 0;}
//
cmd ::= CREATE(S) uniqueflag(U) INDEX nm(X)
ON nm(Y) dbnm(D) LP idxlist(Z) RP(E) onconf(R). {
SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D);
if( U!=OE_None ) U = R;
if( U==OE_Default) U = OE_Abort;
sqliteCreateIndex(pParse, &X, pSrc, Z, U, &S, &E);
sqlite3CreateIndex(pParse, &X, pSrc, Z, U, &S, &E);
}
%type uniqueflag {int}
@@ -741,45 +741,45 @@ uniqueflag(A) ::= UNIQUE. { A = OE_Abort; }
uniqueflag(A) ::= . { A = OE_None; }
%type idxlist {IdList*}
%destructor idxlist {sqliteIdListDelete($$);}
%destructor idxlist {sqlite3IdListDelete($$);}
%type idxlist_opt {IdList*}
%destructor idxlist_opt {sqliteIdListDelete($$);}
%destructor idxlist_opt {sqlite3IdListDelete($$);}
%type idxitem {Token}
idxlist_opt(A) ::= . {A = 0;}
idxlist_opt(A) ::= LP idxlist(X) RP. {A = X;}
idxlist(A) ::= idxlist(X) COMMA idxitem(Y). {A = sqliteIdListAppend(X,&Y);}
idxlist(A) ::= idxitem(Y). {A = sqliteIdListAppend(0,&Y);}
idxlist(A) ::= idxlist(X) COMMA idxitem(Y). {A = sqlite3IdListAppend(X,&Y);}
idxlist(A) ::= idxitem(Y). {A = sqlite3IdListAppend(0,&Y);}
idxitem(A) ::= nm(X) sortorder. {A = X;}
///////////////////////////// The DROP INDEX command /////////////////////////
//
cmd ::= DROP INDEX nm(X) dbnm(Y). {
sqliteDropIndex(pParse, sqliteSrcListAppend(0,&X,&Y));
sqlite3DropIndex(pParse, sqlite3SrcListAppend(0,&X,&Y));
}
///////////////////////////// The COPY command ///////////////////////////////
//
cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y) USING DELIMITERS STRING(Z).
{sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,&Z,R);}
{sqlite3Copy(pParse,sqlite3SrcListAppend(0,&X,&D),&Y,&Z,R);}
cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y).
{sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,0,R);}
{sqlite3Copy(pParse,sqlite3SrcListAppend(0,&X,&D),&Y,0,R);}
///////////////////////////// The VACUUM command /////////////////////////////
//
cmd ::= VACUUM. {sqliteVacuum(pParse,0);}
cmd ::= VACUUM nm(X). {sqliteVacuum(pParse,&X);}
cmd ::= VACUUM. {sqlite3Vacuum(pParse,0);}
cmd ::= VACUUM nm(X). {sqlite3Vacuum(pParse,&X);}
///////////////////////////// The PRAGMA command /////////////////////////////
//
cmd ::= PRAGMA ids(X) EQ nm(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ ON(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ plus_num(Y). {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ minus_num(Y). {sqlitePragma(pParse,&X,&Y,1);}
cmd ::= PRAGMA ids(X) LP nm(Y) RP. {sqlitePragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X). {sqlitePragma(pParse,&X,&X,0);}
cmd ::= PRAGMA ids(X) EQ nm(Y). {sqlite3Pragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ ON(Y). {sqlite3Pragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ plus_num(Y). {sqlite3Pragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X) EQ minus_num(Y). {sqlite3Pragma(pParse,&X,&Y,1);}
cmd ::= PRAGMA ids(X) LP nm(Y) RP. {sqlite3Pragma(pParse,&X,&Y,0);}
cmd ::= PRAGMA ids(X). {sqlite3Pragma(pParse,&X,&X,0);}
plus_num(A) ::= plus_opt number(X). {A = X;}
minus_num(A) ::= MINUS number(X). {A = X;}
number(A) ::= INTEGER(X). {A = X;}
@@ -793,13 +793,13 @@ cmd ::= CREATE(A) trigger_decl BEGIN trigger_cmd_list(S) END(Z). {
Token all;
all.z = A.z;
all.n = (Z.z - A.z) + Z.n;
sqliteFinishTrigger(pParse, S, &all);
sqlite3FinishTrigger(pParse, S, &all);
}
trigger_decl ::= temp(T) TRIGGER nm(B) trigger_time(C) trigger_event(D)
ON nm(E) dbnm(DB) foreach_clause(F) when_clause(G). {
SrcList *pTab = sqliteSrcListAppend(0, &E, &DB);
sqliteBeginTrigger(pParse, &B, C, D.a, D.b, pTab, F, G, T);
SrcList *pTab = sqlite3SrcListAppend(0, &E, &DB);
sqlite3BeginTrigger(pParse, &B, C, D.a, D.b, pTab, F, G, T);
}
%type trigger_time {int}
@@ -809,7 +809,7 @@ trigger_time(A) ::= INSTEAD OF. { A = TK_INSTEAD;}
trigger_time(A) ::= . { A = TK_BEFORE; }
%type trigger_event {struct TrigEvent}
%destructor trigger_event {sqliteIdListDelete($$.b);}
%destructor trigger_event {sqlite3IdListDelete($$.b);}
trigger_event(A) ::= DELETE. { A.a = TK_DELETE; A.b = 0; }
trigger_event(A) ::= INSERT. { A.a = TK_INSERT; A.b = 0; }
trigger_event(A) ::= UPDATE. { A.a = TK_UPDATE; A.b = 0;}
@@ -825,7 +825,7 @@ when_clause(A) ::= . { A = 0; }
when_clause(A) ::= WHEN expr(X). { A = X; }
%type trigger_cmd_list {TriggerStep *}
%destructor trigger_cmd_list {sqliteDeleteTriggerStep($$);}
%destructor trigger_cmd_list {sqlite3DeleteTriggerStep($$);}
trigger_cmd_list(A) ::= trigger_cmd(X) SEMI trigger_cmd_list(Y). {
X->pNext = Y;
A = X;
@@ -833,56 +833,56 @@ trigger_cmd_list(A) ::= trigger_cmd(X) SEMI trigger_cmd_list(Y). {
trigger_cmd_list(A) ::= . { A = 0; }
%type trigger_cmd {TriggerStep *}
%destructor trigger_cmd {sqliteDeleteTriggerStep($$);}
%destructor trigger_cmd {sqlite3DeleteTriggerStep($$);}
// UPDATE
trigger_cmd(A) ::= UPDATE orconf(R) nm(X) SET setlist(Y) where_opt(Z).
{ A = sqliteTriggerUpdateStep(&X, Y, Z, R); }
{ A = sqlite3TriggerUpdateStep(&X, Y, Z, R); }
// INSERT
trigger_cmd(A) ::= insert_cmd(R) INTO nm(X) inscollist_opt(F)
VALUES LP itemlist(Y) RP.
{A = sqliteTriggerInsertStep(&X, F, Y, 0, R);}
{A = sqlite3TriggerInsertStep(&X, F, Y, 0, R);}
trigger_cmd(A) ::= insert_cmd(R) INTO nm(X) inscollist_opt(F) select(S).
{A = sqliteTriggerInsertStep(&X, F, 0, S, R);}
{A = sqlite3TriggerInsertStep(&X, F, 0, S, R);}
// DELETE
trigger_cmd(A) ::= DELETE FROM nm(X) where_opt(Y).
{A = sqliteTriggerDeleteStep(&X, Y);}
{A = sqlite3TriggerDeleteStep(&X, Y);}
// SELECT
trigger_cmd(A) ::= select(X). {A = sqliteTriggerSelectStep(X); }
trigger_cmd(A) ::= select(X). {A = sqlite3TriggerSelectStep(X); }
// The special RAISE expression that may occur in trigger programs
expr(A) ::= RAISE(X) LP IGNORE RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, 0);
A = sqlite3Expr(TK_RAISE, 0, 0, 0);
A->iColumn = OE_Ignore;
sqliteExprSpan(A, &X, &Y);
sqlite3ExprSpan(A, &X, &Y);
}
expr(A) ::= RAISE(X) LP ROLLBACK COMMA nm(Z) RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, &Z);
A = sqlite3Expr(TK_RAISE, 0, 0, &Z);
A->iColumn = OE_Rollback;
sqliteExprSpan(A, &X, &Y);
sqlite3ExprSpan(A, &X, &Y);
}
expr(A) ::= RAISE(X) LP ABORT COMMA nm(Z) RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, &Z);
A = sqlite3Expr(TK_RAISE, 0, 0, &Z);
A->iColumn = OE_Abort;
sqliteExprSpan(A, &X, &Y);
sqlite3ExprSpan(A, &X, &Y);
}
expr(A) ::= RAISE(X) LP FAIL COMMA nm(Z) RP(Y). {
A = sqliteExpr(TK_RAISE, 0, 0, &Z);
A = sqlite3Expr(TK_RAISE, 0, 0, &Z);
A->iColumn = OE_Fail;
sqliteExprSpan(A, &X, &Y);
sqlite3ExprSpan(A, &X, &Y);
}
//////////////////////// DROP TRIGGER statement //////////////////////////////
cmd ::= DROP TRIGGER nm(X) dbnm(D). {
sqliteDropTrigger(pParse,sqliteSrcListAppend(0,&X,&D));
sqlite3DropTrigger(pParse,sqlite3SrcListAppend(0,&X,&D));
}
//////////////////////// ATTACH DATABASE file AS name /////////////////////////
cmd ::= ATTACH database_kw_opt ids(F) AS nm(D) key_opt(K). {
sqliteAttach(pParse, &F, &D, &K);
sqlite3Attach(pParse, &F, &D, &K);
}
%type key_opt {Token}
key_opt(A) ::= USING ids(X). { A = X; }
@@ -893,5 +893,8 @@ database_kw_opt ::= .
//////////////////////// DETACH DATABASE name /////////////////////////////////
cmd ::= DETACH database_kw_opt nm(D). {
sqliteDetach(pParse, &D);
sqlite3Detach(pParse, &D);
}