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 #***********************************************************************
12 # $Id: savepoint3.test,v 1.5 2009/06/05 17:09:12 drh Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
17 source $testdir/malloc_common.tcl
19 do_malloc_test savepoint3-1 -sqlprep {
20 CREATE TABLE t1(a, b, c);
21 INSERT INTO t1 VALUES(1, 2, 3);
24 INSERT INTO t1 VALUES(4, 5, 6);
31 do_malloc_test savepoint3-2 -sqlprep {
32 PRAGMA cache_size = 10;
33 CREATE TABLE t1(a, b, c);
34 INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));
36 randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
38 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
40 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
42 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
44 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
46 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
48 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
50 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
52 PRAGMA cache_size = 10;
54 DELETE FROM t1 WHERE rowid < 5;
56 DELETE FROM t1 WHERE rowid > 10;
62 do_ioerr_test savepoint3.3 -sqlprep {
63 CREATE TABLE t1(a, b, c);
64 INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));
65 INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));
68 UPDATE t1 SET a = 3 WHERE a = 1;
70 UPDATE t1 SET a = 4 WHERE a = 2;
79 # The following test does a really big savepoint rollback. One involving
80 # more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()
81 # operation in pagerPlaybackSavepoint() to fail.
82 #do_malloc_test savepoint3-4 -sqlprep {
84 # CREATE TABLE t1(a, b);
85 # CREATE INDEX i1 ON t1(a);
86 # CREATE INDEX i2 ON t1(b);
87 # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 1
88 # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2
89 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 4
90 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 8
91 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 16
92 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 32
93 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 64
94 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 128
95 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 256
96 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 512
97 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 1024
98 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048
102 # UPDATE t1 SET a = randstr(500,500);
108 # Cause a specific malloc in savepoint rollback code to fail.
110 do_malloc_test savepoint3-4 -start 7 -sqlprep {
111 PRAGMA auto_vacuum = incremental;
112 PRAGMA cache_size = 1000;
114 CREATE TABLE t1(a, b);
115 CREATE TABLE t2(a, b);
116 CREATE TABLE t3(a, b);
117 INSERT INTO t1 VALUES(1, randstr(500,500));
118 INSERT INTO t1 VALUES(2, randstr(500,500));
119 INSERT INTO t1 VALUES(3, randstr(500,500));
123 INSERT INTO t1 VALUES(1, randstr(500,500));
124 INSERT INTO t1 VALUES(2, randstr(500,500));
125 INSERT INTO t1 VALUES(3, randstr(500,500));
126 DROP TABLE t3; -- Page 5 of the database file is now free.
127 DROP TABLE t2; -- Page 4 of the database file is now free.
130 PRAGMA incremental_vacuum;