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 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
16 source $testdir/malloc_common.tcl
18 set testprefix savepointfault
20 do_malloc_test 1 -sqlprep {
21 CREATE TABLE t1(a, b, c);
22 INSERT INTO t1 VALUES(1, 2, 3);
25 INSERT INTO t1 VALUES(4, 5, 6);
32 do_malloc_test 2 -sqlprep {
33 PRAGMA cache_size = 10;
34 CREATE TABLE t1(a, b, c);
35 INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));
37 randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
39 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
41 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
43 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
45 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
47 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
49 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
51 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
53 PRAGMA cache_size = 10;
55 DELETE FROM t1 WHERE rowid < 5;
57 DELETE FROM t1 WHERE rowid > 10;
63 do_ioerr_test 3 -sqlprep {
64 CREATE TABLE t1(a, b, c);
65 INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));
66 INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));
69 UPDATE t1 SET a = 3 WHERE a = 1;
71 UPDATE t1 SET a = 4 WHERE a = 2;
80 # The following test does a really big savepoint rollback. One involving
81 # more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()
82 # operation in pagerPlaybackSavepoint() to fail.
83 #do_malloc_test 4 -sqlprep {
85 # CREATE TABLE t1(a, b);
86 # CREATE INDEX i1 ON t1(a);
87 # CREATE INDEX i2 ON t1(b);
88 # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 1
89 # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2
90 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 4
91 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 8
92 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 16
93 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 32
94 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 64
95 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 128
96 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 256
97 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 512
98 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 1024
99 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048
103 # UPDATE t1 SET a = randstr(500,500);
109 # Cause a specific malloc in savepoint rollback code to fail.
111 do_malloc_test 4 -start 7 -sqlprep {
112 PRAGMA auto_vacuum = incremental;
113 PRAGMA cache_size = 1000;
115 CREATE TABLE t1(a, b);
116 CREATE TABLE t2(a, b);
117 CREATE TABLE t3(a, b);
118 INSERT INTO t1 VALUES(1, randstr(500,500));
119 INSERT INTO t1 VALUES(2, randstr(500,500));
120 INSERT INTO t1 VALUES(3, randstr(500,500));
124 INSERT INTO t1 VALUES(1, randstr(500,500));
125 INSERT INTO t1 VALUES(2, randstr(500,500));
126 INSERT INTO t1 VALUES(3, randstr(500,500));
127 DROP TABLE t3; -- Page 5 of the database file is now free.
128 DROP TABLE t2; -- Page 4 of the database file is now free.
131 PRAGMA incremental_vacuum;