From 7bb481fda9ecb134804b49c2ce77ca28f7eea583 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 30 Mar 2012 20:42:12 -0400 Subject: Imported Upstream version 2.0.3 --- test/tkt-2d1a5c67d.test | 127 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 test/tkt-2d1a5c67d.test (limited to 'test/tkt-2d1a5c67d.test') diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test new file mode 100644 index 0000000..bf9595f --- /dev/null +++ b/test/tkt-2d1a5c67d.test @@ -0,0 +1,127 @@ +# 2011 May 19 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. Specifically, +# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has +# been resolved. +# +# +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix tkt-2d1a5c67d + +ifcapable {!wal || !vtab} {finish_test; return} + +for {set ii 1} {$ii<=10} {incr ii} { + do_test tkt-2d1a5c67d.1.$ii { + db close + forcedelete test.db test.db-wal + sqlite3 db test.db + db eval "PRAGMA cache_size=$::ii" + db eval { + PRAGMA journal_mode=WAL; + CREATE TABLE t1(a,b); + CREATE INDEX t1b ON t1(b); + CREATE TABLE t2(x,y UNIQUE); + INSERT INTO t2 VALUES(3,4); + BEGIN; + INSERT INTO t1(a,b) VALUES(1,2); + SELECT 'A', * FROM t2 WHERE y=4; + SELECT 'B', * FROM t1; + COMMIT; + SELECT 'C', * FROM t1; + } + } {wal A 3 4 B 1 2 C 1 2} +} + +db close +forcedelete test.db test.db-wal +sqlite3 db test.db +register_wholenumber_module db +db eval { + PRAGMA journal_mode=WAL; + CREATE TABLE t1(a,b); + CREATE INDEX t1b ON t1(b); + CREATE TABLE t2(x,y); + CREATE VIRTUAL TABLE nums USING wholenumber; + INSERT INTO t2 SELECT value, randomblob(1000) FROM nums + WHERE value BETWEEN 1 AND 1000; +} + +for {set ii 1} {$ii<=10} {incr ii} { + do_test tkt-2d1a5c67d.2.$ii { + db eval "PRAGMA cache_size=$::ii" + db eval { + DELETE FROM t1; + BEGIN; + INSERT INTO t1(a,b) VALUES(1,2); + SELECT sum(length(y)) FROM t2; + COMMIT; + SELECT * FROM t1; + } + } {1000000 1 2} +} + +db close +sqlite3 db test.db + + +do_execsql_test 3.1 { + PRAGMA cache_size = 10; + CREATE TABLE t3(a INTEGER PRIMARY KEY, b); + CREATE TABLE t4(a); +} + +do_execsql_test 3.2 { + INSERT INTO t3 VALUES(NULL, randomblob(500)); + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 2 + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 4 + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 8 + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 16 + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 32 + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 64 + INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 128 +} + +do_execsql_test 3.3 { + BEGIN; + INSERT INTO t4 VALUES('xyz'); +} + +do_test 3.4 { + set blobs [list] + for {set i 1} {$i<100} {incr i} { + set b [db incrblob -readonly t3 b $i] + read $b + lappend blobs $b + } + + execsql COMMIT + execsql { SELECT * FROM t4 WHERE a = 'xyz' } +} {xyz} + +do_test 3.5 { + foreach b $blobs { close $b } + execsql { SELECT * FROM t4 WHERE a = 'xyz' } +} {xyz} + +# Check that recovery works on the WAL file. +# +forcedelete test.db2-wal test.db2 +do_test 3.6 { + copy_file test.db-wal test.db2-wal + copy_file test.db test.db2 + sqlite3 db2 test.db2 + execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2 +} {xyz} + +finish_test -- cgit v1.2.3