OLD | NEW |
1 # 2008 December 15 | 1 # 2008 December 15 |
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 # | 11 # |
12 # $Id: savepoint3.test,v 1.5 2009/06/05 17:09:12 drh Exp $ | |
13 | 12 |
14 set testdir [file dirname $argv0] | 13 set testdir [file dirname $argv0] |
15 source $testdir/tester.tcl | 14 source $testdir/tester.tcl |
16 | 15 |
17 source $testdir/malloc_common.tcl | 16 source $testdir/malloc_common.tcl |
18 | 17 |
19 do_malloc_test savepoint3-1 -sqlprep { | 18 set testprefix savepointfault |
| 19 |
| 20 do_malloc_test 1 -sqlprep { |
20 CREATE TABLE t1(a, b, c); | 21 CREATE TABLE t1(a, b, c); |
21 INSERT INTO t1 VALUES(1, 2, 3); | 22 INSERT INTO t1 VALUES(1, 2, 3); |
22 } -sqlbody { | 23 } -sqlbody { |
23 SAVEPOINT one; | 24 SAVEPOINT one; |
24 INSERT INTO t1 VALUES(4, 5, 6); | 25 INSERT INTO t1 VALUES(4, 5, 6); |
25 SAVEPOINT two; | 26 SAVEPOINT two; |
26 DELETE FROM t1; | 27 DELETE FROM t1; |
27 ROLLBACK TO two; | 28 ROLLBACK TO two; |
28 RELEASE one; | 29 RELEASE one; |
29 } | 30 } |
30 | 31 |
31 do_malloc_test savepoint3-2 -sqlprep { | 32 do_malloc_test 2 -sqlprep { |
32 PRAGMA cache_size = 10; | 33 PRAGMA cache_size = 10; |
33 CREATE TABLE t1(a, b, c); | 34 CREATE TABLE t1(a, b, c); |
34 INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400)); | 35 INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400)); |
35 INSERT INTO t1 SELECT | 36 INSERT INTO t1 SELECT |
36 randstr(400,400), randstr(400,400), randstr(400,400) FROM t1; | 37 randstr(400,400), randstr(400,400), randstr(400,400) FROM t1; |
37 INSERT INTO t1 | 38 INSERT INTO t1 |
38 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1; | 39 SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1; |
39 INSERT INTO t1 | 40 INSERT INTO t1 |
40 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; |
41 INSERT INTO t1 | 42 INSERT INTO t1 |
(...skipping 10 matching lines...) Expand all Loading... |
52 PRAGMA cache_size = 10; | 53 PRAGMA cache_size = 10; |
53 SAVEPOINT one; | 54 SAVEPOINT one; |
54 DELETE FROM t1 WHERE rowid < 5; | 55 DELETE FROM t1 WHERE rowid < 5; |
55 SAVEPOINT two; | 56 SAVEPOINT two; |
56 DELETE FROM t1 WHERE rowid > 10; | 57 DELETE FROM t1 WHERE rowid > 10; |
57 ROLLBACK TO two; | 58 ROLLBACK TO two; |
58 ROLLBACK TO one; | 59 ROLLBACK TO one; |
59 RELEASE one; | 60 RELEASE one; |
60 } | 61 } |
61 | 62 |
62 do_ioerr_test savepoint3.3 -sqlprep { | 63 do_ioerr_test 3 -sqlprep { |
63 CREATE TABLE t1(a, b, c); | 64 CREATE TABLE t1(a, b, c); |
64 INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000)); | 65 INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000)); |
65 INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000)); | 66 INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000)); |
66 } -sqlbody { | 67 } -sqlbody { |
67 BEGIN; | 68 BEGIN; |
68 UPDATE t1 SET a = 3 WHERE a = 1; | 69 UPDATE t1 SET a = 3 WHERE a = 1; |
69 SAVEPOINT one; | 70 SAVEPOINT one; |
70 UPDATE t1 SET a = 4 WHERE a = 2; | 71 UPDATE t1 SET a = 4 WHERE a = 2; |
71 COMMIT; | 72 COMMIT; |
72 } -cleanup { | 73 } -cleanup { |
73 db eval { | 74 db eval { |
74 SAVEPOINT one; | 75 SAVEPOINT one; |
75 RELEASE one; | 76 RELEASE one; |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 # The following test does a really big savepoint rollback. One involving | 80 # 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 # more than 4000 pages. The idea is to get a specific sqlite3BitvecSet() |
81 # operation in pagerPlaybackSavepoint() to fail. | 82 # operation in pagerPlaybackSavepoint() to fail. |
82 #do_malloc_test savepoint3-4 -sqlprep { | 83 #do_malloc_test 4 -sqlprep { |
83 # BEGIN; | 84 # BEGIN; |
84 # CREATE TABLE t1(a, b); | 85 # CREATE TABLE t1(a, b); |
85 # CREATE INDEX i1 ON t1(a); | 86 # CREATE INDEX i1 ON t1(a); |
86 # CREATE INDEX i2 ON t1(b); | 87 # 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)); -- 1 |
88 # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2 | 89 # 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; -- 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; -- 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; -- 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; -- 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; -- 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; -- 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; -- 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; -- 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; -- 1024 |
98 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048 | 99 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048 |
99 # COMMIT; | 100 # COMMIT; |
100 # BEGIN; | 101 # BEGIN; |
101 # SAVEPOINT abc; | 102 # SAVEPOINT abc; |
102 # UPDATE t1 SET a = randstr(500,500); | 103 # UPDATE t1 SET a = randstr(500,500); |
103 #} -sqlbody { | 104 #} -sqlbody { |
104 # ROLLBACK TO abc; | 105 # ROLLBACK TO abc; |
105 #} | 106 #} |
106 | 107 |
107 | 108 |
108 # Cause a specific malloc in savepoint rollback code to fail. | 109 # Cause a specific malloc in savepoint rollback code to fail. |
109 # | 110 # |
110 do_malloc_test savepoint3-4 -start 7 -sqlprep { | 111 do_malloc_test 4 -start 7 -sqlprep { |
111 PRAGMA auto_vacuum = incremental; | 112 PRAGMA auto_vacuum = incremental; |
112 PRAGMA cache_size = 1000; | 113 PRAGMA cache_size = 1000; |
113 | 114 |
114 CREATE TABLE t1(a, b); | 115 CREATE TABLE t1(a, b); |
115 CREATE TABLE t2(a, b); | 116 CREATE TABLE t2(a, b); |
116 CREATE TABLE t3(a, b); | 117 CREATE TABLE t3(a, b); |
117 INSERT INTO t1 VALUES(1, randstr(500,500)); | 118 INSERT INTO t1 VALUES(1, randstr(500,500)); |
118 INSERT INTO t1 VALUES(2, randstr(500,500)); | 119 INSERT INTO t1 VALUES(2, randstr(500,500)); |
119 INSERT INTO t1 VALUES(3, randstr(500,500)); | 120 INSERT INTO t1 VALUES(3, randstr(500,500)); |
120 DELETE FROM t1; | 121 DELETE FROM t1; |
121 | 122 |
122 BEGIN; | 123 BEGIN; |
123 INSERT INTO t1 VALUES(1, randstr(500,500)); | 124 INSERT INTO t1 VALUES(1, randstr(500,500)); |
124 INSERT INTO t1 VALUES(2, randstr(500,500)); | 125 INSERT INTO t1 VALUES(2, randstr(500,500)); |
125 INSERT INTO t1 VALUES(3, randstr(500,500)); | 126 INSERT INTO t1 VALUES(3, randstr(500,500)); |
126 DROP TABLE t3; -- Page 5 of the database file is now free. | 127 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. | 128 DROP TABLE t2; -- Page 4 of the database file is now free. |
128 | 129 |
129 SAVEPOINT abc; | 130 SAVEPOINT abc; |
130 PRAGMA incremental_vacuum; | 131 PRAGMA incremental_vacuum; |
131 } -sqlbody { | 132 } -sqlbody { |
132 ROLLBACK TO abc; | 133 ROLLBACK TO abc; |
133 } | 134 } |
134 | 135 |
135 | 136 |
136 finish_test | 137 finish_test |
OLD | NEW |