diff options
author | dan <dan@noemail.net> | 2018-05-17 19:24:08 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2018-05-17 19:24:08 +0000 |
commit | e2f781b9d10fe358dfc999d8f0ae98f5b736adc0 (patch) | |
tree | 3797264c3d857a4633198029dfc0598fcb892395 /src/resolve.c | |
parent | 2e362f9775ba05e353276039acc788e592fea0e4 (diff) | |
download | sqlite-e2f781b9d10fe358dfc999d8f0ae98f5b736adc0.tar.gz sqlite-e2f781b9d10fe358dfc999d8f0ae98f5b736adc0.zip |
Evaluate multiple window functions in a single pass if they use the same
window definition. Add xValue callbacks for other built-in aggregate
functions.
FossilOrigin-Name: c9f0f140941660ff368e5bb5752d54feb1964b7a9eac986d4bfb8f24a1c20d86
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/resolve.c b/src/resolve.c index 073fdf193..99472272f 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -776,13 +776,15 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ sqlite3WalkExprList(pWalker, pList); if( is_agg ){ if( pExpr->pWin ){ - pExpr->pWin->pNextWin = pNC->pWin; - pNC->pWin = pExpr->pWin; + if( 0==pNC->pWin + || 0==sqlite3WindowCompare(pParse, pNC->pWin, pExpr->pWin) + ){ + pExpr->pWin->pNextWin = pNC->pWin; + pNC->pWin = pExpr->pWin; + } pExpr->pWin->pFunc = pDef; - pExpr->pWin->nArg = pExpr->x.pList->nExpr; - } - else - { + pExpr->pWin->nArg = (pExpr->x.pList ? pExpr->x.pList->nExpr : 0); + }else{ NameContext *pNC2 = pNC; pExpr->op = TK_AGG_FUNCTION; pExpr->op2 = 0; |