wasCSharpSQLite – Blame information for rev 7
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # 2011 May 16 |
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. The |
||
12 | # focus of this file is testing the PRAGMA journal_size_limit when |
||
13 | # in WAL mode. |
||
14 | # |
||
15 | |||
16 | set testdir [file dirname $argv0] |
||
17 | source $testdir/tester.tcl |
||
18 | ifcapable !wal {finish_test ; return } |
||
19 | |||
20 | # Case 1: No size limit. Journal can get large. |
||
21 | # |
||
22 | do_test wal7-1.0 { |
||
23 | db close |
||
24 | forcedelete test.db |
||
25 | sqlite3 db test.db |
||
26 | db eval { |
||
27 | PRAGMA page_size=1024; |
||
28 | PRAGMA journal_mode=WAL; |
||
29 | PRAGMA wal_autocheckpoint=50; -- 50 pages |
||
30 | CREATE TABLE t1(x, y UNIQUE); |
||
31 | INSERT INTO t1 VALUES(1,2); |
||
32 | INSERT INTO t1 VALUES(zeroblob(200000),4); |
||
33 | CREATE TABLE t2(z); |
||
34 | DELETE FROM t1; |
||
35 | INSERT INTO t2 SELECT x FROM t1; |
||
36 | } |
||
37 | expr {[file size test.db-wal]>50*1100} |
||
38 | } 1 |
||
39 | do_test wal7-1.1 { |
||
40 | db eval {PRAGMA wal_checkpoint} |
||
41 | expr {[file size test.db-wal]>50*1100} |
||
42 | } 1 |
||
43 | do_test wal7-1.2 { |
||
44 | db eval {INSERT INTO t2 VALUES('hi');} |
||
45 | expr {[file size test.db-wal]>50*1100} |
||
46 | } 1 |
||
47 | |||
48 | # Case 2: Size limit at half the autocheckpoint size. |
||
49 | # |
||
50 | do_test wal7-2.0 { |
||
51 | db close |
||
52 | forcedelete test.db |
||
53 | sqlite3 db test.db |
||
54 | db eval { |
||
55 | PRAGMA page_size=1024; |
||
56 | PRAGMA journal_mode=WAL; |
||
57 | PRAGMA wal_autocheckpoint=50; -- 50 pages |
||
58 | PRAGMA journal_size_limit=25000; |
||
59 | CREATE TABLE t1(x, y UNIQUE); |
||
60 | INSERT INTO t1 VALUES(1,2); |
||
61 | INSERT INTO t1 VALUES(zeroblob(200000),4); |
||
62 | CREATE TABLE t2(z); |
||
63 | DELETE FROM t1; |
||
64 | INSERT INTO t2 VALUES(1); |
||
65 | } |
||
66 | file size test.db-wal |
||
67 | } 25000 |
||
68 | |||
69 | |||
70 | # Case 3: Size limit of zero. |
||
71 | # |
||
72 | do_test wal7-3.0 { |
||
73 | db close |
||
74 | forcedelete test.db |
||
75 | sqlite3 db test.db |
||
76 | db eval { |
||
77 | PRAGMA page_size=1024; |
||
78 | PRAGMA journal_mode=WAL; |
||
79 | PRAGMA wal_autocheckpoint=50; -- 50 pages |
||
80 | PRAGMA journal_size_limit=0; |
||
81 | CREATE TABLE t1(x, y UNIQUE); |
||
82 | INSERT INTO t1 VALUES(1,2); |
||
83 | INSERT INTO t1 VALUES(zeroblob(200000),4); |
||
84 | CREATE TABLE t2(z); |
||
85 | DELETE FROM t1; |
||
86 | INSERT INTO t2 VALUES(1); |
||
87 | } |
||
88 | set sz [file size test.db-wal] |
||
89 | expr {$sz>0 && $sz<13700} |
||
90 | } 1 |
||
91 | |||
92 | |||
93 | # Case 4: Size limit set before going WAL |
||
94 | # |
||
95 | do_test wal7-4.0 { |
||
96 | db close |
||
97 | forcedelete test.db |
||
98 | sqlite3 db test.db |
||
99 | db eval { |
||
100 | PRAGMA page_size=1024; |
||
101 | PRAGMA journal_size_limit=25000; |
||
102 | PRAGMA journal_mode=WAL; |
||
103 | PRAGMA wal_autocheckpoint=50; -- 50 pages |
||
104 | CREATE TABLE t1(x, y UNIQUE); |
||
105 | INSERT INTO t1 VALUES(1,2); |
||
106 | INSERT INTO t1 VALUES(zeroblob(200000),4); |
||
107 | CREATE TABLE t2(z); |
||
108 | DELETE FROM t1; |
||
109 | INSERT INTO t2 VALUES(1); |
||
110 | } |
||
111 | set sz [file size test.db-wal] |
||
112 | } 25000 |
||
113 | |||
114 | |||
115 | |||
116 | |||
117 | |||
118 | finish_test |