From: danielk1977 Date: Tue, 30 Dec 2008 09:45:45 +0000 (+0000) Subject: Fix a bug in where.c causing a malfunction when an INDEXED BY clause specified an... X-Git-Tag: version-3.6.10~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=992347f2edd257e7c87f111dade62383745f41ed;p=thirdparty%2Fsqlite.git Fix a bug in where.c causing a malfunction when an INDEXED BY clause specified an unusable index on other than the leftmost table in the FROM clause. Ticket #3560. (CVS 6076) FossilOrigin-Name: f8ff0212129ce602a1e1e9ad702c47b9302f2f21 --- diff --git a/manifest b/manifest index 9285137a2e..565be866fe 100644 --- 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 diff --git a/manifest.uuid b/manifest.uuid index 65fc03d9c8..29c63f3a8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8898d132e84888dc7c51b2f1ab67f78cc21f31b \ No newline at end of file +f8ff0212129ce602a1e1e9ad702c47b9302f2f21 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 769b70ac41..2efd6842c4 100644 --- a/src/where.c +++ b/src/where.c @@ -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.rCosta[bestJ].iCursor) ); WHERETRACE(("*** Optimizer selects table %d for loop %d\n", bestJ, pLevel-pWInfo->a)); if( (bestPlan.plan.wsFlags & WHERE_ORDERBY)!=0 ){ diff --git a/test/indexedby.test b/test/indexedby.test index 85fcd2f0cf..38750e74f7 100644 --- a/test/indexedby.test +++ b/test/indexedby.test @@ -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