]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug in where.c causing a malfunction when an INDEXED BY clause specified an...
authordanielk1977 <danielk1977@noemail.net>
Tue, 30 Dec 2008 09:45:45 +0000 (09:45 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 30 Dec 2008 09:45:45 +0000 (09:45 +0000)
FossilOrigin-Name: f8ff0212129ce602a1e1e9ad702c47b9302f2f21

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

index 9285137a2edef42acc53fe05a0750459cbe5cb4d..565be866fee0a2986e8ccae2b186972ca6f92e4f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sbug\sin\sREADME.tokenizers.\sTicket\s#3559.\s(CVS\s6075)
-D 2008-12-30T06:36:51
+C Fix\sa\sbug\sin\swhere.c\scausing\sa\smalfunction\swhen\san\sINDEXED\sBY\sclause\sspecified\san\sunusable\sindex\son\sother\sthan\sthe\sleftmost\stable\sin\sthe\sFROM\sclause.\sTicket\s#3560.\s(CVS\s6076)
+D 2008-12-30T09:45:46
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 77635d0909c2067cee03889a1e04ce910d8fb809
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -207,7 +207,7 @@ F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
 F src/vdbemem.c f9c859ac17e2e05a0f249868ce4f191f69edd31d
 F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
 F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
-F src/where.c d0f422dd1a72a59484af77433412af53da63c78a
+F src/where.c 1e1cadcfda4c2606c23c03844268d4b90f5f048d
 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@@ -391,7 +391,7 @@ F test/incrvacuum_ioerr.test 57d2f5777ab13fa03b87b262a4ea1bad5cfc0291
 F test/index.test cbf301cdb2da43e4eac636c3400c2439af1834ad
 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
 F test/index3.test 727d55dceb9a4ec36675057bb5becfc265e28ca6
-F test/indexedby.test 03af52375e50d146e78f56442b6677d2932c4963
+F test/indexedby.test bcf239ccdc5ac6112110136f8481b40dcd070164
 F test/insert.test aef273dd1cee84cc92407469e6bd1b3cdcb76908
 F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435
 F test/insert3.test 7188f1da1126eb15f1b27cf34f4c2753c7d5fd27
@@ -687,7 +687,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P e49807b16f7f86d3f2290d6c1f7562f3db6330f9
-R 45eb8d1c87cec4e4583352d46a05ae31
+P b8898d132e84888dc7c51b2f1ab67f78cc21f31b
+R b7839f0e2e3e66238c8ec07900a2d5d4
 U danielk1977
-Z 92973555b0dc8dd6b677002c21a4cbbb
+Z 3f55cc2a8dd0beb6d8e0657bdc1d6da5
index 65fc03d9c8c9673d7c4e50a46dd6adb97672ddd2..29c63f3a8f5e6ad03c3a07da3d33ad9cff0861b3 100644 (file)
@@ -1 +1 @@
-b8898d132e84888dc7c51b2f1ab67f78cc21f31b
\ No newline at end of file
+f8ff0212129ce602a1e1e9ad702c47b9302f2f21
\ No newline at end of file
index 769b70ac41f01409f6bbdd8c40774109f689ced7..2efd6842c4953a619b32c75aa12913a468a06d1c 100644 (file)
@@ -16,7 +16,7 @@
 ** so is applicable.  Because this module is responsible for selecting
 ** indices, you might also think of this module as the "query optimizer".
 **
-** $Id: where.c,v 1.350 2008/12/29 23:45:07 drh Exp $
+** $Id: where.c,v 1.351 2008/12/30 09:45:46 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -3104,13 +3104,15 @@ WhereInfo *sqlite3WhereBegin(
         bestIndex(pParse, pWC, pTabItem, notReady,
                   (i==0 && ppOrderBy) ? *ppOrderBy : 0, &sCost);
       }
-      if( sCost.rCost<bestPlan.rCost ){
+      if( once==0 || sCost.rCost<bestPlan.rCost ){
         once = 1;
         bestPlan = sCost;
         bestJ = j;
       }
       if( doNotReorder ) break;
     }
+    assert( once );
+    assert( notReady & getMask(pMaskSet, pTabList->a[bestJ].iCursor) );
     WHERETRACE(("*** Optimizer selects table %d for loop %d\n", bestJ,
            pLevel-pWInfo->a));
     if( (bestPlan.plan.wsFlags & WHERE_ORDERBY)!=0 ){
index 85fcd2f0cfe9772dcb4d9c78280fffddce5badb5..38750e74f76f41713dfcb89f488f391d7b695bff 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: indexedby.test,v 1.3 2008/10/06 16:18:40 danielk1977 Exp $
+# $Id: indexedby.test,v 1.4 2008/12/30 09:45:46 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -204,5 +204,26 @@ do_test indexedby-8.6 {
   catchsql { UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5}
 } {1 {cannot use index: i2}}
 
+# Test that bug #3560 is fixed.
+#
+do_test indexedby-9.1 {
+  execsql {
+    CREATE TABLE maintable( id integer);
+    CREATE TABLE joinme(id_int integer, id_text text);
+    CREATE INDEX joinme_id_text_idx on joinme(id_text);
+    CREATE INDEX joinme_id_int_idx on joinme(id_int);
+  }
+} {}
+do_test indexedby-9.2 {
+  catchsql {
+    select * from maintable as m inner join
+    joinme as j indexed by joinme_id_text_idx
+    on ( m.id  = j.id_int)
+  }
+} {1 {cannot use index: joinme_id_text_idx}}
+do_test indexedby-9.3 {
+  catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx }
+} {1 {cannot use index: joinme_id_text_idx}}
+
 finish_test