/ Check-in [1f16c9a7]
Login

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

Overview
Comment:Fix an obscure problem in range estimation with STAT4.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1f16c9a76bc48331799f33b30d143c632fe0e7db
User & Date: drh 2016-12-09 00:15:17
Context
2016-12-09
16:02
Avoid unnecessary zeroing of fields in the MemPage object that are going to be reinitialized before use anyhow. A smaller and faster binary results. check-in: 01ada3d1 user: drh tags: trunk
00:15
Fix an obscure problem in range estimation with STAT4. check-in: 1f16c9a7 user: drh tags: trunk
2016-12-08
23:52
Fix the showstat4 utility program so that is displays strings using standard SQL notation (single quotes) rather than C-style notation. check-in: 92998e4a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

  1329   1329           pVal->u.i = -pVal->u.i;
  1330   1330         }
  1331   1331         sqlite3ValueApplyAffinity(pVal, affinity, enc);
  1332   1332       }
  1333   1333     }else if( op==TK_NULL ){
  1334   1334       pVal = valueNew(db, pCtx);
  1335   1335       if( pVal==0 ) goto no_mem;
         1336  +    sqlite3VdbeMemNumerify(pVal);
  1336   1337     }
  1337   1338   #ifndef SQLITE_OMIT_BLOB_LITERAL
  1338   1339     else if( op==TK_BLOB ){
  1339   1340       int nVal;
  1340   1341       assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
  1341   1342       assert( pExpr->u.zToken[1]=='\'' );
  1342   1343       pVal = valueNew(db, pCtx);

Changes to test/analyzeF.test.

   116    116     SELECT * FROM t1 WHERE x = dstr() AND y = 11;
   117    117   } {1 {string or blob too big}}
   118    118   
   119    119   do_catchsql_test 4.4 {
   120    120     SELECT * FROM t1 WHERE x = test_zeroblob(1100000) AND y = 4;
   121    121   } {1 {string or blob too big}}
   122    122   
          123  +# 2016-12-08: Constraints of the form "x=? AND x IS NOT NULL" were being
          124  +# mishandled.  The sqlite3Stat4ProbeSetValue() routine was assuming that
          125  +# valueNew() was returning a Mem object that was preset to NULL, which is
          126  +# not the case.  The consequence was the the "x IS NOT NULL" constraint
          127  +# was used to drive the index (via the "x>NULL" pseudo-constraint) rather
          128  +# than the "x=?" constraint.
          129  +#
          130  +do_execsql_test 5.1 {
          131  +  DROP TABLE IF EXISTS t1;
          132  +  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT);
          133  +  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10000)
          134  +    INSERT INTO t1(a, c) SELECT x, x FROM c;
          135  +  UPDATE t1 SET b=printf('x%02x',a/500) WHERE a>4000;
          136  +  UPDATE t1 SET b='xyz' where a>=9998;
          137  +  CREATE INDEX t1b ON t1(b);
          138  +  ANALYZE;
          139  +  SELECT count(*), b FROM t1 GROUP BY 2 ORDER BY 2;
          140  +} {4000 {} 499 x08 500 x09 500 x0a 500 x0b 500 x0c 500 x0d 500 x0e 500 x0f 500 x10 500 x11 500 x12 498 x13 3 xyz}
          141  +do_execsql_test 5.2 {
          142  +  explain query plan
          143  +  SELECT * FROM t1 WHERE b='xyz' AND b IS NOT NULL ORDER BY +a;
          144  +  /*                  v---- Should be "=", not ">"  */
          145  +} {/USING INDEX t1b .b=/}
          146  +do_execsql_test 5.3 {
          147  +  SELECT * FROM t1 WHERE b='xyz' AND b IS NOT NULL ORDER BY +a;
          148  +} {9998 xyz 9998 9999 xyz 9999 10000 xyz 10000}
   123    149   
   124    150   finish_test