/ Check-in [46d04059]
Login

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

Overview
Comment:Make sure the WhereLoop.aLTerm[] array is large enough when processing the skip-scan optimization. Fix for ticket [520070ec7fbaac].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 46d040591f27be01b1860344f8a268797fe344f4
User & Date: drh 2013-12-22 20:44:10
Context
2013-12-23
15:35
Make sure the WhereLoop.aLTerm[] array is large enough when processing the skip-scan optimization. Fix for ticket [520070ec7fbaac]. check-in: ac5852d6 user: drh tags: branch-3.8.2
2013-12-22
22:45
Remove a condition that is always in the logic that handles reading default values for columns. check-in: 895af097 user: drh tags: trunk
20:44
Make sure the WhereLoop.aLTerm[] array is large enough when processing the skip-scan optimization. Fix for ticket [520070ec7fbaac]. check-in: 46d04059 user: drh tags: trunk
2013-12-21
17:14
Fix speedtest1.c so that in --explain mode it only outputs non-explain text for DDL statements. check-in: 2d2b3c49 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3924   3924     ** number 18 was found by experimentation to be the payoff point where
  3925   3925     ** skip-scan become faster than a full-scan.
  3926   3926     */
  3927   3927     if( pTerm==0
  3928   3928      && saved_nEq==saved_nSkip
  3929   3929      && saved_nEq+1<pProbe->nKeyCol
  3930   3930      && pProbe->aiRowEst[saved_nEq+1]>=18  /* TUNING: Minimum for skip-scan */
         3931  +   && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
  3931   3932     ){
  3932   3933       LogEst nIter;
  3933   3934       pNew->u.btree.nEq++;
  3934   3935       pNew->u.btree.nSkip++;
  3935   3936       pNew->aLTerm[pNew->nLTerm++] = 0;
  3936   3937       pNew->wsFlags |= WHERE_SKIPSCAN;
  3937   3938       nIter = sqlite3LogEst(pProbe->aiRowEst[0]/pProbe->aiRowEst[saved_nEq+1]);

Changes to test/skipscan1.test.

   182    182     EXPLAIN QUERY PLAN
   183    183     SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;
   184    184   } {/* INDEX sqlite_autoindex_t3_1 (ANY(a) AND b=?)*/}
   185    185   do_execsql_test skipscan1-3.2sort {
   186    186     EXPLAIN QUERY PLAN
   187    187     SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;
   188    188   } {~/*ORDER BY*/}
          189  +
          190  +# Ticket 520070ec7fbaac: Array overrun in the skip-scan optimization
          191  +# 2013-12-22
          192  +#
          193  +do_execsql_test skipscan1-4.1 {
          194  +  CREATE TABLE t4(a,b,c,d,e,f,g,h,i);
          195  +  CREATE INDEX t4all ON t4(a,b,c,d,e,f,g,h);
          196  +  INSERT INTO t4 VALUES(1,2,3,4,5,6,7,8,9);
          197  +  ANALYZE;
          198  +  DELETE FROM sqlite_stat1;
          199  +  INSERT INTO sqlite_stat1 
          200  +    VALUES('t4','t4all','655360 163840 40960 10240 2560 640 160 40 10');
          201  +  ANALYZE sqlite_master;
          202  +  SELECT i FROM t4 WHERE a=1;
          203  +  SELECT i FROM t4 WHERE b=2;
          204  +  SELECT i FROM t4 WHERE c=3;
          205  +  SELECT i FROM t4 WHERE d=4;
          206  +  SELECT i FROM t4 WHERE e=5;
          207  +  SELECT i FROM t4 WHERE f=6;
          208  +  SELECT i FROM t4 WHERE g=7;
          209  +  SELECT i FROM t4 WHERE h=8;
          210  +} {9 9 9 9 9 9 9 9}
   189    211   
   190    212   finish_test