Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Disable the [d1ba200234f40b84|count-of-view optimization] if any subquery is DISTINCT, as the optimization does not work in that case. Bug reported by forum post a860f5fb2e. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d7013b63932b2f5750572ae6bdd259a2 |
User & Date: | drh 2025-03-10 10:32:31 |
Original Comment: | Disable the [d1ba200234f40b84|count-of-view optimization] if any subquery is DISTINCT, as the optimization does not work in that case. Bug reported by [forum/forumpost/a860f5fb2e|forum post a860f5fb2e]. |
Context
2025-03-10
| ||
17:28 | Add an explicit db close to test/walsetlk.test to work around an unjustified test failure on Windows when the walsetlk tests are run in the same invocation of testfixture.exe in Windows. (check-in: f418de10 user: stephan tags: trunk) | |
10:39 | Disable the [d1ba200234f40b84|count-of-view optimization] if any subquery is DISTINCT, as the optimization does not work in that case. (Leaf check-in: bae270b9 user: drh tags: branch-3.49) | |
10:32 | Disable the [d1ba200234f40b84|count-of-view optimization] if any subquery is DISTINCT, as the optimization does not work in that case. Bug reported by forum post a860f5fb2e. (check-in: d7013b63 user: drh tags: trunk) | |
2025-03-06
| ||
09:29 | Back out the most significant part of [5c28a17253e2f], as Cygwin is a hybrid. With SQLITE_OS_UNIX it will use POSIX locking, which will misinteract with apps using Windows-style locking. (check-in: 44adf8f3 user: stephan tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 | ** The transformation only works if all of the following are true: ** ** * The subquery is a UNION ALL of two or more terms ** * The subquery does not have a LIMIT clause ** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries ** * The outer query is a simple count(*) with no WHERE clause or other ** extraneous syntax. ** ** Return TRUE if the optimization is undertaken. */ static int countOfViewOptimization(Parse *pParse, Select *p){ Select *pSub, *pPrior; Expr *pExpr; Expr *pCount; | > | 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 | ** The transformation only works if all of the following are true: ** ** * The subquery is a UNION ALL of two or more terms ** * The subquery does not have a LIMIT clause ** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries ** * The outer query is a simple count(*) with no WHERE clause or other ** extraneous syntax. ** * None of the subqueries are DISTINCT (forumpost/a860f5fb2e 2025-03-10) ** ** Return TRUE if the optimization is undertaken. */ static int countOfViewOptimization(Parse *pParse, Select *p){ Select *pSub, *pPrior; Expr *pExpr; Expr *pCount; |
︙ | ︙ | |||
7229 7230 7231 7232 7233 7234 7235 | pSub = pFrom->u4.pSubq->pSelect; if( pSub->pPrior==0 ) return 0; /* Must be a compound */ if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */ do{ if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */ if( pSub->pWhere ) return 0; /* No WHERE clause */ if( pSub->pLimit ) return 0; /* No LIMIT clause */ | > | > > > | 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 | pSub = pFrom->u4.pSubq->pSelect; if( pSub->pPrior==0 ) return 0; /* Must be a compound */ if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */ do{ if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */ if( pSub->pWhere ) return 0; /* No WHERE clause */ if( pSub->pLimit ) return 0; /* No LIMIT clause */ if( pSub->selFlags & (SF_Aggregate|SF_Distinct) ){ testcase( pSub->selFlags & SF_Aggregate ); testcase( pSub->selFlags & SF_Distinct ); return 0; /* Not an aggregate nor DISTINCT */ } 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 */ db = pParse->db; |
︙ | ︙ |