]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the query planner so that IS and IS NULL operators are able to drive
authordrh <drh@noemail.net>
Thu, 7 Apr 2016 23:18:44 +0000 (23:18 +0000)
committerdrh <drh@noemail.net>
Thu, 7 Apr 2016 23:18:44 +0000 (23:18 +0000)
an index on a LEFT OUTER JOIN.

FossilOrigin-Name: 84d2a09eab28b65ab7015e89c2057851c7894842

manifest
manifest.uuid
src/where.c

index d150efacf1822aeb0398c74c3bbc4ed2a5e07219..dbc8d05fdd7738e2b66ccc174db10f5dc26cda0f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\sthe\sversion\snumber\sto\s3.12.1.\s\sThis\sis\sthe\sfirst\srelease\scandidate.
-D 2016-04-07T21:29:56.281
+C Enhance\sthe\squery\splanner\sso\sthat\sIS\sand\sIS\sNULL\soperators\sare\sable\sto\sdrive\nan\sindex\son\sa\sLEFT\sOUTER\sJOIN.
+D 2016-04-07T23:18:44.800
 F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc b00bcf0ec7001857aea81ee39fae45d20f5f4e59
@@ -433,7 +433,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c 10deb6b43887662691e5f53d10b3c171c401169b
 F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c
 F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354
-F src/where.c fe7925faafbe9a458972035c0bb4753d672f04ed
+F src/where.c 99cc6270fc3915201e2a90bbac3768f007a89c44
 F src/whereInt.h 93297d56edd137b7ea004490690fb6e2ce028a34
 F src/wherecode.c 863aedf086131743763c1960637fde904eadc442
 F src/whereexpr.c fb87944b1254234e5bba671aaf6dee476241506a
@@ -1459,7 +1459,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 3360ab098a374d2eea433ca2a8278ca866957326
-R bdce6efd0bd6b8391dd3f11f99281b9e
+P 300f1b61a0a1e486bdd63ab14b8a06574d4b3fc9
+Q +c648539b52ca28c0b2cb61208e2c32b1d29626a1
+R 53ca277f27cb21538c9d98930a79d380
 U drh
-Z 903e5b0a3bbef42c4103adda07b920c0
+Z 0e0ae1cbd0507466230e7807074e834c
index 273ed69bc503fbd1403cca493e2fa2b80ae0d04e..7b24e92699362ee557e8785a91138212b05845b7 100644 (file)
@@ -1 +1 @@
-300f1b61a0a1e486bdd63ab14b8a06574d4b3fc9
\ No newline at end of file
+84d2a09eab28b65ab7015e89c2057851c7894842
\ No newline at end of file
index cf23aa62a4f208ccad7c1ec550eee385f144cffe..4f7ee66ff7f3a1614aace5494382ddfc2ab77f71 100644 (file)
@@ -2201,8 +2201,6 @@ static int whereLoopAddBtreeIndex(
   assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );
   if( pNew->wsFlags & WHERE_BTM_LIMIT ){
     opMask = WO_LT|WO_LE;
-  }else if( /*pProbe->tnum<=0 ||*/ (pSrc->fg.jointype & JT_LEFT)!=0 ){
-    opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE;
   }else{
     opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
   }
@@ -2240,6 +2238,18 @@ static int whereLoopAddBtreeIndex(
     ** to mix with a lower range bound from some other source */
     if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
 
+    /* Do not allow IS constraints from the WHERE clause to be used by the
+    ** right table of a LEFT JOIN.  Only constraints in the ON clause are
+    ** allowed */
+    if( (pSrc->fg.jointype & JT_LEFT)!=0
+     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+     && (eOp & (WO_IS|WO_ISNULL))!=0
+    ){
+      testcase( eOp & WO_IS );
+      testcase( eOp & WO_ISNULL );
+      continue;
+    }
+
     pNew->wsFlags = saved_wsFlags;
     pNew->u.btree.nEq = saved_nEq;
     pNew->nLTerm = saved_nLTerm;