1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Allow general expressions in the VALUES clause of an INSERT statement. (CVS 376)

FossilOrigin-Name: ec1f3fae6f8cd8466892cd370e1802e492a76e6e
This commit is contained in:
drh
2002-02-18 13:56:36 +00:00
parent cf9095061c
commit e64e7b203e
6 changed files with 57 additions and 31 deletions

View File

@ -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

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.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($$);}