/ Check-in [52885ed8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Handle the case where the estimated cost of a virtual table scan is larger than SQLITE_BIG_DBL. Ticket #2253. (CVS 3670)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 52885ed8b76a06588acf202a38b4feabfca1cfd1
User & Date: danielk1977 2007-03-02 08:12:22
Context
2007-03-04
13:15
Changes to the btree and pager that reduce the amount of I/O when dealing with the freelist. (1) Avoid journaling pages of a table that is being deleted. (2) Do not read the original content of pages being pulled off of the freelist. (CVS 3671) check-in: 2ba5be31 user: drh tags: trunk
2007-03-02
08:12
Handle the case where the estimated cost of a virtual table scan is larger than SQLITE_BIG_DBL. Ticket #2253. (CVS 3670) check-in: 52885ed8 user: danielk1977 tags: trunk
07:27
Disable the "SELECT max(rowid) ..." optimization for virtual tables. Ticket #2250. (CVS 3669) check-in: ddb4d0af user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is reponsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.238 2007/02/23 23:13:34 drh Exp $
           19  +** $Id: where.c,v 1.239 2007/03/02 08:12:22 danielk1977 Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
    25     25   */
    26     26   #define BMS  (sizeof(Bitmask)*8)
................................................................................
  1353   1353         sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc));
  1354   1354       }
  1355   1355       sqlite3SafetyOn(pParse->db);
  1356   1356     }else{
  1357   1357       rc = sqlite3SafetyOn(pParse->db);
  1358   1358     }
  1359   1359     *(int*)&pIdxInfo->nOrderBy = nOrderBy;
         1360  +
  1360   1361     return pIdxInfo->estimatedCost;
  1361   1362   }
  1362   1363   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  1363   1364   
  1364   1365   /*
  1365   1366   ** Find the best index for accessing a particular table.  Return a pointer
  1366   1367   ** to the index, flags that describe how the index should be used, the
................................................................................
  2039   2040           flags = WHERE_VIRTUALTABLE;
  2040   2041           pIndex = *ppIdxInfo;
  2041   2042           if( pIndex && pIndex->orderByConsumed ){
  2042   2043             flags = WHERE_VIRTUALTABLE | WHERE_ORDERBY;
  2043   2044           }
  2044   2045           pIdx = 0;
  2045   2046           nEq = 0;
         2047  +        if( (SQLITE_BIG_DBL/2.0)<cost ){
         2048  +          /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
         2049  +          ** inital value of lowestCost in this loop. If it is, then
         2050  +          ** the (cost<lowestCost) test below will never be true and
         2051  +          ** pLevel->pBestIdx never set.
         2052  +          */ 
         2053  +          cost = (SQLITE_BIG_DBL/2.0);
         2054  +        }
  2046   2055         }else 
  2047   2056   #endif
  2048   2057         {
  2049   2058           cost = bestIndex(pParse, &wc, pTabItem, notReady,
  2050   2059                            (i==0 && ppOrderBy) ? *ppOrderBy : 0,
  2051   2060                            &pIdx, &flags, &nEq);
  2052   2061           pIndex = 0;

Changes to test/vtab1.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is creating and dropping virtual tables.
    13     13   #
    14         -# $Id: vtab1.test,v 1.40 2007/02/21 16:52:12 danielk1977 Exp $
           14  +# $Id: vtab1.test,v 1.41 2007/03/02 08:12:23 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   ifcapable !vtab||!schema_pragmas {
    20     20     finish_test
    21     21     return
................................................................................
   886    886   } {0 1}
   887    887   do_test vtab1.11-5 {
   888    888     execsql {
   889    889       SELECT  glob(a,'2') FROM e
   890    890     }
   891    891   } {{2 1} {2 2}}
   892    892    
   893         -# See ticket #2244
   894         -#
   895         -do_test vtab1.2244-1 {
   896         -  execsql {
   897         -    CREATE TABLE t2244(a, b);
   898         -    CREATE VIRTUAL TABLE t2244e USING echo(t2244);
   899         -    INSERT INTO t2244 VALUES('AA', 'BB');
   900         -    INSERT INTO t2244 VALUES('CC', 'DD');
   901         -    SELECT rowid, * FROM t2244e;
   902         -  }
   903         -} {1 AA BB 2 CC DD}
   904         -do_test vtab1.2244-2 {
   905         -  execsql {
   906         -    SELECT * FROM t2244e WHERE rowid = 10;
   907         -  }
   908         -} {}
   909         -do_test vtab1.2244-3 {
   910         -  execsql {
   911         -    UPDATE t2244e SET a = 'hello world' WHERE 0;
   912         -    SELECT rowid, * FROM t2244e;
   913         -  }
   914         -} {1 AA BB 2 CC DD}
   915    893   
   916    894   unset -nocomplain echo_module_begin_fail
   917    895   finish_test

Changes to test/vtab8.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file inserting into virtual tables from a SELECT
    13     13   # statement.
    14     14   #
    15         -# $Id: vtab8.test,v 1.1 2007/03/02 07:27:01 danielk1977 Exp $
           15  +# $Id: vtab8.test,v 1.2 2007/03/02 08:12:23 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   ifcapable !vtab {
    21     21     finish_test
    22     22     return
................................................................................
    53     53       INSERT INTO t2250 VALUES(10, 20);
    54     54       CREATE VIRTUAL TABLE t2250e USING echo(t2250);
    55     55       select max(rowid) from t2250;
    56     56       select max(rowid) from t2250e;
    57     57     }
    58     58   } {1 1}
    59     59   
    60         -# See ticket #2260 (note: this test doesn't trigger the bug yet - it's a
    61         -# work in progress).
           60  +# See ticket #2260.
    62     61   #
    63     62   do_test vtab1.2260-1 {
    64     63     execsql {
    65     64       CREATE TABLE t2260a_real(a, b);
    66     65       CREATE TABLE t2260b_real(a, b);
    67     66   
    68     67       CREATE INDEX i2260 ON t2260a_real(a);