1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Omit the the count-of-view optimization if there is a HAVING clause.

dbsqlfuzz 6a107e3055bd22afab31cfddabc2d9d54fcbaf69

FossilOrigin-Name: babe2b5e59647ac9db4601e67c25190aac14eb76d5fcb9fa5b3692b955fefd61
This commit is contained in:
drh
2023-03-31 23:48:59 +00:00
parent 567b069e42
commit 1839b7990d
4 changed files with 39 additions and 9 deletions

View File

@@ -6871,6 +6871,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */
if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
if( p->pWhere ) return 0;
if( p->pHaving ) return 0;
if( p->pGroupBy ) return 0;
if( p->pOrderBy ) return 0;
pExpr = p->pEList->a[0].pExpr;
@@ -6890,7 +6891,8 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
if( pSub->pWhere ) return 0; /* No WHERE clause */
if( pSub->pLimit ) return 0; /* No LIMIT clause */
if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
pSub = pSub->pPrior; /* Repeat over compound */
assert( pSub->pHaving==0 ); /* Due to the previous */
pSub = pSub->pPrior; /* Repeat over compound */
}while( pSub );
/* If we reach this point then it is OK to perform the transformation */