/ Check-in [cbc67de5]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add further tests so that veryquick.test covers all vdbe branches.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cbc67de5a3937fa65811ed7c13e870699c895660dc2132cf9d3cf5d83364e344
User & Date: dan 2019-04-05 20:47:15
Context
2019-04-05
20:56
Eliminate the tool/addopcodes.tcl script. The purpose of that script was to keep the number of parser codes below 256 in order to save parser table space. But we have long since blown through that ceiling so the addopcodes.tcl script was just needless complexity. There is no longer any reason to keep it around. check-in: d2728192 user: drh tags: trunk
20:47
Add further tests so that veryquick.test covers all vdbe branches. check-in: cbc67de5 user: dan tags: trunk
17:22
Improved comment on the sqlite3FaultSim() function. No changes to code. check-in: 08b29672 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/skipscan1.test.

   340    340   
   341    341   optimization_control db skip-scan 0
   342    342   do_execsql_test skipscan1-9.3 {
   343    343     EXPLAIN QUERY PLAN
   344    344     SELECT  * FROM t9a WHERE b IN (SELECT x FROM t9b WHERE y!=5);
   345    345   } {/{SCAN TABLE t9a}/}
   346    346   optimization_control db skip-scan 1
          347  +
          348  +do_execsql_test skipscan1-2.1 {
          349  +  CREATE TABLE t6(a TEXT, b INT, c INT, d INT);
          350  +  CREATE INDEX t6abc ON t6(a,b,c);
          351  +  INSERT INTO t6 VALUES('abc',123,4,5);
          352  +
          353  +  ANALYZE;
          354  +  DELETE FROM sqlite_stat1;
          355  +  INSERT INTO sqlite_stat1 VALUES('t6','t6abc','10000 5000 2000 10');
          356  +  ANALYZE sqlite_master;
          357  +  DELETE FROM t6;
          358  +} {}
          359  +
          360  +do_execsql_test skipscan1-2.2eqp {
          361  +  EXPLAIN QUERY PLAN
          362  +  SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a;
          363  +} {/* USING INDEX t6abc (ANY(a) AND b=?)*/}
          364  +do_execsql_test skipscan1-2.2 {
          365  +  SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a;
          366  +} {}
          367  +
          368  +do_execsql_test skipscan1-2.3eqp {
          369  +  EXPLAIN QUERY PLAN
          370  +  SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a DESC;
          371  +} {/* USING INDEX t6abc (ANY(a) AND b=?)*/}
          372  +do_execsql_test skipscan1-2.3 {
          373  +  SELECT a,b,c,d,'|' FROM t6 WHERE d<>99 AND b=345 ORDER BY a DESC;
          374  +} {}
   347    375   
   348    376   finish_test

Changes to test/where.test.

  1434   1434     CREATE TABLE t1(a INTEGER PRIMARY KEY);
  1435   1435     INSERT INTO t1(a) VALUES(1),(2),(3);
  1436   1436     CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT);
  1437   1437     INSERT INTO t2(y) VALUES(2),(3);
  1438   1438     SELECT * FROM t1, t2 WHERE a=y AND y=3;
  1439   1439   } {3 2 3}
  1440   1440   
         1441  +#-------------------------------------------------------------------------
         1442  +#
         1443  +reset_db
         1444  +do_execsql_test where-24.0 {
         1445  +  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
         1446  +  INSERT INTO t1 VALUES(1, 'one');
         1447  +  INSERT INTO t1 VALUES(2, 'two');
         1448  +  INSERT INTO t1 VALUES(3, 'three');
         1449  +  INSERT INTO t1 VALUES(4, 'four');
         1450  +}
         1451  +
         1452  +foreach {tn sql res} {
         1453  +  1 "SELECT b FROM t1"                   {one two three four}
         1454  +  2 "SELECT b FROM t1 WHERE a<4"         {one two three}
         1455  +  3 "SELECT b FROM t1 WHERE a>1"         {two three four}
         1456  +  4 "SELECT b FROM t1 WHERE a>1 AND a<4" {two three}
         1457  +
         1458  +  5 "SELECT b FROM t1 WHERE a>? AND a<4" {}
         1459  +  6 "SELECT b FROM t1 WHERE a>1 AND a<?" {}
         1460  +  7 "SELECT b FROM t1 WHERE a>? AND a<?" {}
         1461  +
         1462  +  7 "SELECT b FROM t1 WHERE a>=? AND a<=4" {}
         1463  +  8 "SELECT b FROM t1 WHERE a>=1 AND a<=?" {}
         1464  +  9 "SELECT b FROM t1 WHERE a>=? AND a<=?" {}
         1465  +} {
         1466  +  set rev [list]
         1467  +  foreach r $res { set rev [concat $r $rev] }
         1468  +
         1469  +  do_execsql_test where-24.$tn.1 "$sql"                     $res
         1470  +  do_execsql_test where-24.$tn.2 "$sql ORDER BY rowid"      $res
         1471  +  do_execsql_test where-24.$tn.3 "$sql ORDER BY rowid DESC" $rev
         1472  +
         1473  +  do_execsql_test where-24-$tn.4 "
         1474  +    BEGIN;
         1475  +      DELETE FROM t1;
         1476  +      $sql;
         1477  +      $sql ORDER BY rowid;
         1478  +      $sql ORDER BY rowid DESC;
         1479  +    ROLLBACK;
         1480  +  "
         1481  +}
         1482  +
         1483  +#-------------------------------------------------------------------------
         1484  +#
         1485  +reset_db
         1486  +do_execsql_test where-25.0 {
         1487  +  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
         1488  +  CREATE UNIQUE INDEX i1 ON t1(c);
         1489  +  INSERT INTO t1 VALUES(1, 'one', 'i');
         1490  +  INSERT INTO t1 VALUES(2, 'two', 'ii');
         1491  +
         1492  +  CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
         1493  +  CREATE UNIQUE INDEX i2 ON t2(c);
         1494  +  INSERT INTO t2 VALUES(1, 'one', 'i');
         1495  +  INSERT INTO t2 VALUES(2, 'two', 'ii');
         1496  +  INSERT INTO t2 VALUES(3, 'three', 'iii');
         1497  +
         1498  +  PRAGMA writable_schema = 1;
         1499  +  UPDATE sqlite_master SET rootpage = (
         1500  +    SELECT rootpage FROM sqlite_master WHERE name = 'i2'
         1501  +  ) WHERE name = 'i1';
         1502  +}
         1503  +db close
         1504  +sqlite3 db test.db
         1505  +do_catchsql_test where-25.1 {
         1506  +  DELETE FROM t1 WHERE c='iii'
         1507  +} {1 {database disk image is malformed}}
         1508  +do_catchsql_test where-25.2 {
         1509  +  INSERT INTO t1 VALUES(4, 'four', 'iii') 
         1510  +    ON CONFLICT(c) DO UPDATE SET b=NULL
         1511  +} {1 {database disk image is malformed}}
         1512  +
         1513  +reset_db
         1514  +do_execsql_test where-25.3 {
         1515  +  CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
         1516  +  CREATE UNIQUE INDEX i1 ON t1(c);
         1517  +  INSERT INTO t1 VALUES(1, 'one', 'i');
         1518  +  INSERT INTO t1 VALUES(2, 'two', 'ii');
         1519  +
         1520  +  CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);
         1521  +  CREATE UNIQUE INDEX i2 ON t2(c);
         1522  +  INSERT INTO t2 VALUES(1, 'one', 'i');
         1523  +  INSERT INTO t2 VALUES(2, 'two', 'ii');
         1524  +  INSERT INTO t2 VALUES(3, 'three', 'iii');
         1525  +
         1526  +  PRAGMA writable_schema = 1;
         1527  +  UPDATE sqlite_master SET rootpage = (
         1528  +    SELECT rootpage FROM sqlite_master WHERE name = 'i2'
         1529  +  ) WHERE name = 'i1';
         1530  +}
         1531  +db close
         1532  +sqlite3 db test.db
         1533  +do_catchsql_test where-25.4 {
         1534  +  SELECT * FROM t1 WHERE c='iii'
         1535  +} {0 {}}
         1536  +do_catchsql_test where-25.5 {
         1537  +  INSERT INTO t1 VALUES(4, 'four', 'iii') 
         1538  +    ON CONFLICT(c) DO UPDATE SET b=NULL
         1539  +} {1 {corrupt database}}
         1540  +
  1441   1541   finish_test
         1542  +