From: drh Date: Mon, 9 Mar 2015 13:01:02 +0000 (+0000) Subject: Fix the LIKE optimization so that it works even if there are additional X-Git-Tag: version-3.8.9~87 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80314629393b0bf728465d15ec1f2428c2e9d5c9;p=thirdparty%2Fsqlite.git Fix the LIKE optimization so that it works even if there are additional range contraints on the column that is subject to the LIKE or GLOB. FossilOrigin-Name: 984c3fd5261619fb542a5a95dab37707b5d79dbf --- 80314629393b0bf728465d15ec1f2428c2e9d5c9 diff --cc manifest index b8a1f8b1ae,1c5b59c033..a8566de963 --- a/manifest +++ b/manifest @@@ -1,5 -1,5 +1,5 @@@ - C Increase\sthe\sversion\snumber\sto\s3.8.9 - D 2015-03-09T10:40:48.276 -C Always\suse\sLIKE\soptimization\srange\sconstraints\sin\spairs. -D 2015-03-09T12:11:56.889 ++C Fix\sthe\sLIKE\soptimization\sso\sthat\sit\sworks\seven\sif\sthere\sare\sadditional\nrange\scontraints\son\sthe\scolumn\sthat\sis\ssubject\sto\sthe\sLIKE\sor\sGLOB. ++D 2015-03-09T13:01:02.136 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2f643d6968dfc0b82d2e546a0525a39079f9e928 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@@ -307,7 -307,7 +307,7 @@@ F src/vxworks.h c18586c8edc1bddbc15c004 F src/wal.c 39303f2c9db02a4e422cd8eb2c8760420c6a51fe F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 - F src/where.c 84104123394d38aa530f4e3e12b4ac7efcd7fe19 -F src/where.c 21c96bc0265228dbca2feb3f65c464bc464ec4c2 ++F src/where.c eb141b075776e9864d38f279333e2472a8653202 F src/whereInt.h cbe4aa57326998d89e7698ca65bb7c28541d483c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@@ -1241,7 -1241,7 +1241,8 @@@ F tool/vdbe_profile.tcl 67746953071a9f8 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f - P 74cb0b032fcf598537fae04412771450124ae712 - R 9ac10056eb6a3c9d151b86baaf6f566f -P 465bfc72d252f94778248253142faeba78ceea02 -R 3b7b3881e4a2944ad5c0176e96b8fcf3 ++P e5da5e7d5dc5a3438ced23f1ee83e695abc29c45 0e02dc94fd1bb891d0edd1e34b57e923b17712a7 ++R c1700660b0fab033a6359aa8c00c1b69 ++T +closed 0e02dc94fd1bb891d0edd1e34b57e923b17712a7 U drh - Z 5dfd706dc4ee17c10393dacc3c9444b2 -Z 1e9efc602031c231aa2c489f96b95b11 ++Z 0d4bf9b628bd332a63a01f9a77a070c3 diff --cc manifest.uuid index 1a6de51696,9abd00976e..5e807e391c --- a/manifest.uuid +++ b/manifest.uuid @@@ -1,1 -1,1 +1,1 @@@ - e5da5e7d5dc5a3438ced23f1ee83e695abc29c45 -0e02dc94fd1bb891d0edd1e34b57e923b17712a7 ++984c3fd5261619fb542a5a95dab37707b5d79dbf diff --cc src/where.c index 64c9652b0b,d6bce65d2e..8b9060b0a7 --- a/src/where.c +++ b/src/where.c @@@ -3361,14 -3369,13 +3369,16 @@@ static Bitmask codeOneLoopStart if( pLoop->wsFlags & WHERE_BTM_LIMIT ){ pRangeStart = pLoop->aLTerm[j++]; nExtraReg = 1; ++ /* Like optimization range constraints always occur in pairs */ ++ assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 || ++ (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 ); } if( pLoop->wsFlags & WHERE_TOP_LIMIT ){ pRangeEnd = pLoop->aLTerm[j++]; nExtraReg = 1; - if( pRangeStart - && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0 - && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 - ){ + if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){ - assert( pRangeStart!=0 ); - assert( pRangeStart->wtFlags & TERM_LIKEOPT ); ++ assert( pRangeStart!=0 ); /* LIKE opt constraints */ ++ assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */ pLevel->iLikeRepCntr = ++pParse->nMem; testcase( bRev ); testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC ); @@@ -4586,6 -4597,17 +4600,17 @@@ static int whereLoopAddBtreeIndex pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT; pBtm = pTerm; pTop = 0; + if( pTerm->wtFlags & TERM_LIKEOPT ){ - /* Make sure that range contraints that come from the LIKE - ** optimization are always used in pairs. */ ++ /* Range contraints that come from the LIKE optimization are ++ ** always used in pairs. */ + pTop = &pTerm[1]; + assert( (pTop-(pTerm->pWC->a))pWC->nTerm ); + assert( pTop->wtFlags & TERM_LIKEOPT ); + assert( pTop->eOperator==WO_LT ); + if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */ + pNew->aLTerm[pNew->nLTerm++] = pTop; + pNew->wsFlags |= WHERE_TOP_LIMIT; + } }else{ assert( eOp & (WO_LT|WO_LE) ); testcase( eOp & WO_LT );