]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enable the query planner to deal with WHERE clauses that have OR terms
authordrh <drh@noemail.net>
Tue, 30 Sep 2014 17:31:23 +0000 (17:31 +0000)
committerdrh <drh@noemail.net>
Tue, 30 Sep 2014 17:31:23 +0000 (17:31 +0000)
nested within AND terms that are nested within OR terms.  Also remove an
unused function declaration.

FossilOrigin-Name: b6b289182f6590288ebc7b9efbcb29b6b4480538

manifest
manifest.uuid
src/sqliteInt.h
src/where.c

index 2a2a4b68ccc8400042773ff7244cfb185f50f432..84f200ceb8d69c1110d67d0ece5aae88f06605f7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Further\senhancements\sto\sthe\s"wheretrace"\sdebugging\soutput.
-D 2014-09-30T17:03:35.868
+C Enable\sthe\squery\splanner\sto\sdeal\swith\sWHERE\sclauses\sthat\shave\sOR\sterms\nnested\swithin\sAND\sterms\sthat\sare\snested\swithin\sOR\sterms.\s\sAlso\sremove\san\nunused\sfunction\sdeclaration.
+D 2014-09-30T17:31:23.408
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -232,7 +232,7 @@ F src/shell.c 38f627b0885191357f55902a3ac199de90d79715
 F src/sqlite.h.in 159f2cb9eef74b6c99aeeb4c071e7745835f04f6
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
-F src/sqliteInt.h 8242d04760ec2a943a152eba2a006ea121a3eafd
+F src/sqliteInt.h 254797e62264c53184172d98a491aa2b8cd4ad88
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
 F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
@@ -302,7 +302,7 @@ F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
 F src/wal.c 10e7de7ce90865a68153f001a61f1d985cd17983
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
-F src/where.c a459332dc671138a6997904850ead36d83bfb8e0
+F src/where.c 2f42fe0d19303e0f5ce29aff3afbd3e43cbd6efb
 F src/whereInt.h 124d970450955a6982e174b07c320ae6d62a595c
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -1200,7 +1200,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 2e375eae473e4a9f2e7870d59e22ba39051ecbce
-R c96a5d9652d91d70c0e54df21653ce3e
+P 670993eb8113f386cb2cb8b1507917f6da3b4d98
+R 1a06ccbab92129ac2bab7054741ffba8
 U drh
-Z 7116ce524f0c5c15e04b43bf011b61b4
+Z 36668dfa98188ac65878a88086fca9b9
index 42170fe6be3cc9be77579d5406f4ea6c610ae848..9e6ff3561c0286a6b7d97b57e54b703436f9ae7e 100644 (file)
@@ -1 +1 @@
-670993eb8113f386cb2cb8b1507917f6da3b4d98
\ No newline at end of file
+b6b289182f6590288ebc7b9efbcb29b6b4480538
\ No newline at end of file
index d637df782a71bfd78b0433a88f394f4e4f55f4f5..35cadcdbc08e80ee78bc232d87c0d6ac8746bfbf 100644 (file)
@@ -2231,7 +2231,7 @@ struct SrcList {
 #define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */
 #define WHERE_FORCE_TABLE      0x0020 /* Do not use an index-only search */
 #define WHERE_ONETABLE_ONLY    0x0040 /* Only code the 1st table in pTabList */
-#define WHERE_AND_ONLY         0x0080 /* Don't use indices for OR terms */
+                          /*   0x0080 // not currently used */
 #define WHERE_GROUPBY          0x0100 /* pOrderBy is really a GROUP BY */
 #define WHERE_DISTINCTBY       0x0200 /* pOrderby is really a DISTINCT clause */
 #define WHERE_WANT_DISTINCT    0x0400 /* All output needs to be distinct */
@@ -3134,7 +3134,6 @@ Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);
 Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);
 void sqlite3ExprAssignVarNumber(Parse*, Expr*);
 void sqlite3ExprDelete(sqlite3*, Expr*);
-void sqlite3ExprFactor(sqlite3*, Expr*, u8);
 ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
 void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
 void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
index bc7e58a7fef30d1d0d0b5f28918bafe01a740181..8974895c45c236105bf5de90a39f55b0520b9d80 100644 (file)
@@ -3524,8 +3524,9 @@ static Bitmask codeOneLoopStart(
     ** eliminating duplicates from other WHERE clauses, the action for each
     ** sub-WHERE clause is to to invoke the main loop body as a subroutine.
     */
-    wctrlFlags =  WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
-                  WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY;
+    wctrlFlags =  WHERE_OMIT_OPEN_CLOSE
+                | WHERE_FORCE_TABLE
+                | WHERE_ONETABLE_ONLY;
     for(ii=0; ii<pOrWc->nTerm; ii++){
       WhereTerm *pOrTerm = &pOrWc->a[ii];
       if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
@@ -5005,7 +5006,6 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
   struct SrcList_item *pItem;
   
   pWC = pBuilder->pWC;
-  if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK;
   pWCEnd = pWC->a + pWC->nTerm;
   pNew = pBuilder->pNew;
   memset(&sSum, 0, sizeof(sSum));
@@ -5058,6 +5058,9 @@ static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
         {
           rc = whereLoopAddBtree(&sSubBuild, mExtra);
         }
+        if( rc==SQLITE_OK ){
+          rc = whereLoopAddOr(&sSubBuild, mExtra);
+        }
         assert( rc==SQLITE_OK || sCur.n==0 );
         if( sCur.n==0 ){
           sSum.n = 0;