mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Do not apply the push-down optimization to CTE subqueries that will be
reused in other contexts in where the same optimization is unlikely to be valid. Fix for the bug reported by [forum:/forumpost/d496c3d29bc93736|forum post d496c3d29bc93736]. FossilOrigin-Name: a7ce29a6ef2e0362bbc9b23719d936dce07209b2651153c774682f599bbd888e
This commit is contained in:
@@ -6583,7 +6583,8 @@ int sqlite3Select(
|
||||
** inside the subquery. This can help the subquery to run more efficiently.
|
||||
*/
|
||||
if( OptimizationEnabled(db, SQLITE_PushDown)
|
||||
&& (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes)
|
||||
&& (pItem->fg.isCte==0
|
||||
|| (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2))
|
||||
&& pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,
|
||||
(pItem->fg.jointype & JT_OUTER)!=0)
|
||||
){
|
||||
|
||||
Reference in New Issue
Block a user