Home | History | Annotate | Download | only in test
      1 # 2011 May 19
      2 #
      3 # The author disclaims copyright to this source code.  In place of
      4 # a legal notice, here is a blessing:
      5 #
      6 #    May you do good and not evil.
      7 #    May you find forgiveness for yourself and forgive others.
      8 #    May you share freely, never taking more than you give.
      9 #
     10 #***********************************************************************
     11 # This file implements regression tests for SQLite library. Specifically,
     12 # it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has
     13 # been resolved.
     14 #
     15 # 
     16 #
     17 
     18 set testdir [file dirname $argv0]
     19 source $testdir/tester.tcl
     20 
     21 ifcapable !wal {finish_test; return}
     22 
     23 for {set ii 1} {$ii<=10} {incr ii} {
     24   do_test tkt-2d1a5c67d.1.$ii {
     25     db close
     26     forcedelete test.db test.db-wal
     27     sqlite3 db test.db
     28     db eval "PRAGMA cache_size=$::ii"
     29     db eval {
     30       PRAGMA journal_mode=WAL;
     31       CREATE TABLE t1(a,b);
     32       CREATE INDEX t1b ON t1(b);
     33       CREATE TABLE t2(x,y UNIQUE);
     34       INSERT INTO t2 VALUES(3,4);
     35       BEGIN;
     36       INSERT INTO t1(a,b) VALUES(1,2);
     37       SELECT 'A', * FROM t2 WHERE y=4;
     38       SELECT 'B', * FROM t1;
     39       COMMIT;
     40       SELECT 'C', * FROM t1;
     41     }
     42   } {wal A 3 4 B 1 2 C 1 2}
     43 }
     44 
     45 db close
     46 forcedelete test.db test.db-wal
     47 sqlite3 db test.db
     48 register_wholenumber_module db
     49 db eval {
     50   PRAGMA journal_mode=WAL;
     51   CREATE TABLE t1(a,b);
     52   CREATE INDEX t1b ON t1(b);
     53   CREATE TABLE t2(x,y);
     54   CREATE VIRTUAL TABLE nums USING wholenumber;
     55   INSERT INTO t2 SELECT value, randomblob(1000) FROM nums
     56                  WHERE value BETWEEN 1 AND 1000;
     57 }
     58 
     59 for {set ii 1} {$ii<=10} {incr ii} {
     60   do_test tkt-2d1a5c67d.2.$ii {
     61     db eval "PRAGMA cache_size=$::ii"
     62     db eval {
     63       DELETE FROM t1;
     64       BEGIN;
     65       INSERT INTO t1(a,b) VALUES(1,2);
     66       SELECT sum(length(y)) FROM t2;
     67       COMMIT;
     68       SELECT * FROM t1;
     69     }
     70   } {1000000 1 2}
     71 }
     72 
     73 finish_test
     74