From: drh Date: Thu, 31 Mar 2016 21:16:56 +0000 (+0000) Subject: Enhance the query planner so that IS and IS NULL operators are able to drive X-Git-Tag: version-3.9.3~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c012b719a0a40a8b9be6e6f12ab8d1890314759;p=thirdparty%2Fsqlite.git Enhance the query planner so that IS and IS NULL operators are able to drive an index on a LEFT OUTER JOIN. FossilOrigin-Name: f1e6bb952e691d504713f3f923f8019585dbd4aa --- diff --git a/manifest b/manifest index b26022c602..7fe0ae1df9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.9.2 -D 2015-11-02T18:31:45.544 +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-31T21:16:56.689 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in f0088ff0d2ac949fce6de7c00f13a99ac5bdb663 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -420,7 +420,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c 18b0ed49830cf04fe2d68224b41838a73ac6cd24 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba -F src/where.c e3724b7b31d1e13869308ed4125305364f7d823a +F src/where.c f06ac362cfb64c16cb02df7aa756f35b5f3455c6 F src/whereInt.h 7892bb54cf9ca0ae5c7e6094491b94c9286dc647 F src/wherecode.c cdfff200d065e7fb1af827b3274ed46b10a91d65 F src/whereexpr.c e63244ca06c503e5f3c5b7f3c9aea0db826089ed @@ -1390,10 +1390,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c0c4b6b39648be9aa9b1e218e6d281ab17812536 -R 56b278dd241b099a55f2d39b092fbea8 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.9.2 * +P bda77dda9697c463c3d0704014d51627fceee328 +Q +c648539b52ca28c0b2cb61208e2c32b1d29626a1 +R b35c888757280be19c712957d8f590ac U drh -Z ea2f853532ec0d2d6055c0d00a95dc82 +Z c2af06165318ce226b935e5360d45b12 diff --git a/manifest.uuid b/manifest.uuid index 2772d49f44..2c7d521f0f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bda77dda9697c463c3d0704014d51627fceee328 \ No newline at end of file +f1e6bb952e691d504713f3f923f8019585dbd4aa \ No newline at end of file diff --git a/src/where.c b/src/where.c index 0adc698401..427ea679ff 100644 --- a/src/where.c +++ b/src/where.c @@ -2192,8 +2192,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; } @@ -2231,6 +2229,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;