/ Check-in [98357d8c]
Login

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

Overview
Comment:Ensure that the optional "sz=N" parameter that can be manually added to the end of an sqlite_stat1 entry does not have an N value that is too small. Ticket [e4598ecbdd18bd82]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 98357d8c1263920b33a3648ef9214a63c99728bafa7a8d3dd6a1241b2303fd42
User & Date: drh 2019-08-15 14:35:45
Context
2019-08-15
21:27
Add the SQLITE_DBCONFIG_ENABLE_VIEW option, together with a "db config" command in the TCL interface that can access that option as well as all the other sqlite3_db_config() boolean options. check-in: 61b4bccd user: drh tags: trunk
20:04
Provide the SQLITE_DIRECTONLY flag for app-defined functions that prohibits the use of those functions within triggers or views. Closed-Leaf check-in: fc745845 user: drh tags: directonly
14:35
Ensure that the optional "sz=N" parameter that can be manually added to the end of an sqlite_stat1 entry does not have an N value that is too small. Ticket [e4598ecbdd18bd82] check-in: 98357d8c user: drh tags: trunk
13:53
Ensure that SQLite does not attempt to process incompatible window functions in a single scan. Fix for [256741a1]. check-in: 4f5b2d93 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

  1446   1446   #endif
  1447   1447       pIndex->bUnordered = 0;
  1448   1448       pIndex->noSkipScan = 0;
  1449   1449       while( z[0] ){
  1450   1450         if( sqlite3_strglob("unordered*", z)==0 ){
  1451   1451           pIndex->bUnordered = 1;
  1452   1452         }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
  1453         -        pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));
         1453  +        int sz = sqlite3Atoi(z+3);
         1454  +        if( sz<2 ) sz = 2;
         1455  +        pIndex->szIdxRow = sqlite3LogEst(sz);
  1454   1456         }else if( sqlite3_strglob("noskipscan*", z)==0 ){
  1455   1457           pIndex->noSkipScan = 1;
  1456   1458         }
  1457   1459   #ifdef SQLITE_ENABLE_COSTMULT
  1458   1460         else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
  1459   1461           pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
  1460   1462         }

Changes to src/where.c.

  2666   2666         }
  2667   2667       }
  2668   2668   
  2669   2669       /* Set rCostIdx to the cost of visiting selected rows in index. Add
  2670   2670       ** it to pNew->rRun, which is currently set to the cost of the index
  2671   2671       ** seek only. Then, if this is a non-covering index, add the cost of
  2672   2672       ** visiting the rows in the main table.  */
         2673  +    assert( pSrc->pTab->szTabRow>0 );
  2673   2674       rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;
  2674   2675       pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);
  2675   2676       if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
  2676   2677         pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);
  2677   2678       }
  2678   2679       ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult);
  2679   2680   

Changes to test/analyzeC.test.

   127    127     ANALYZE sqlite_master;
   128    128     SELECT count(a) FROM t1;
   129    129   } {6}
   130    130   do_execsql_test 4.3 {
   131    131     EXPLAIN QUERY PLAN
   132    132     SELECT count(a) FROM t1;
   133    133   } {/.*INDEX t1ca.*/}
          134  +
          135  +# 2019-08-15.
          136  +# Ticket https://www.sqlite.org/src/tktview/e4598ecbdd18bd82945f602901
          137  +# The sz=N parameter in the sqlite_stat1 table needs to have a value of
          138  +# 2 or more to avoid a division by zero in the query planner.
          139  +#
          140  +do_execsql_test 4.4 {
          141  +  DROP TABLE IF EXISTS t44;
          142  +  CREATE TABLE t44(a PRIMARY KEY);
          143  +  INSERT INTO sqlite_stat1 VALUES('t44',null,'sz=0');
          144  +  ANALYZE sqlite_master;
          145  +  SELECT 0 FROM t44 WHERE a IN(1,2,3);
          146  +} {}
          147  +
   134    148   
   135    149   
   136    150   # The sz=NNN parameter works even if there is other extraneous text
   137    151   # in the sqlite_stat1.stat column.
   138    152   #
   139    153   do_execsql_test 5.0 {
   140    154     DELETE FROM sqlite_stat1;