mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Fix a weird corner case in aggregate function processing that results from the
recent addition of support for index expressions on aggregate queries. [forum:/forumpost/bad532820c|Forum post bad532820c]. FossilOrigin-Name: c34fd9fe1b76e0a5943f014f46141cbe55d41bb1e6980adf9bcb6785a03e7883
This commit is contained in:
11
src/expr.c
11
src/expr.c
@@ -6286,9 +6286,11 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
|
||||
int iAgg = pExpr->iAgg;
|
||||
Parse *pParse = pWalker->pParse;
|
||||
sqlite3 *db = pParse->db;
|
||||
assert( iAgg>=0 );
|
||||
if( pExpr->op!=TK_AGG_FUNCTION ){
|
||||
assert( iAgg>=0 && iAgg<pAggInfo->nColumn );
|
||||
if( pAggInfo->aCol[iAgg].pCExpr==pExpr ){
|
||||
if( iAgg<pAggInfo->nColumn
|
||||
&& pAggInfo->aCol[iAgg].pCExpr==pExpr
|
||||
){
|
||||
pExpr = sqlite3ExprDup(db, pExpr, 0);
|
||||
if( pExpr ){
|
||||
pAggInfo->aCol[iAgg].pCExpr = pExpr;
|
||||
@@ -6297,8 +6299,9 @@ static int agginfoPersistExprCb(Walker *pWalker, Expr *pExpr){
|
||||
}
|
||||
}else{
|
||||
assert( pExpr->op==TK_AGG_FUNCTION );
|
||||
assert( iAgg>=0 && iAgg<pAggInfo->nFunc );
|
||||
if( pAggInfo->aFunc[iAgg].pFExpr==pExpr ){
|
||||
if( ALWAYS(iAgg<pAggInfo->nFunc)
|
||||
&& pAggInfo->aFunc[iAgg].pFExpr==pExpr
|
||||
){
|
||||
pExpr = sqlite3ExprDup(db, pExpr, 0);
|
||||
if( pExpr ){
|
||||
pAggInfo->aFunc[iAgg].pFExpr = pExpr;
|
||||
|
Reference in New Issue
Block a user