]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplified error detection in the xBestIndex processing.
authordrh <drh@noemail.net>
Tue, 8 Mar 2016 02:59:33 +0000 (02:59 +0000)
committerdrh <drh@noemail.net>
Tue, 8 Mar 2016 02:59:33 +0000 (02:59 +0000)
FossilOrigin-Name: 82ca2131b670505578628687746135ac413d156b

manifest
manifest.uuid
src/where.c
test/vtab6.test

index 4cdc82a8c0f124e7bbbbbb21f7db79adb2e11ec1..02f759a6444a7625b54f78efd0ec8190c1970d12 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\sALLBITS\smacro\sas\sa\sshorthand\sfor\s"(Bitmask)(-1)".
-D 2016-03-08T01:32:30.559
+C Simplified\serror\sdetection\sin\sthe\sxBestIndex\sprocessing.
+D 2016-03-08T02:59:33.371
 F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66
@@ -428,7 +428,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 e4d2d0ea8403339db188e75b75ca44fff225abba
+F src/where.c dff52f7f0842430f80a7017c7859124685b08453
 F src/whereInt.h 93297d56edd137b7ea004490690fb6e2ce028a34
 F src/wherecode.c 863aedf086131743763c1960637fde904eadc442
 F src/whereexpr.c fb87944b1254234e5bba671aaf6dee476241506a
@@ -1286,7 +1286,7 @@ F test/vtab2.test f8cd1bb9aba7143eba97812d9617880a36d247ad
 F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e
 F test/vtab4.test 8e73ed268f3d596bc3590f45fc948fb40f28e9c3
 F test/vtab5.test 889f444970393c73f1e077e2bdc5d845e157a391
-F test/vtab6.test d2986cf418dc51e7fb81d12366bea2caa8b812df
+F test/vtab6.test 8e789f526e6594cf7ae933d1adee0caa87dc9f78
 F test/vtab7.test ae560ebea870ed04e9aa4177cc302f910faaabb5
 F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
 F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
@@ -1454,7 +1454,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 721ae51e443647291f3a8f7f2128aa410fee2682
-R 06f3b1fde5a5e4d09bcfebd9ae1525b6
+P 91bd619d27e4d91510a187bbb88de961a31c8a2e
+R 925559caeda122c2e0a2ca4fc28cc0ee
 U drh
-Z acf689ff3c45ad889c44d18cadd3bf9c
+Z b4b54118bbf4d13b5c60372c03985e73
index 78794d5451e2b8be8e13368594645344a244bb32..21eda15faa7c392e35a2f63e5e3161945b3abac7 100644 (file)
@@ -1 +1 @@
-91bd619d27e4d91510a187bbb88de961a31c8a2e
\ No newline at end of file
+82ca2131b670505578628687746135ac413d156b
\ No newline at end of file
index 7510839791616754465cb8f05c545d387c9eb3d7..2d7272a74276394249822d4b486770d59d805a83 100644 (file)
@@ -934,7 +934,6 @@ static sqlite3_index_info *allocateIndexInfo(
 */
 static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
   sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab;
-  int i;
   int rc;
 
   TRACE_IDX_INPUTS(p);
@@ -953,12 +952,16 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
   sqlite3_free(pVtab->zErrMsg);
   pVtab->zErrMsg = 0;
 
+#if 0
+  /* This error is now caught by the caller.
+  ** Search for "xBestIndex malfunction" below */
   for(i=0; i<p->nConstraint; i++){
     if( !p->aConstraint[i].usable && p->aConstraintUsage[i].argvIndex>0 ){
       sqlite3ErrorMsg(pParse, 
           "table %s: xBestIndex returned an invalid plan", pTab->zName);
     }
   }
+#endif
 
   return pParse->nErr;
 }
@@ -2835,9 +2838,10 @@ static int whereLoopAddVirtualOne(
        || j<0
        || j>=pWC->nTerm
        || pNew->aLTerm[iTerm]!=0
+       || pIdxCons->usable==0
       ){
         rc = SQLITE_ERROR;
-        sqlite3ErrorMsg(pParse,"%s.xBestIndex() malfunction",pSrc->pTab->zName);
+        sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName);
         return rc;
       }
       testcase( iTerm==nConstraint-1 );
@@ -2859,7 +2863,7 @@ static int whereLoopAddVirtualOne(
         ** together.  */
         pIdxInfo->orderByConsumed = 0;
         pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
-        *pbIn = 1;
+        *pbIn = 1; assert( (mExclude & WO_IN)==0 );
       }
     }
   }
@@ -2972,10 +2976,11 @@ static int whereLoopAddVirtual(
     ** xBestIndex again, this time with IN(...) terms disabled. */
     if( rc==SQLITE_OK && bIn ){
       rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, WO_IN, p, &bIn);
+      assert( bIn==0 );
       mBestNoIn = pNew->prereq & ~mPrereq;
       if( mBestNoIn==0 ){
         seenZero = 1;
-        if( bIn==0 ) seenZeroNoIN = 1;
+        seenZeroNoIN = 1;
       }
     }
 
index f8e0935a2835976da9d79fe62285c603466027ed..f4504b017ddde64270f6f1e89704dbaddd389ff4 100644 (file)
@@ -566,12 +566,12 @@ do_test vtab6-11.4.1 {
   catchsql {
     SELECT a, b, c FROM ab NATURAL JOIN bc;
   }
-} {1 {table ab: xBestIndex returned an invalid plan}}
+} {1 {ab.xBestIndex malfunction}}
 do_test vtab6-11.4.2 {
   catchsql {
     SELECT a, b, c FROM bc NATURAL JOIN ab;
   }
-} {1 {table bc: xBestIndex returned an invalid plan}}
+} {1 {bc.xBestIndex malfunction}}
 
 unset ::echo_module_ignore_usable