diff options
author | drh <drh@noemail.net> | 2007-05-14 11:34:46 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-05-14 11:34:46 +0000 |
commit | 4f07e5fbdf0fb0cde532ea39602bd1ba32d0c8ae (patch) | |
tree | 766db8d9ee1e4d0a9ebb8857102c28cbe85a9836 /src | |
parent | 84f31128b2d09479663df3597f83251cba59ab39 (diff) | |
download | sqlite-4f07e5fbdf0fb0cde532ea39602bd1ba32d0c8ae.tar.gz sqlite-4f07e5fbdf0fb0cde532ea39602bd1ba32d0c8ae.zip |
Remove terms with operator TK_AS from the expression tree. Ticket #2356. (CVS 3991)
FossilOrigin-Name: 5627ff74be9242418434a06fe5c104d1f9128cab
Diffstat (limited to 'src')
-rw-r--r-- | src/auth.c | 5 | ||||
-rw-r--r-- | src/expr.c | 27 | ||||
-rw-r--r-- | src/select.c | 8 |
3 files changed, 16 insertions, 24 deletions
diff --git a/src/auth.c b/src/auth.c index fe05a68af..79940c273 100644 --- a/src/auth.c +++ b/src/auth.c @@ -14,7 +14,7 @@ ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** -** $Id: auth.c,v 1.25 2006/06/16 08:01:03 danielk1977 Exp $ +** $Id: auth.c,v 1.26 2007/05/14 11:34:47 drh Exp $ */ #include "sqliteInt.h" @@ -115,8 +115,7 @@ void sqlite3AuthRead( int iDb; /* The index of the database the expression refers to */ if( db->xAuth==0 ) return; - if( pExpr->op==TK_AS ) return; - assert( pExpr->op==TK_COLUMN ); + if( pExpr->op!=TK_COLUMN ) return; iDb = sqlite3SchemaToIndex(pParse->db, pExpr->pSchema); if( iDb<0 ){ /* An attempt to read a column out of a subquery or other diff --git a/src/expr.c b/src/expr.c index 5ce30b475..cfc534660 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.292 2007/05/12 06:11:12 danielk1977 Exp $ +** $Id: expr.c,v 1.293 2007/05/14 11:34:47 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -35,9 +35,6 @@ */ char sqlite3ExprAffinity(Expr *pExpr){ int op = pExpr->op; - if( op==TK_AS ){ - return sqlite3ExprAffinity(pExpr->pLeft); - } if( op==TK_SELECT ){ return sqlite3ExprAffinity(pExpr->pSelect->pEList->a[0].pExpr); } @@ -75,7 +72,7 @@ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ CollSeq *pColl = 0; if( pExpr ){ pColl = pExpr->pColl; - if( (pExpr->op==TK_AS || pExpr->op==TK_CAST) && !pColl ){ + if( pExpr->op==TK_CAST && !pColl ){ return sqlite3ExprCollSeq(pParse, pExpr->pLeft); } } @@ -481,10 +478,6 @@ Expr *sqlite3ExprDup(Expr *p){ pNew->pRight = sqlite3ExprDup(p->pRight); pNew->pList = sqlite3ExprListDup(p->pList); pNew->pSelect = sqlite3SelectDup(p->pSelect); - pNew->pTab = p->pTab; -#if SQLITE_MAX_EXPR_DEPTH>0 - pNew->nHeight = p->nHeight; -#endif return pNew; } void sqlite3TokenCopy(Token *pTo, Token *pFrom){ @@ -1114,10 +1107,17 @@ static int lookupName( for(j=0; j<pEList->nExpr; j++){ char *zAs = pEList->a[j].zName; if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ + Expr *pDup; assert( pExpr->pLeft==0 && pExpr->pRight==0 ); - pExpr->op = TK_AS; - pExpr->iColumn = j; - pExpr->pLeft = sqlite3ExprDup(pEList->a[j].pExpr); + assert( pExpr->pList==0 ); + assert( pExpr->pSelect==0 ); + pDup = sqlite3ExprDup(pEList->a[j].pExpr); + if( pExpr->flags & EP_ExpCollate ){ + pDup->pColl = pExpr->pColl; + pDup->flags |= EP_ExpCollate; + } + memcpy(pExpr, pDup, sizeof(*pExpr)); + sqliteFree(pDup); cnt = 1; assert( zTab==0 && zDb==0 ); goto lookupname_end_2; @@ -1960,8 +1960,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){ sqlite3VdbeAddOp(v, OP_And, 0, 0); break; } - case TK_UPLUS: - case TK_AS: { + case TK_UPLUS: { sqlite3ExprCode(pParse, pExpr->pLeft); stackChng = 0; break; diff --git a/src/select.c b/src/select.c index dd8b81d82..686ecb192 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.344 2007/05/10 10:46:57 danielk1977 Exp $ +** $Id: select.c,v 1.345 2007/05/14 11:34:47 drh Exp $ */ #include "sqliteInt.h" @@ -822,12 +822,6 @@ static const char *columnType( int j; if( pExpr==0 || pNC->pSrcList==0 ) return 0; - /* The TK_AS operator can only occur in ORDER BY, GROUP BY, HAVING, - ** and LIMIT clauses. But pExpr originates in the result set of a - ** SELECT. So pExpr can never contain an AS operator. - */ - assert( pExpr->op!=TK_AS ); - switch( pExpr->op ){ case TK_AGG_COLUMN: case TK_COLUMN: { |