From: drh Date: Sat, 26 Nov 2005 14:24:40 +0000 (+0000) Subject: Disable the OR-clause optimization if it does not result in an index being X-Git-Tag: version-3.6.10~3371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a5f7474e37263b3a38c79a4b98f712a497ddd6e;p=thirdparty%2Fsqlite.git Disable the OR-clause optimization if it does not result in an index being used that would not have been used otherwise. In other words, do not convert OR clauses into an IN statement if it does not help the optimizer. (CVS 2789) FossilOrigin-Name: 7e7cfce0f8ed2a6e04747736a2c68484f447cdfb --- diff --git a/manifest b/manifest index 9b8e0c2287..b3078aeaa5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sleft\sjoins\sstill\swork\seven\swhen\sthe\sOR\sclause\soptimization\sfires.\nTicket\s#1537.\s(CVS\s2788) -D 2005-11-26T14:08:08 +C Disable\sthe\sOR-clause\soptimization\sif\sit\sdoes\snot\sresult\sin\san\sindex\sbeing\nused\sthat\swould\snot\shave\sbeen\sused\sotherwise.\s\sIn\sother\swords,\sdo\snot\nconvert\sOR\sclauses\sinto\san\sIN\sstatement\sif\sit\sdoes\snot\shelp\sthe\soptimizer.\s(CVS\s2789) +D 2005-11-26T14:24:41 F Makefile.in 28a2772cd9e03ba758c2a052813092cdb9da73bf F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -90,7 +90,7 @@ F src/vdbeapi.c 85bbe1d0243a89655433d60711b4bd71979b59cd F src/vdbeaux.c 3dca9c04c07dda17f0cb06b3a552e1e23106232f F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5 F src/vdbemem.c cd9609c1e7f71ec76d9840c84c3a57ebfa6539cf -F src/where.c 1d144279883a6a2498ac8773e723582bca8254ad +F src/where.c a9fed5a5b549f5dae1aa95dc9463cd1f35efa0f1 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42 F test/all.test 7f0988442ab811dfa41793b5b550f5828ce316f3 F test/alter.test 9d6837a3d946b73df692b7cef2a7644d2e2f6bc6 @@ -323,7 +323,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 008f676f20c690255e5cb8ae01df47c5094ac240 -R b34d323b79ba342c39e80a4df57b4fa0 +P cbbeb9de0019a0b81318158711590078fcb7e98a +R 067bd3867a5225e7924889dcec0a8fc0 U drh -Z 2ac6d09fb843357ed1a6d0af5f42251a +Z a4ac09e883a7ba726f3dc764bd2b73b6 diff --git a/manifest.uuid b/manifest.uuid index 9ee9e5f418..8c77b9ff1b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbbeb9de0019a0b81318158711590078fcb7e98a \ No newline at end of file +7e7cfce0f8ed2a6e04747736a2c68484f447cdfb \ No newline at end of file diff --git a/src/where.c b/src/where.c index 3c2257ede7..ce94b102d5 100644 --- a/src/where.c +++ b/src/where.c @@ -16,7 +16,7 @@ ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.184 2005/11/26 14:08:08 drh Exp $ +** $Id: where.c,v 1.185 2005/11/26 14:24:41 drh Exp $ */ #include "sqliteInt.h" @@ -700,15 +700,17 @@ static void exprAnalyze( } pNew = sqlite3Expr(TK_IN, pDup, 0, 0); if( pNew ){ + int idxNew; transferJoinMarkings(pNew, pExpr); pNew->pList = pList; + idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); + exprAnalyze(pSrc, pMaskSet, pWC, idxNew); + pTerm = &pWC->a[idxTerm]; + pWC->a[idxNew].iParent = idxTerm; + pTerm->nChild = 1; }else{ sqlite3ExprListDelete(pList); } - pTerm->pExpr = pNew; - pTerm->flags |= TERM_DYNAMIC; - exprAnalyze(pSrc, pMaskSet, pWC, idxTerm); - pTerm = &pWC->a[idxTerm]; } or_not_possible: whereClauseClear(&sOr);