aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-06-21 02:15:48 +0000
committerdrh <drh@noemail.net>2013-06-21 02:15:48 +0000
commitbc71b1d4536ce7842f80010049c69f5fd2806b3b (patch)
tree1cff45b2fc2a82ffb4bf6d380ea9cb918844ace8 /src
parentfd636c7541d0de19ce365fc9e483b88121531c2e (diff)
downloadsqlite-bc71b1d4536ce7842f80010049c69f5fd2806b3b.tar.gz
sqlite-bc71b1d4536ce7842f80010049c69f5fd2806b3b.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/where.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/where.c b/src/where.c
index 18b4a3782..32fa61c7f 100644
--- a/src/where.c
+++ b/src/where.c
@@ -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"));