diff options
author | drh <drh@noemail.net> | 2002-01-22 14:11:29 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-01-22 14:11:29 +0000 |
commit | 9208643d2ad287d5274a2973769fa25f83934043 (patch) | |
tree | b7e6e1e80d3a22ee26ecc901a7481ad759eec4f2 /src/expr.c | |
parent | 7613bfae5636db4e5f4b386073deaa50b7acd11c (diff) | |
download | sqlite-9208643d2ad287d5274a2973769fa25f83934043.tar.gz sqlite-9208643d2ad287d5274a2973769fa25f83934043.zip |
Constant ORDER BY or GROUP BY expressions are an error. (CVS 352)
FossilOrigin-Name: 035984a5b00b4a1a6505405f40b15c7695283c0a
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/expr.c b/src/expr.c index 0a0113886..802c874bc 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.38 2002/01/22 03:13:42 drh Exp $ +** $Id: expr.c,v 1.39 2002/01/22 14:11:29 drh Exp $ */ #include "sqliteInt.h" @@ -35,25 +35,29 @@ void sqliteExprDelete(Expr *p){ ** Walk an expression tree. Return 1 if the expression is constant ** and 0 if it involves variables. */ -static int isConstant(Expr *p){ +int sqliteExprIsConstant(Expr *p){ switch( p->op ){ case TK_ID: case TK_COLUMN: case TK_DOT: return 0; + case TK_INTEGER: + case TK_FLOAT: + case TK_STRING: + return 1; default: { - if( p->pLeft && !isConstant(p->pLeft) ) return 0; - if( p->pRight && !isConstant(p->pRight) ) return 0; + if( p->pLeft && !sqliteExprIsConstant(p->pLeft) ) return 0; + if( p->pRight && !sqliteExprIsConstant(p->pRight) ) return 0; if( p->pList ){ int i; for(i=0; i<p->pList->nExpr; i++){ - if( !isConstant(p->pList->a[i].pExpr) ) return 0; + if( !sqliteExprIsConstant(p->pList->a[i].pExpr) ) return 0; } } - break; + return p->pLeft!=0 || p->pRight!=0 || (p->pList && p->pList->nExpr>0); } } - return 1; + return 0; } /* @@ -304,7 +308,7 @@ int sqliteExprResolveIds( int i, iSet; for(i=0; i<pExpr->pList->nExpr; i++){ Expr *pE2 = pExpr->pList->a[i].pExpr; - if( !isConstant(pE2) ){ + if( !sqliteExprIsConstant(pE2) ){ sqliteSetString(&pParse->zErrMsg, "right-hand side of IN operator must be constant", 0); pParse->nErr++; |