From: drh Date: Tue, 24 Feb 2015 16:48:59 +0000 (+0000) Subject: This additional fix prevents a partial index from being qualified for use X-Git-Tag: version-3.8.9~119^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=077f06edfa988588b93442b646a55bfb58ec9d92;p=thirdparty%2Fsqlite.git This additional fix prevents a partial index from being qualified for use if the constraint that qualifies the partial index is part of the ON clause of a LEFT JOIN. FossilOrigin-Name: 1a1516e4da26dcee35e6fbb6604ce252faf3d116 --- diff --git a/manifest b/manifest index 34750ae8f3..07b1467343 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\spartial\sautomatic\sindexes\sare\snot\sbased\son\sterms\sin\sthe\sON\sclause\nof\sa\sLEFT\sJOIN.\s\sFix\sfor\sticket\s[2326c258d02ead3]. -D 2015-02-24T16:05:54.976 +C This\sadditional\sfix\sprevents\sa\spartial\sindex\sfrom\sbeing\squalified\sfor\suse\s\nif\sthe\sconstraint\sthat\squalifies\sthe\spartial\sindex\sis\spart\sof\sthe\sON\sclause\sof\na\sLEFT\sJOIN. +D 2015-02-24T16:48:59.496 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -306,7 +306,7 @@ F src/vtab.c 699f2b8d509cfe379c33dde33827875d5b030e01 F src/wal.c 39303f2c9db02a4e422cd8eb2c8760420c6a51fe F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 59ab7da73b0de376d945c96c2867a1d550686717 +F src/where.c 88509f19a64a36e1c22a1dbdac74ee1a62d99dc3 F src/whereInt.h d3633e9b592103241b74b0ec76185f3e5b8b62e0 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -350,7 +350,7 @@ F test/autoinc.test c58912526998a39e11f66b533e23cfabea7f25b7 F test/autoindex1.test 6ff78b94f43a59616c06c11c55b12935173506d7 F test/autoindex2.test af7e595c6864cc6ef5fc38d5db579a3e34940cb8 F test/autoindex3.test a3be0d1a53a7d2edff208a5e442312957047e972 -F test/autoindex4.test 364be4c1654267720aa537beba4ef0ca4d7f60d9 +F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf F test/autovacuum.test 941892505d2c0f410a0cb5970dfa1c7c4e5f6e74 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 @@ -1239,7 +1239,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f8917ba4d917bc762b3b252466ab72a8a70dc0d8 -R 3f565b8438472847d9367d99d4186ffd +P c0f4e308a508183b72ceda447dc3ac778cb85b9f +R 4fd07aecba33e9248bb5425721691954 U drh -Z f1617e86199163d366d582f2564e1bac +Z 49115944492618e32f7d86cca0efe1da diff --git a/manifest.uuid b/manifest.uuid index 8ebe715cb4..36a5889cda 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0f4e308a508183b72ceda447dc3ac778cb85b9f \ No newline at end of file +1a1516e4da26dcee35e6fbb6604ce252faf3d116 \ No newline at end of file diff --git a/src/where.c b/src/where.c index aef1820e80..f45da74794 100644 --- a/src/where.c +++ b/src/where.c @@ -4695,7 +4695,11 @@ static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ int i; WhereTerm *pTerm; for(i=0, pTerm=pWC->a; inTerm; i++, pTerm++){ - if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1; + if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) + && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) + ){ + return 1; + } } return 0; } diff --git a/test/autoindex4.test b/test/autoindex4.test index 8e32462df4..0e7a80df21 100644 --- a/test/autoindex4.test +++ b/test/autoindex4.test @@ -68,6 +68,16 @@ do_execsql_test autoindex4-3.0 { WHERE Items.Name = 'Parent' ORDER BY Items.ItemName; } {Item1 Item2} +do_execsql_test autoindex4-3.1 { + CREATE INDEX Items_x1 ON Items(ItemName,Name) WHERE ItemName = 'dummy'; + + SELECT Items.ItemName + FROM Items + LEFT JOIN A ON (A.Name = Items.ItemName and Items.ItemName = 'dummy') + LEFT JOIN B ON (B.Name = Items.ItemName) + WHERE Items.Name = 'Parent' + ORDER BY Items.ItemName; +} {Item1 Item2} finish_test