| OLD | NEW |
| 1 # 2011 May 19 | 1 # 2011 May 19 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| 11 # This file implements regression tests for SQLite library. Specifically, | 11 # This file implements regression tests for SQLite library. Specifically, |
| 12 # it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has | 12 # it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has |
| 13 # been resolved. | 13 # been resolved. |
| 14 # | 14 # |
| 15 # | 15 # |
| 16 # | 16 # |
| 17 | 17 |
| 18 set testdir [file dirname $argv0] | 18 set testdir [file dirname $argv0] |
| 19 source $testdir/tester.tcl | 19 source $testdir/tester.tcl |
| 20 set testprefix tkt-2d1a5c67d |
| 20 | 21 |
| 21 ifcapable !wal {finish_test; return} | 22 ifcapable {!wal || !vtab} {finish_test; return} |
| 22 | 23 |
| 23 for {set ii 1} {$ii<=10} {incr ii} { | 24 for {set ii 1} {$ii<=10} {incr ii} { |
| 24 do_test tkt-2d1a5c67d.1.$ii { | 25 do_test tkt-2d1a5c67d.1.$ii { |
| 25 db close | 26 db close |
| 26 forcedelete test.db test.db-wal | 27 forcedelete test.db test.db-wal |
| 27 sqlite3 db test.db | 28 sqlite3 db test.db |
| 28 db eval "PRAGMA cache_size=$::ii" | 29 db eval "PRAGMA cache_size=$::ii" |
| 29 db eval { | 30 db eval { |
| 30 PRAGMA journal_mode=WAL; | 31 PRAGMA journal_mode=WAL; |
| 31 CREATE TABLE t1(a,b); | 32 CREATE TABLE t1(a,b); |
| 32 CREATE INDEX t1b ON t1(b); | 33 CREATE INDEX t1b ON t1(b); |
| 33 CREATE TABLE t2(x,y UNIQUE); | 34 CREATE TABLE t2(x,y UNIQUE); |
| 34 INSERT INTO t2 VALUES(3,4); | 35 INSERT INTO t2 VALUES(3,4); |
| 35 BEGIN; | 36 BEGIN; |
| 36 INSERT INTO t1(a,b) VALUES(1,2); | 37 INSERT INTO t1(a,b) VALUES(1,2); |
| 37 SELECT 'A', * FROM t2 WHERE y=4; | 38 SELECT 'A', * FROM t2 WHERE y=4; |
| 38 SELECT 'B', * FROM t1; | 39 SELECT 'B', * FROM t1; |
| 39 COMMIT; | 40 COMMIT; |
| 40 SELECT 'C', * FROM t1; | 41 SELECT 'C', * FROM t1; |
| 41 } | 42 } |
| 42 } {wal A 3 4 B 1 2 C 1 2} | 43 } {wal A 3 4 B 1 2 C 1 2} |
| 43 } | 44 } |
| 44 | 45 |
| 45 db close | 46 db close |
| 46 forcedelete test.db test.db-wal | 47 forcedelete test.db test.db-wal |
| 47 sqlite3 db test.db | 48 sqlite3 db test.db |
| 48 register_wholenumber_module db | 49 load_static_extension db wholenumber |
| 49 db eval { | 50 db eval { |
| 50 PRAGMA journal_mode=WAL; | 51 PRAGMA journal_mode=WAL; |
| 51 CREATE TABLE t1(a,b); | 52 CREATE TABLE t1(a,b); |
| 52 CREATE INDEX t1b ON t1(b); | 53 CREATE INDEX t1b ON t1(b); |
| 53 CREATE TABLE t2(x,y); | 54 CREATE TABLE t2(x,y); |
| 54 CREATE VIRTUAL TABLE nums USING wholenumber; | 55 CREATE VIRTUAL TABLE nums USING wholenumber; |
| 55 INSERT INTO t2 SELECT value, randomblob(1000) FROM nums | 56 INSERT INTO t2 SELECT value, randomblob(1000) FROM nums |
| 56 WHERE value BETWEEN 1 AND 1000; | 57 WHERE value BETWEEN 1 AND 1000; |
| 57 } | 58 } |
| 58 | 59 |
| 59 for {set ii 1} {$ii<=10} {incr ii} { | 60 for {set ii 1} {$ii<=10} {incr ii} { |
| 60 do_test tkt-2d1a5c67d.2.$ii { | 61 do_test tkt-2d1a5c67d.2.$ii { |
| 61 db eval "PRAGMA cache_size=$::ii" | 62 db eval "PRAGMA cache_size=$::ii" |
| 62 db eval { | 63 db eval { |
| 63 DELETE FROM t1; | 64 DELETE FROM t1; |
| 64 BEGIN; | 65 BEGIN; |
| 65 INSERT INTO t1(a,b) VALUES(1,2); | 66 INSERT INTO t1(a,b) VALUES(1,2); |
| 66 SELECT sum(length(y)) FROM t2; | 67 SELECT sum(length(y)) FROM t2; |
| 67 COMMIT; | 68 COMMIT; |
| 68 SELECT * FROM t1; | 69 SELECT * FROM t1; |
| 69 } | 70 } |
| 70 } {1000000 1 2} | 71 } {1000000 1 2} |
| 71 } | 72 } |
| 72 | 73 |
| 74 db close |
| 75 sqlite3 db test.db |
| 76 |
| 77 |
| 78 do_execsql_test 3.1 { |
| 79 PRAGMA cache_size = 10; |
| 80 CREATE TABLE t3(a INTEGER PRIMARY KEY, b); |
| 81 CREATE TABLE t4(a); |
| 82 } |
| 83 |
| 84 do_execsql_test 3.2 { |
| 85 INSERT INTO t3 VALUES(NULL, randomblob(500)); |
| 86 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 2 |
| 87 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 4 |
| 88 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 8 |
| 89 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 16 |
| 90 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 32 |
| 91 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 64 |
| 92 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 128 |
| 93 } |
| 94 |
| 95 do_execsql_test 3.3 { |
| 96 BEGIN; |
| 97 INSERT INTO t4 VALUES('xyz'); |
| 98 } |
| 99 |
| 100 do_test 3.4 { |
| 101 set blobs [list] |
| 102 for {set i 1} {$i<100} {incr i} { |
| 103 set b [db incrblob -readonly t3 b $i] |
| 104 read $b |
| 105 lappend blobs $b |
| 106 } |
| 107 |
| 108 execsql COMMIT |
| 109 execsql { SELECT * FROM t4 WHERE a = 'xyz' } |
| 110 } {xyz} |
| 111 |
| 112 do_test 3.5 { |
| 113 foreach b $blobs { close $b } |
| 114 execsql { SELECT * FROM t4 WHERE a = 'xyz' } |
| 115 } {xyz} |
| 116 |
| 117 # Check that recovery works on the WAL file. |
| 118 # |
| 119 forcedelete test.db2-wal test.db2 |
| 120 do_test 3.6 { |
| 121 copy_file test.db-wal test.db2-wal |
| 122 copy_file test.db test.db2 |
| 123 sqlite3 db2 test.db2 |
| 124 execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2 |
| 125 } {xyz} |
| 126 |
| 73 finish_test | 127 finish_test |
| OLD | NEW |