mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Fix an issue with the OmitNoopJoin optimization and add test cases that
are specifically for that optimization. FossilOrigin-Name: 5480d124b74c9adaacc4fa9cb81560865b44f3e1
This commit is contained in:
10
src/where.c
10
src/where.c
@@ -5796,6 +5796,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||
Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
|
||||
if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
|
||||
while( pWInfo->nLevel>=2 ){
|
||||
WhereTerm *pTerm, *pEnd;
|
||||
pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
|
||||
if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
|
||||
if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
|
||||
@@ -5804,6 +5805,15 @@ WhereInfo *sqlite3WhereBegin(
|
||||
break;
|
||||
}
|
||||
if( (tabUsed & pLoop->maskSelf)!=0 ) break;
|
||||
pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;
|
||||
for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
|
||||
if( (pTerm->prereqAll & pLoop->maskSelf)!=0
|
||||
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
|
||||
){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( pTerm<pEnd ) break;
|
||||
WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
|
||||
pWInfo->nLevel--;
|
||||
nTabList--;
|
||||
|
||||
Reference in New Issue
Block a user