Candidate fix for the nested aggregate query problem of ticket
[c2ad16f997ee9c8e].
FossilOrigin-Name: f3dd1fafd4718558de1f06139419a8c560d727f5
diff --git a/src/expr.c b/src/expr.c
index 10d9f77..95c3515 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -3965,7 +3965,9 @@
return WRC_Prune;
}
case TK_AGG_FUNCTION: {
- if( !sqlite3FunctionUsesOtherSrc(pExpr, pSrcList) ){
+ if( (pNC->ncFlags & NC_InAggFunc)==0
+ && !sqlite3FunctionUsesOtherSrc(pExpr, pSrcList)
+ ){
/* Check to see if pExpr is a duplicate of another aggregate
** function that is already in the pAggInfo structure
*/
@@ -4002,8 +4004,8 @@
ExprSetIrreducible(pExpr);
pExpr->iAgg = (i16)i;
pExpr->pAggInfo = pAggInfo;
- return WRC_Prune;
}
+ return WRC_Prune;
}
}
return WRC_Continue;