]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When determining whether or not a partial index is usable, do not assume that the...
authordan <dan@noemail.net>
Wed, 27 Aug 2014 17:37:20 +0000 (17:37 +0000)
committerdan <dan@noemail.net>
Wed, 27 Aug 2014 17:37:20 +0000 (17:37 +0000)
FossilOrigin-Name: fcebca166f15431764b82a8b267f11d28386e975

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

index c45e2fe4fc47739ff82b4c733b67e9cc5aa33a18..284a4c0be0d146338d64d9597da4c14a6245dc68 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\sthe\ssqlite3_context\sobject,\skeep\sa\spointer\sto\sthe\sresult\svalue\srather\nthan\sstoring\sthe\sresult\svalue\sin\sthe\ssqlite3_context\sobject\sand\susing\nmemcpy()\sto\smove\sthe\svalue\sback\sinto\sits\sregister\nafter\sthe\sfunction\sreturns.\s\sThis\sruns\sfaster\sand\ssaves\sover\s500\sbytes\nof\scode\sspace.
-D 2014-08-27T14:14:06.320
+C When\sdetermining\swhether\sor\snot\sa\spartial\sindex\sis\susable,\sdo\snot\sassume\sthat\sthe\scursor\snumber\sassigned\sto\seach\stable\sin\sthe\squery\sis\sthe\ssame\sas\sits\sindex\sin\sthe\sFROM\sclause.\sFix\sfor\sticket\s[98d973b8f5].
+D 2014-08-27T17:37:20.006
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -297,7 +297,7 @@ F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
 F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45
-F src/where.c 4e2770a1914b8ce30f3e44ad954b720eca3b5efd
+F src/where.c b80cb72645390ba6d8b715a47f5696d27b4fc6c9
 F src/whereInt.h 923820bee9726033a501a08d2fc69b9c1ee4feb3
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -626,7 +626,7 @@ F test/index3.test 55a90cff99834305e8141df7afaef39674b57062
 F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6
 F test/index5.test fc07c14193c0430814e7a08b5da46888ee795c33
 F test/index6.test fb370966ac3cd0989053dd5385757b5c3e24ab6a
-F test/index7.test a3baf9a625bda7fd49471e99aeae04095fbfeecf
+F test/index7.test 4a1d3707e95067dfa069786baab124adedd55945
 F test/indexedby.test b2f22f3e693a53813aa3f50b812eb609ba6df1ec
 F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
 F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
@@ -1188,7 +1188,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 1624916c6e9bc5dbcfa146b316a99ac8fecb13a9
-R d81ba05103ba02a6e3d94271217446d4
-U drh
-Z 3300f3f8d44a1fbcab3339e234a49760
+P 6c1ee3e388eb110de815270467b1e50592c0ba6c
+R 464ad42e9750481b657eb9d5845e92c2
+U dan
+Z e49f678a3d5ba39b1ed4a3e5b185dc37
index 057a225c6134f0512fcbc20acbaf11c29cd699e4..52c4bd20c2c393e97cb7d9b822f35d637ef4aec4 100644 (file)
@@ -1 +1 @@
-6c1ee3e388eb110de815270467b1e50592c0ba6c
\ No newline at end of file
+fcebca166f15431764b82a8b267f11d28386e975
\ No newline at end of file
index 4ba8de6e4165baf91c2c9d64dfebe5b90bdd7e0d..22dfd0d0fa01371ce3bc01aae087eae1fa9e65ff 100644 (file)
@@ -4713,7 +4713,8 @@ static int whereLoopAddBtree(
   */
   for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){
     if( pProbe->pPartIdxWhere!=0
-     && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){
+     && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){
+      testcase( pNew->iTab!=pSrc->iCursor );  /* See ticket [98d973b8f5] */
       continue;  /* Partial index inappropriate for this query */
     }
     rSize = pProbe->aiRowLogEst[0];
index 1c81f6024bbf5bf1680d3eebf3e3959c45cf5dc8..49b64b7c5adadb4aee1c73c5763fc32d81811dfe 100644 (file)
@@ -248,4 +248,34 @@ do_execsql_test index7-5.0 {
   SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';
 } {6 6}
 
+# Verify that the problem identified by ticket [] has been fixed.
+#
+do_execsql_test index7-6.1 {
+  CREATE TABLE t5(a, b);
+  CREATE TABLE t4(c, d);
+  INSERT INTO t5 VALUES(1, 'xyz');
+  INSERT INTO t4 VALUES('abc', 'not xyz');
+  SELECT * FROM (SELECT * FROM t5 WHERE a=1 AND b='xyz'), t4 WHERE c='abc';
+} {
+  1 xyz abc {not xyz}
+}
+do_execsql_test index7-6.2 {
+  CREATE INDEX i4 ON t4(c) WHERE d='xyz';
+  SELECT * FROM (SELECT * FROM t5 WHERE a=1 AND b='xyz'), t4 WHERE c='abc';
+} {
+  1 xyz abc {not xyz}
+}
+do_execsql_test index7-6.3 {
+  CREATE VIEW v4 AS SELECT * FROM t4;
+  INSERT INTO t4 VALUES('def', 'xyz');
+  SELECT * FROM v4 WHERE d='xyz' AND c='def'
+} {
+  def xyz
+}
+do_eqp_test index7-6.4 {
+  SELECT * FROM v4 WHERE d='xyz' AND c='def'
+} {
+  0 0 0 {SEARCH TABLE t4 USING INDEX i4 (c=?)}
+}
+
 finish_test