From: dan Date: Thu, 29 Aug 2013 10:46:05 +0000 (+0000) Subject: Candidate fix for [9f2eb3abac]: Have the whereShortCut() planner ignore indexes with... X-Git-Tag: version-3.8.1~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd40abb297737d50e32d9f60aa55515226f42cc2;p=thirdparty%2Fsqlite.git Candidate fix for [9f2eb3abac]: Have the whereShortCut() planner ignore indexes with more than four columns. FossilOrigin-Name: c1152bdcbb5ac185f743015fff63769effa81b4b --- diff --git a/manifest b/manifest index b049cf4d48..c896281d95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Small\senhancements\sto\sunit\stesting\sinfrastructure. -D 2013-08-29T01:09:14.083 +C Candidate\sfix\sfor\s[9f2eb3abac]:\sHave\sthe\swhereShortCut()\splanner\signore\sindexes\swith\smore\sthan\sfour\scolumns. +D 2013-08-29T10:46:05.710 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -290,7 +290,7 @@ F src/vtab.c 165ce0e797c2cd23badb104c9f2ae9042d6d942c F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 -F src/where.c e0b70ec707e208af37b436eaa829b038cc55e545 +F src/where.c dab4d4b8f415e876e5acf63e55f7023fef42316b F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -859,6 +859,7 @@ F test/tkt-868145d012.test a5f941107ece6a64410ca4755c6329b7eb57a356 F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 F test/tkt-94c04eaadb.test fa9c71192f7e2ea2d51bf078bc34e8da6088bf71 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 +F test/tkt-9f2eb3abac.test 85bc63e749f050e6a61c8f9207f1eee65c9d3395 F test/tkt-a7b7803e.test 159ef554234fa1f9fb318c751b284bd1cf858da4 F test/tkt-b1d3a2e531.test 610ef582413171b379652663111b1f996d9f8f78 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 @@ -1108,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 6c709338bc77fbed24a2597eabd88dd8c29b38d7 -R c45150e3b7004e4a0ed3f6fa3be34cd1 -U mistachkin -Z 89e12299b0f96674ea40270259273327 +P 9229aeb361f9805894321327d05aba855b8799f3 +R cdb2a97ae7b02b85f8d964c7dea1a83c +U dan +Z 5d34b767de2885354c0587f1fafecb4c diff --git a/manifest.uuid b/manifest.uuid index 03763eea4b..1641c63a70 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9229aeb361f9805894321327d05aba855b8799f3 \ No newline at end of file +c1152bdcbb5ac185f743015fff63769effa81b4b \ No newline at end of file diff --git a/src/where.c b/src/where.c index d9a795e4ea..a8584a275f 100644 --- a/src/where.c +++ b/src/where.c @@ -5536,11 +5536,15 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ pLoop->rRun = 33; /* 33==whereCost(10) */ }else{ for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue; + assert( pLoop->aLTermSpace==pLoop->aLTerm ); + assert( ArraySize(pLoop->aLTermSpace)==4 ); + if( pIdx->onError==OE_None + || pIdx->pPartIdxWhere!=0 + || pIdx->nColumn>ArraySize(pLoop->aLTermSpace) + ) continue; for(j=0; jnColumn; j++){ pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); if( pTerm==0 ) break; - whereLoopResize(pWInfo->pParse->db, pLoop, j); pLoop->aLTerm[j] = pTerm; } if( j!=pIdx->nColumn ) continue; diff --git a/test/tkt-9f2eb3abac.test b/test/tkt-9f2eb3abac.test new file mode 100644 index 0000000000..5b93733afe --- /dev/null +++ b/test/tkt-9f2eb3abac.test @@ -0,0 +1,79 @@ + +# 2013 August 29 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/malloc_common.tcl +set ::testprefix tkt-9f2eb3abac + +do_execsql_test 1.1 { + CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,d,e)); + SELECT * FROM t1 WHERE a=? AND b=? AND c=? AND d=? AND e=?; +} {} + +do_execsql_test 1.2 { + CREATE TABLE "a" ( + "b" integer NOT NULL, + "c" integer NOT NULL, + PRIMARY KEY ("b", "c") + ); + + CREATE TABLE "d" ( + "e" integer NOT NULL, + "g" integer NOT NULL, + "f" integer NOT NULL, + "h" integer NOT NULL, + "i" character(10) NOT NULL, + "j" int, + PRIMARY KEY ("e", "g", "f", "h") + ); + + CREATE TABLE "d_to_a" ( + "f_e" integer NOT NULL, + "f_g" integer NOT NULL, + "f_f" integer NOT NULL, + "f_h" integer NOT NULL, + "t_b" integer NOT NULL, + "t_c" integer NOT NULL, + "r" character NOT NULL, + "s" integer, + PRIMARY KEY ("f_e", "f_g", "f_f", "f_h", "t_b", "t_c") + ); + + INSERT INTO d (g, e, h, f, j, i) VALUES ( 1, 1, 1, 1, 1, 1 ); + INSERT INTO a (b, c) VALUES ( 1, 1 ); + INSERT INTO d_to_a VALUES (1, 1, 1, 1, 1, 1, 1, 1); + + DELETE FROM d_to_a + WHERE f_g = 1 AND f_e = 1 AND f_h = 1 AND f_f = 1 AND t_b = 1 AND t_c = 1; + + SELECT * FROM d_to_a; +} {} + +faultsim_delete_and_reopen +do_execsql_test 2.0 { CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,d,e)) } +do_execsql_test 2.1 { CREATE TABLE t2(x) } +faultsim_save_and_close + +do_faultsim_test 3 -faults oom* -prep { + faultsim_restore_and_reopen + execsql { SELECT 1 FROM sqlite_master } +} -body { + execsql { SELECT * FROM t1,t2 WHERE a=? AND b=? AND c=? AND d=? AND e=? } +} -test { + faultsim_test_result {0 {}} +} + +finish_test +