]> 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, 31 Mar 2016 20:40:28 +0000 (20:40 +0000)
committerdrh <drh@noemail.net>
Thu, 31 Mar 2016 20:40:28 +0000 (20:40 +0000)
an index on a LEFT OUTER JOIN.

FossilOrigin-Name: c648539b52ca28c0b2cb61208e2c32b1d29626a1

manifest
manifest.uuid
src/where.c

index c60204052330c555344f5302ee75ade2bb761d48..985501bcf7d92d8a17e06bbb6c01ce956ea5dce9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Updates\sfor\sthe\sMSVC\smakefiles.
-D 2016-03-30T16:23:06.801
+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-03-31T20:40:28.501
 F Makefile.in e812bb732d7af01baa09f1278bd4f4a2e3a09449
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc cde766eb7c27a7ca42000e66c5f0c37a17a05998
@@ -453,7 +453,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
@@ -1480,7 +1480,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 64d75cbe2c45af67124fa7ce5688d91cc6ddb755
-R 77269b95e931ac6cca96bcd2fa718a38
-U mistachkin
-Z 37f983898af724eda9f571ecd8a4d862
+P 7cf0cab730e2d570c82dd789279ad6501ac598c8
+R 208d59c6eb413bba3e66e70033cda029
+U drh
+Z d36ae30a27c8e5f7b17afdd33be692aa
index 2aa68317b9cfab2b2ac4ad4480e754108eceb3fc..c1ba66c050105fde341022baa3ab99a2a575942e 100644 (file)
@@ -1 +1 @@
-7cf0cab730e2d570c82dd789279ad6501ac598c8
\ No newline at end of file
+c648539b52ca28c0b2cb61208e2c32b1d29626a1
\ 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;