-C Fixes\sfor\scompilation/testing\swhen\sthe\svarious\sOMIT\smacros\sare\sdefined.\s(CVS\s4423)
-D 2007-09-12T17:01:45
+C Fix\sincorrect\sindex\scost\sassumptions\sthat\soccur\safter\san\sANALYZE.\nTicket\s#2643.\s(CVS\s4424)
+D 2007-09-13T17:54:40
F Makefile.in cbfb898945536a8f9ea8b897e1586dd1fdbcc5db
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 246d434fa60bde6553490eb686adfd86adcd6712
F src/vtab.c 6776605198e0b844391335f1b77e3595b3616331
-F src/where.c 1b3a67bba14cb19b44496090a66f58370b8c768d
+F src/where.c 44042c8b9d0d054cc318c3a0df052215ebf49d2d
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test b59d1bd8b0c1d4a08b845e8af48fd43926f01f11
F test/tkt2409.test 20318bf6acd9b834b4420548f277b8e3a7420cd1
F test/tkt2450.test 77ed94863f2049c1420288ddfea2d41e5e0971d6
F test/tkt2640.test c513e7992a602a87ef3a2cc9ca1cba4146924e9b
+F test/tkt2643.test 3f3ebb743da00d4fed4fcf6daed92a0e18e57813
F test/trace.test 75ffc1b992c780d054748a656e3e7fd674f18567
F test/trans.test b73289992b46d38d9479ecc4fdc03d8edb2413dc
F test/trigger1.test b361161cf20614024cc1e52ea0bdec250776b2ae
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 9c9c2a1da2b6235b3b0541d1f55a02a1f350567f
-R e714a99afd32daf4589c0492f0d973f7
-U danielk1977
-Z 3ca4821de1ee59d63f410052e38375a2
+P c8405b15c074c94dab5e33272cf1471f458d11df
+R b946fdafcbe6e914052dcda867e14d99
+U drh
+Z c838890951ff9cb355602e662e43675b
-c8405b15c074c94dab5e33272cf1471f458d11df
\ No newline at end of file
+2cfdbfe6543bac42961deecec7d085d806e604b5
\ No newline at end of file
** 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.260 2007/09/12 15:41:01 drh Exp $
+** $Id: where.c,v 1.261 2007/09/13 17:54:40 drh Exp $
*/
#include "sqliteInt.h"
&& nEq==pProbe->nColumn ){
flags |= WHERE_UNIQUE;
}
- WHERETRACE(("...... nEq=%d inMult=%.9g cost=%.9g\n", nEq, inMultiplier, cost));
+ WHERETRACE(("...... nEq=%d inMult=%.9g cost=%.9g\n",nEq,inMultiplier,cost));
/* Look for range constraints
*/
/* If this index has achieved the lowest cost so far, then use it.
*/
- if( cost < lowestCost ){
+ if( flags && cost < lowestCost ){
bestIdx = pProbe;
lowestCost = cost;
- assert( flags!=0 );
bestFlags = flags;
bestNEq = nEq;
}
--- /dev/null
+# 2007 Sep 12
+#
+# 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 is to test that ticket #2643 has been fixed.
+#
+# $Id: tkt2643.test,v 1.1 2007/09/13 17:54:41 drh Exp $
+#
+
+# The problem in ticket #2643 has to do with the query optimizer
+# making bad assumptions about index cost when data from ANALYZE
+# is available.
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt2643-1.1 {
+ execsql {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(2,3,4);
+ ANALYZE;
+ }
+ db close
+ sqlite3 db test.db
+ execsql {
+ CREATE INDEX i1 ON t1(c);
+ SELECT count(*) FROM t1 WHERE c IS NOT NULL
+ }
+} {2}
+
+finish_test