diff options
author | drh <drh@noemail.net> | 2002-02-18 13:56:36 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-02-18 13:56:36 +0000 |
commit | e64e7b203e965192fc69983d6ca6bd2c696f5c57 (patch) | |
tree | ca14aa76bd505fff0f43a2824466b8109e86246d /src | |
parent | cf9095061c8c13bd720c79396fcb5afb9b85a6c1 (diff) | |
download | sqlite-e64e7b203e965192fc69983d6ca6bd2c696f5c57.tar.gz sqlite-e64e7b203e965192fc69983d6ca6bd2c696f5c57.zip |
Allow general expressions in the VALUES clause of an INSERT statement. (CVS 376)
FossilOrigin-Name: ec1f3fae6f8cd8466892cd370e1802e492a76e6e
Diffstat (limited to 'src')
-rw-r--r-- | src/insert.c | 12 | ||||
-rw-r--r-- | src/parse.y | 24 |
2 files changed, 15 insertions, 21 deletions
diff --git a/src/insert.c b/src/insert.c index f993b89ea..aa49c4082 100644 --- a/src/insert.c +++ b/src/insert.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.42 2002/02/03 19:06:03 drh Exp $ +** $Id: insert.c,v 1.43 2002/02/18 13:56:37 drh Exp $ */ #include "sqliteInt.h" @@ -100,10 +100,20 @@ void sqliteInsert( assert( pSelect->pEList ); nColumn = pSelect->pEList->nExpr; }else{ + IdList dummy; assert( pList!=0 ); srcTab = -1; assert( pList ); nColumn = pList->nExpr; + for(i=0; i<nColumn; i++){ + sqliteExprResolveInSelect(pParse, pList->a[i].pExpr); + } + dummy.nId = 0; + for(i=0; i<nColumn; i++){ + if( sqliteExprResolveIds(pParse, &dummy, 0, pList->a[i].pExpr) ){ + goto insert_cleanup; + } + } } /* Make sure the number of columns in the source data matches the number diff --git a/src/parse.y b/src/parse.y index fc5180c73..8d71515be 100644 --- a/src/parse.y +++ b/src/parse.y @@ -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.49 2002/02/18 01:17:00 drh Exp $ +** @(#) $Id: parse.y,v 1.50 2002/02/18 13:56:37 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -347,25 +347,9 @@ insert_cmd(A) ::= REPLACE. {A = OE_Replace;} %type itemlist {ExprList*} %destructor itemlist {sqliteExprListDelete($$);} -%type item {Expr*} -%destructor item {sqliteExprDelete($$);} - -itemlist(A) ::= itemlist(X) COMMA item(Y). {A = sqliteExprListAppend(X,Y,0);} -itemlist(A) ::= item(X). {A = sqliteExprListAppend(0,X,0);} -item(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);} -item(A) ::= PLUS INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);} -item(A) ::= MINUS INTEGER(X). { - A = sqliteExpr(TK_UMINUS, 0, 0, 0); - if( A ) A->pLeft = sqliteExpr(TK_INTEGER, 0, 0, &X); -} -item(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);} -item(A) ::= PLUS FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);} -item(A) ::= MINUS FLOAT(X). { - A = sqliteExpr(TK_UMINUS, 0, 0, 0); - if( A ) A->pLeft = sqliteExpr(TK_FLOAT, 0, 0, &X); -} -item(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);} -item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);} + +itemlist(A) ::= itemlist(X) COMMA expr(Y). {A = sqliteExprListAppend(X,Y,0);} +itemlist(A) ::= expr(X). {A = sqliteExprListAppend(0,X,0);} %type inscollist_opt {IdList*} %destructor inscollist_opt {sqliteIdListDelete($$);} |