3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the PRAGMA journal_size_limit when
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 ifcapable !wal {finish_test ; return }
20 # Case 1: No size limit. Journal can get large.
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);
35 INSERT INTO t2 SELECT x FROM t1;
37 expr {[file size test.db-wal]>50*1100}
40 db eval {PRAGMA wal_checkpoint}
41 expr {[file size test.db-wal]>50*1100}
44 db eval {INSERT INTO t2 VALUES('hi');}
45 expr {[file size test.db-wal]>50*1100}
48 # Case 2: Size limit at half the autocheckpoint size.
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);
64 INSERT INTO t2 VALUES(1);
70 # Case 3: Size limit of zero.
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);
86 INSERT INTO t2 VALUES(1);
88 set sz [file size test.db-wal]
89 expr {$sz>0 && $sz<13700}
93 # Case 4: Size limit set before going WAL
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);
109 INSERT INTO t2 VALUES(1);
111 set sz [file size test.db-wal]