]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix EXPLAIN QUERY PLAN output for indexed-expressions. Fix another
authordrh <drh@noemail.net>
Thu, 27 Aug 2015 20:33:38 +0000 (20:33 +0000)
committerdrh <drh@noemail.net>
Thu, 27 Aug 2015 20:33:38 +0000 (20:33 +0000)
obscure fault in the WHERE term scanner.

FossilOrigin-Name: 73d361ce9e4d72c943def8b0b3caa227f9199aed

manifest
manifest.uuid
src/where.c
src/wherecode.c

index 2a88bdcb4d7892a2fd7e17b5fd0bf10ccad6ab72..901fd7000641f81c91a7d9e896bbd173315782d1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sproblems\sin\sthe\sindexed-expression\shandling\sin\sthe\soptimizer.
-D 2015-08-27T19:56:49.408
+C Fix\sEXPLAIN\sQUERY\sPLAN\soutput\sfor\sindexed-expressions.\s\sFix\sanother\nobscure\sfault\sin\sthe\sWHERE\sterm\sscanner.
+D 2015-08-27T20:33:38.975
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e2218eb228374422969de7b1680eda6864affcef
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -414,9 +414,9 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb
 F src/wal.c 6fb6b68969e4692593c2552c4e7bff5882de2cb8
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c 2e14d17f592d176b6dc879c33fbdec4fbccaa2ba
-F src/where.c fcdded4bf274bf527020436e8895b33d575f18f6
+F src/where.c b22b416694905555a0cbbd7d8881179392a56aba
 F src/whereInt.h 292d3ac90da4eab1e03ac8452f1add746bcafaa1
-F src/wherecode.c 3d9113cc307ffeed58db41fe9f2d807c94787ab5
+F src/wherecode.c b0bf45ca49e62fde68ba2e2ad2939d9cdeb4e409
 F src/whereexpr.c 990ed42b5940d4000e7e61887a4bbed412c80488
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
@@ -1380,7 +1380,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 42f93f582eccd8a778189aa6c113874f995ab751
-R 475d6e7258921a9c57642e7cd0e82c9c
+P 03375017691d5b480e73d712c4318632e835060c
+R 8aa1e38f792c255d32b6cb36a0f80565
 U drh
-Z 29a0c57d5a3080634424e9023a9fd1e9
+Z dc558ff8656aec58d6de7d38d850c48a
index d483132b9081161ba675a6db5025e8fca188c4be..77236f721d365e53bceaa6990b5afbea8f5122a9 100644 (file)
@@ -1 +1 @@
-03375017691d5b480e73d712c4318632e835060c
\ No newline at end of file
+73d361ce9e4d72c943def8b0b3caa227f9199aed
\ No newline at end of file
index c78563f1c5ef7acc0df92be687cd5621a8c796fc..8d26cd4b4d80a28c69065794cfbaaca49eb4d5a7 100644 (file)
@@ -191,10 +191,9 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
         ){
           if( (pTerm->eOperator & WO_EQUIV)!=0
            && pScan->nEquiv<ArraySize(pScan->aiCur)
+           && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
           ){
             int j;
-            pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight);
-            assert( pX->op==TK_COLUMN );
             for(j=0; j<pScan->nEquiv; j++){
               if( pScan->aiCur[j]==pX->iTable
                && pScan->aiColumn[j]==pX->iColumn ){
index e5c0b40b1a48fb08afbedc73e73af75a9a9adb0a..0a9d7b35be104355e75dc46f838334cc79b5fbbc 100644 (file)
@@ -41,6 +41,16 @@ static void explainAppendTerm(
   sqlite3StrAccumAppend(pStr, "?", 1);
 }
 
+/*
+** Return the name of the i-th column of the pIdx index.
+*/
+static const char *explainIndexColumnName(Index *pIdx, int i){
+  i = pIdx->aiColumn[i];
+  if( i==(-2) ) return "<expr>";
+  if( i==(-1) ) return "rowid";
+  return pIdx->pTable->aCol[i].zName;
+}
+
 /*
 ** Argument pLevel describes a strategy for scanning table pTab. This 
 ** function appends text to pStr that describes the subset of table
@@ -60,13 +70,11 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop, Table *pTab){
   u16 nEq = pLoop->u.btree.nEq;
   u16 nSkip = pLoop->nSkip;
   int i, j;
-  Column *aCol = pTab->aCol;
-  i16 *aiColumn = pIndex->aiColumn;
 
   if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;
   sqlite3StrAccumAppend(pStr, " (", 2);
   for(i=0; i<nEq; i++){
-    char *z = aiColumn[i] < 0 ? "rowid" : aCol[aiColumn[i]].zName;
+    const char *z = explainIndexColumnName(pIndex, i);
     if( i>=nSkip ){
       explainAppendTerm(pStr, i, z, "=");
     }else{
@@ -77,11 +85,11 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop, Table *pTab){
 
   j = i;
   if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
-    char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName;
+    const char *z = explainIndexColumnName(pIndex, i);
     explainAppendTerm(pStr, i++, z, ">");
   }
   if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
-    char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName;
+    const char *z = explainIndexColumnName(pIndex, j);
     explainAppendTerm(pStr, i, z, "<");
   }
   sqlite3StrAccumAppend(pStr, ")", 1);