aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authordrh <>2023-04-03 23:49:00 +0000
committerdrh <>2023-04-03 23:49:00 +0000
commit39b07f1afce2dc222bab4dc3889eb1ce23a7cf83 (patch)
treeb2417fbadf170ca5f8dbf2b41747fc886649e3d3 /src/select.c
parentf61bf3dbe81bc0f535822b3802ff5fead67f09b5 (diff)
downloadsqlite-39b07f1afce2dc222bab4dc3889eb1ce23a7cf83.tar.gz
sqlite-39b07f1afce2dc222bab4dc3889eb1ce23a7cf83.zip
When translating arguments of aggregate functions into references to
expression indexes, make sure to only translate them for the current aggregate when there are nested aggregates. [forum/forumpost/409ebc7368|Forum post 409ebc7368]. FossilOrigin-Name: 898bfa1afd8260eaaf2aa6db94e74d99ebf4e8a6dc02cf21d20cd981393609a5
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/select.c b/src/select.c
index d959b8988..9e070be0b 100644
--- a/src/select.c
+++ b/src/select.c
@@ -6485,7 +6485,7 @@ static int aggregateIdxEprRefToColCallback(Walker *pWalker, Expr *pExpr){
if( pExpr->op==TK_AGG_FUNCTION ) return WRC_Continue;
if( pExpr->op==TK_IF_NULL_ROW ) return WRC_Continue;
pAggInfo = pExpr->pAggInfo;
- if( pExpr->iAgg>=pAggInfo->nColumn ) return WRC_Continue;
+ if( NEVER(pExpr->iAgg>=pAggInfo->nColumn) ) return WRC_Continue;
assert( pExpr->iAgg>=0 );
pCol = &pAggInfo->aCol[pExpr->iAgg];
pExpr->op = TK_AGG_COLUMN;