From: drh Date: Wed, 13 May 2015 17:54:08 +0000 (+0000) Subject: Add testcase() macros and comments and a few test-cases. X-Git-Tag: version-3.8.11~262^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e0cc3c296caa6a62967b50238f3563215727d11c;p=thirdparty%2Fsqlite.git Add testcase() macros and comments and a few test-cases. FossilOrigin-Name: 24263d08b11c88416d270013bdaf5ff45125cb4d --- diff --git a/manifest b/manifest index ec12a04f7c..4413996a08 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\searly\sattempt\sto\sget\sindexes\sto\swork\swith\sthe\sIS\soperator.\s\sThis\scode\npasses\stests,\sbut\smuch\smore\stesting\sis\sneeded\sto\sverify\sthat\sit\sworks\son\nall\scorner\scases. -D 2015-05-13T15:24:07.257 +C Add\stestcase()\smacros\sand\scomments\sand\sa\sfew\stest-cases. +D 2015-05-13T17:54:08.892 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in edfc69769e613a6359c42c06ea1d42c3bece1736 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -307,7 +307,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 48e3c1f0a8a7ecbaeb5a57c195254243d49430ba +F src/where.c 98964edb2a27d6f87976b85a8b00862558a277b2 F src/whereInt.h 6b5a8ac7b4adc055176c3330d755735ed674335d F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1165,7 +1165,7 @@ F test/walro.test 34422d1d95aaff0388f0791ec20edb34e2a3ed57 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e -F test/where.test 28b64e93428961b07b0d486778d63fd672948f6b +F test/where.test 1ff3d9f8da0a6c0dc5ccfd38d9225b2cdb5b6afb F test/where2.test 23fdb5d8e756554aad4ca7ae03de9dd8367a2c6e F test/where3.test 1ad55ba900bd7747f98b6082e65bd3e442c5004e F test/where4.test d8420ceeb8323a41ceff1f1841fc528e824e1ecf @@ -1258,10 +1258,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 59e3e9e764440b7feaafadff74f422535d21bca2 -R 9f6038338a4c8e424f8c4ba92f9afc16 -T *branch * index-is-operator -T *sym-index-is-operator * -T -sym-trunk * +P 6f7f1673d00d216a5aa456acb44793a14f3b3d91 +R 3ff0212a0c4cf6ad597a241e62c5ab7c U drh -Z a0eadd388567e992c46f2fabbded464e +Z fddf4aa627339444877435638e7a9621 diff --git a/manifest.uuid b/manifest.uuid index 877d59c28e..d093009b2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f7f1673d00d216a5aa456acb44793a14f3b3d91 \ No newline at end of file +24263d08b11c88416d270013bdaf5ff45125cb4d \ No newline at end of file diff --git a/src/where.c b/src/where.c index 6bbfaca879..1c2c0931be 100644 --- a/src/where.c +++ b/src/where.c @@ -417,7 +417,7 @@ static u16 operatorMask(int op){ }else if( op==TK_ISNULL ){ c = WO_ISNULL; }else if( op==TK_IS ){ - c = WO_EQ; + c = WO_EQ; /* IS works like ==, just without the IsNull tests */ }else{ assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff ); c = (u16)(WO_EQ<<(op-TK_EQ)); @@ -1117,6 +1117,7 @@ static void exprAnalyzeOrTerm( okToChngToIN = 1; for(; i>=0 && okToChngToIN; i--, pOrTerm++){ assert( pOrTerm->eOperator & WO_EQ ); + testcase( pOrTerm->pExpr->op==TK_IS ); if( pOrTerm->leftCursor!=iCursor ){ pOrTerm->wtFlags &= ~TERM_OR_OK; }else if( pOrTerm->u.leftColumn!=iColumn ){ @@ -1153,6 +1154,7 @@ static void exprAnalyzeOrTerm( assert( pOrTerm->eOperator & WO_EQ ); assert( pOrTerm->leftCursor==iCursor ); assert( pOrTerm->u.leftColumn==iColumn ); + testcase( pOrTerm->pExpr->op==TK_IS ); pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup); pLeft = pOrTerm->pExpr->pLeft; @@ -1683,6 +1685,7 @@ static int termCanDriveIndex( if( pTerm->u.leftColumn<0 ) return 0; aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity; if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; + testcase( pTerm->pExpr->op==TK_IS ); return 1; } #endif @@ -2980,6 +2983,7 @@ static int codeAllEqualityTerms( testcase( pTerm->eOperator & WO_IN ); if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){ Expr *pRight = pTerm->pExpr->pRight; + testcase( pTerm->pExpr->op==TK_IS ); if( (pTerm->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ @@ -3631,6 +3635,7 @@ static Bitmask codeOneLoopStart( Expr *pRight = pRangeStart->pExpr->pRight; sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeStart); + testcase( pRangeStart->pExpr->op==TK_IS ); if( (pRangeStart->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ @@ -3677,6 +3682,7 @@ static Bitmask codeOneLoopStart( sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); sqlite3ExprCode(pParse, pRight, regBase+nEq); whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); + testcase( pRangeEnd->pExpr->op==TK_IS ); if( (pRangeEnd->wtFlags & TERM_NULLOK)==0 && sqlite3ExprCanBeNull(pRight) ){ @@ -4113,7 +4119,7 @@ static Bitmask codeOneLoopStart( pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0); if( pAlt==0 ) continue; if( pAlt->wtFlags & (TERM_CODED) ) continue; - testcase( pAlt->eOperator & WO_EQ ); + testcase( (pAlt->eOperator & WO_EQ)!=0 && pAlt->pExpr->op==TK_IS ); testcase( pAlt->eOperator & WO_IN ); VdbeModuleComment((v, "begin transitive constraint")); pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); @@ -4658,6 +4664,7 @@ static void whereLoopOutputAdjust( pLoop->nOut--; if( pTerm->eOperator&WO_EQ ){ Expr *pRight = pTerm->pExpr->pRight; + testcase( pTerm->pExpr->op==TK_IS ); if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){ k = 10; }else{ @@ -4859,7 +4866,7 @@ static int whereLoopAddBtreeIndex( ){ Expr *pExpr = pTerm->pExpr; if( (eOp & (WO_EQ|WO_ISNULL))!=0 ){ - testcase( eOp & WO_EQ ); + testcase( (eOp & WO_EQ)!=0 && pExpr->op==TK_IS ); testcase( eOp & WO_ISNULL ); rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut); }else{ @@ -5707,6 +5714,7 @@ static i8 wherePathSatisfiesOrderBy( if( !pColl ) pColl = db->pDfltColl; z2 = pColl->zName; if( sqlite3StrICmp(z1, z2)!=0 ) continue; + testcase( pTerm->pExpr->op==TK_IS ); } obSat |= MASKBIT(i); } @@ -6329,6 +6337,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); if( pTerm==0 ) break; pLoop->aLTerm[j] = pTerm; + testcase( pTerm->pExpr->op==TK_IS ); } if( j!=pIdx->nKeyCol ) continue; pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED; diff --git a/test/where.test b/test/where.test index f560708cca..72fd696306 100644 --- a/test/where.test +++ b/test/where.test @@ -65,9 +65,15 @@ proc count sql { do_test where-1.1.1 { count {SELECT x, y, w FROM t1 WHERE w=10} } {3 121 10 3} +do_test where-1.1.1b { + count {SELECT x, y, w FROM t1 WHERE w IS 10} +} {3 121 10 3} do_eqp_test where-1.1.2 { SELECT x, y, w FROM t1 WHERE w=10 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} +do_eqp_test where-1.1.2b { + SELECT x, y, w FROM t1 WHERE w IS 10 +} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} do_test where-1.1.3 { db status step } {0} @@ -101,12 +107,21 @@ do_test where-1.3.1 { do_test where-1.3.2 { count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc} } {3 144 11 3} +do_test where-1.3.3 { + count {SELECT x, y, w AS abc FROM t1 WHERE 11 IS abc} +} {3 144 11 3} do_test where-1.4.1 { count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2} } {11 3 144 3} +do_test where-1.4.1b { + count {SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2} +} {11 3 144 3} do_eqp_test where-1.4.2 { SELECT w, x, y FROM t1 WHERE 11=w AND x>2 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} +do_eqp_test where-1.4.2b { + SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2 +} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} do_test where-1.4.3 { count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2} } {11 3 144 3} @@ -143,6 +158,9 @@ do_test where-1.10 { do_test where-1.11 { count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10} } {3 100 3} +do_test where-1.11b { + count {SELECT x, y FROM t1 WHERE x IS 3 AND y IS 100 AND w<10} +} {3 100 3} # New for SQLite version 2.1: Verify that that inequality constraints # are used correctly. @@ -150,12 +168,18 @@ do_test where-1.11 { do_test where-1.12 { count {SELECT w FROM t1 WHERE x=3 AND y<100} } {8 3} +do_test where-1.12b { + count {SELECT w FROM t1 WHERE x IS 3 AND y<100} +} {8 3} do_test where-1.13 { count {SELECT w FROM t1 WHERE x=3 AND 100>y} } {8 3} do_test where-1.14 { count {SELECT w FROM t1 WHERE 3=x AND y<100} } {8 3} +do_test where-1.14b { + count {SELECT w FROM t1 WHERE 3 IS x AND y<100} +} {8 3} do_test where-1.15 { count {SELECT w FROM t1 WHERE 3=x AND 100>y} } {8 3} @@ -168,6 +192,9 @@ do_test where-1.17 { do_test where-1.18 { count {SELECT w FROM t1 WHERE x=3 AND y>225} } {15 3} +do_test where-1.18b { + count {SELECT w FROM t1 WHERE x IS 3 AND y>225} +} {15 3} do_test where-1.19 { count {SELECT w FROM t1 WHERE x=3 AND 225121 AND y<196} } {11 12 5} +do_test where-1.22b { + count {SELECT w FROM t1 WHERE x IS 3 AND y>121 AND y<196} +} {11 12 5} do_test where-1.23 { count {SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196} } {10 11 12 13 9}