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

Only eliminate inner loops of a JOIN if they are the RHS of a LEFT JOIN

and if they give no more than a single result.  This appears to give correct
answers in all cases.

FossilOrigin-Name: d7a25cc79794817504ca1a4262008a68b2a4dece
This commit is contained in:
drh
2013-06-21 02:15:48 +00:00
parent fd636c7541
commit bc71b1d453
3 changed files with 14 additions and 14 deletions

View File

@@ -5794,16 +5794,16 @@ WhereInfo *sqlite3WhereBegin(
if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
while( pWInfo->nLevel>=2 ){
pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
if( ((wctrlFlags & WHERE_WANT_DISTINCT)!=0
|| (pLoop->wsFlags & WHERE_ONEROW)!=0)
&& (tabUsed & pLoop->maskSelf)==0
if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
&& (pLoop->wsFlags & WHERE_ONEROW)==0
){
WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
pWInfo->nLevel--;
nTabList--;
}else{
break;
}
if( (tabUsed & pLoop->maskSelf)!=0 ) break;
WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
pWInfo->nLevel--;
nTabList--;
}
}
WHERETRACE(0xffff,("*** Optimizer Finished ***\n"));