]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Handle the case where the estimated cost of a virtual table scan is larger than SQLIT...
authordanielk1977 <danielk1977@noemail.net>
Fri, 2 Mar 2007 08:12:22 +0000 (08:12 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 2 Mar 2007 08:12:22 +0000 (08:12 +0000)
FossilOrigin-Name: 52885ed8b76a06588acf202a38b4feabfca1cfd1

manifest
manifest.uuid
src/where.c
test/vtab1.test
test/vtab8.test

index db6ac756a3e6e3fc3db7fa610d265c23e37e6aac..7a4b47c32967dce51eb3fc04f3d364800f1bd10d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Disable\sthe\s"SELECT\smax(rowid)\s..."\soptimization\sfor\svirtual\stables.\sTicket\s#2250.\s(CVS\s3669)
-D 2007-03-02T07:27:00
+C Handle\sthe\scase\swhere\sthe\sestimated\scost\sof\sa\svirtual\stable\sscan\sis\slarger\sthan\sSQLITE_BIG_DBL.\sTicket\s#2253.\s(CVS\s3670)
+D 2007-03-02T08:12:22
 F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -129,7 +129,7 @@ F src/vdbeaux.c 666f0753f7d70b6a092c7f2074ae8cf1f9755cfc
 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
 F src/vdbemem.c ff2424bee9eaf7c61d1f28bc0e711bebddebd653
 F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
-F src/where.c d4a10cf428e5bf855e8a7f6c6a95119ca93489f0
+F src/where.c 1242dd545ffa7be8b2f539984d5f458ec731a937
 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/all.test b62fcd122052efaff1b0979aefa2dd65cfc8ee52
@@ -348,14 +348,14 @@ F test/vacuum.test cf839fc3ff24d601057319bbb5c700ce9c8e0fb0
 F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
 F test/view.test 852bd4101e6d171c46ad682eb5c5faf662b2eba4
-F test/vtab1.test bbfeb479bc851993403d7f08cf071b34d0e3b4c2
+F test/vtab1.test 92410029a2679c8751635ecaa023cf54bc5ab4eb
 F test/vtab2.test 94bb3bf691ac10e34cf7dad46b1cf94b861d513c
 F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
 F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87
 F test/vtab5.test 9fb8f335651afe8f870011e2f68e5b00c5ad03cd
 F test/vtab6.test ec0036f29f8a803da9935206f2d9d1b6a8026392
 F test/vtab7.test 5f9ef9fb84733e928d5d0267c821072561b198d5
-F test/vtab8.test 31b61c3caeb18c9166483b53c9fc911dd0bf08ff
+F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
 F test/vtab9.test 87afba55339b0c255e9697fbfb5bfb6120505d9d
 F test/vtab_err.test 224cc80ad700797c48b9cd2c1e0bd7a8517d8609
 F test/where.test 1d020f50c77f37b2dbab9766ca959e6e3278ecdb
@@ -435,7 +435,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 8d3829cdb35f41bc7a2e6f945e9aa83987513104
-R a8c74ef4df5791aca2f931fcffb9fa89
+P ddb4d0af5770c7030fe6e92119972c9508724b9a
+R 35703e5b3fc1d8c9b1249f60db5a29c1
 U danielk1977
-Z 81b4e3cb66e26f39332d05ca445f394b
+Z cc77ee9ae5f32f8281d9b31d7adeb8f2
index 0fec9d6b4e6c9ad25c108010de7e1fb547cc78f2..6a83391b2fd83149dfbc237ea30486fbea8bf9ab 100644 (file)
@@ -1 +1 @@
-ddb4d0af5770c7030fe6e92119972c9508724b9a
\ No newline at end of file
+52885ed8b76a06588acf202a38b4feabfca1cfd1
\ No newline at end of file
index ad7e12c88a9165b4c9585e796161e9f57fc9d731..a3b49ccb1ea44643a7b0da432cd88f3a4300dca2 100644 (file)
@@ -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.238 2007/02/23 23:13:34 drh Exp $
+** $Id: where.c,v 1.239 2007/03/02 08:12:22 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -1357,6 +1357,7 @@ static double bestVirtualIndex(
     rc = sqlite3SafetyOn(pParse->db);
   }
   *(int*)&pIdxInfo->nOrderBy = nOrderBy;
+
   return pIdxInfo->estimatedCost;
 }
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -2043,6 +2044,14 @@ WhereInfo *sqlite3WhereBegin(
         }
         pIdx = 0;
         nEq = 0;
+        if( (SQLITE_BIG_DBL/2.0)<cost ){
+          /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
+          ** inital value of lowestCost in this loop. If it is, then
+          ** the (cost<lowestCost) test below will never be true and
+          ** pLevel->pBestIdx never set.
+          */ 
+          cost = (SQLITE_BIG_DBL/2.0);
+        }
       }else 
 #endif
       {
index 57e9b7dbf4e031c33527ac89314a5d6f8ec6d5d3..b451a773ec7633fa19a79d9296c516e8c47bd697 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is creating and dropping virtual tables.
 #
-# $Id: vtab1.test,v 1.40 2007/02/21 16:52:12 danielk1977 Exp $
+# $Id: vtab1.test,v 1.41 2007/03/02 08:12:23 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -890,28 +890,6 @@ do_test vtab1.11-5 {
   }
 } {{2 1} {2 2}}
  
-# See ticket #2244
-#
-do_test vtab1.2244-1 {
-  execsql {
-    CREATE TABLE t2244(a, b);
-    CREATE VIRTUAL TABLE t2244e USING echo(t2244);
-    INSERT INTO t2244 VALUES('AA', 'BB');
-    INSERT INTO t2244 VALUES('CC', 'DD');
-    SELECT rowid, * FROM t2244e;
-  }
-} {1 AA BB 2 CC DD}
-do_test vtab1.2244-2 {
-  execsql {
-    SELECT * FROM t2244e WHERE rowid = 10;
-  }
-} {}
-do_test vtab1.2244-3 {
-  execsql {
-    UPDATE t2244e SET a = 'hello world' WHERE 0;
-    SELECT rowid, * FROM t2244e;
-  }
-} {1 AA BB 2 CC DD}
 
 unset -nocomplain echo_module_begin_fail
 finish_test
index b147adbb098da32cd68cf8c153128a8b6a965758..8e04a4155f18d7b5f11c7de61b857a50bf1cdfe6 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file inserting into virtual tables from a SELECT
 # statement.
 #
-# $Id: vtab8.test,v 1.1 2007/03/02 07:27:01 danielk1977 Exp $
+# $Id: vtab8.test,v 1.2 2007/03/02 08:12:23 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -57,8 +57,7 @@ do_test vtab1-2250-2 {
   }
 } {1 1}
 
-# See ticket #2260 (note: this test doesn't trigger the bug yet - it's a
-# work in progress).
+# See ticket #2260.
 #
 do_test vtab1.2260-1 {
   execsql {