aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2012-08-23 19:46:11 +0000
committerdrh <drh@noemail.net>2012-08-23 19:46:11 +0000
commited551b95a4a0f71be84820b31d4c865eea294407 (patch)
tree28220c8c473987b81ba8242a43a4ec0b59c24044 /src/expr.c
parent030796df8d36a781ce062fad3fcb7312b8ac6a47 (diff)
downloadsqlite-ed551b95a4a0f71be84820b31d4c865eea294407.tar.gz
sqlite-ed551b95a4a0f71be84820b31d4c865eea294407.zip
Add test cases and fix bugs associated with the previous check-in
enhancements to nested aggregate subquery processing. FossilOrigin-Name: 00b1dc71be4c3420730b5f7840af824ea86165e7
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/expr.c b/src/expr.c
index e2f8b4578..9fe899402 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3123,9 +3123,12 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){
}else{
pFarg = pExpr->x.pList;
}
- sqlite3ExplainPrintf(pOut, "%sFUNCTION:%s(",
- op==TK_AGG_FUNCTION ? "AGG_" : "",
- pExpr->u.zToken);
+ if( op==TK_AGG_FUNCTION ){
+ sqlite3ExplainPrintf(pOut, "AGG_FUNCTION%d:%s(",
+ pExpr->op2, pExpr->u.zToken);
+ }else{
+ sqlite3ExplainPrintf(pOut, "FUNCTION:%s(", pExpr->u.zToken);
+ }
if( pFarg ){
sqlite3ExplainExprList(pOut, pFarg);
}
@@ -3818,8 +3821,8 @@ int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
/*
** An instance of the following structure is used by the tree walker
** to count references to table columns in the arguments of an
-** aggregate function, in order to implement the sqlite3FunctionUsesOtherSrc()
-** and sqlite3FunctionThisSrc() routines.
+** aggregate function, in order to implement the
+** sqlite3FunctionThisSrc() routine.
*/
struct SrcCount {
SrcList *pSrc; /* One particular FROM clause in a nested query */
@@ -3848,26 +3851,6 @@ static int exprSrcCount(Walker *pWalker, Expr *pExpr){
}
/*
-** Determine if any of the arguments to the pExpr Function references
-** any SrcList other than pSrcList. Return true if they do. Return
-** false if pExpr has no argument or has only constant arguments or
-** only references tables named in pSrcList.
-*/
-static int sqlite3FunctionUsesOtherSrc(Expr *pExpr, SrcList *pSrcList){
- Walker w;
- struct SrcCount cnt;
- assert( pExpr->op==TK_AGG_FUNCTION );
- memset(&w, 0, sizeof(w));
- w.xExprCallback = exprSrcCount;
- w.u.pSrcCount = &cnt;
- cnt.pSrc = pSrcList;
- cnt.nThis = 0;
- cnt.nOther = 0;
- sqlite3WalkExprList(&w, pExpr->x.pList);
- return cnt.nOther>0;
-}
-
-/*
** Determine if any of the arguments to the pExpr Function reference
** pSrcList. Return true if they do. Also return true if the function
** has no arguments or has only constant arguments. Return false if pExpr
@@ -4003,7 +3986,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
}
case TK_AGG_FUNCTION: {
if( (pNC->ncFlags & NC_InAggFunc)==0
- && !sqlite3FunctionUsesOtherSrc(pExpr, pSrcList)
+ && pWalker->walkerDepth==pExpr->op2
){
/* Check to see if pExpr is a duplicate of another aggregate
** function that is already in the pAggInfo structure