Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: third_party/sqlite/src/test/walcrash.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2010 February 8 1 # 2010 February 8
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 #***********************************************************************
(...skipping 19 matching lines...) Expand all
30 ifcapable !wal {finish_test ; return } 30 ifcapable !wal {finish_test ; return }
31 31
32 db close 32 db close
33 33
34 set seed 0 34 set seed 0
35 set REPEATS 100 35 set REPEATS 100
36 36
37 # walcrash-1.* 37 # walcrash-1.*
38 # 38 #
39 for {set i 1} {$i < $REPEATS} {incr i} { 39 for {set i 1} {$i < $REPEATS} {incr i} {
40 file delete -force test.db test.db-wal 40 forcedelete test.db test.db-wal
41 do_test walcrash-1.$i.1 { 41 do_test walcrash-1.$i.1 {
42 crashsql -delay 4 -file test.db-wal -seed [incr seed] { 42 crashsql -delay 4 -file test.db-wal -seed [incr seed] {
43 PRAGMA journal_mode = WAL; 43 PRAGMA journal_mode = WAL;
44 CREATE TABLE t1(a, b); 44 CREATE TABLE t1(a, b);
45 INSERT INTO t1 VALUES(1, 1); 45 INSERT INTO t1 VALUES(1, 1);
46 INSERT INTO t1 VALUES(2, 3); 46 INSERT INTO t1 VALUES(2, 3);
47 INSERT INTO t1 VALUES(3, 6); 47 INSERT INTO t1 VALUES(3, 6);
48 } 48 }
49 } {1 {child process exited abnormally}} 49 } {1 {child process exited abnormally}}
50 do_test walcrash-1.$i.2 { 50 do_test walcrash-1.$i.2 {
(...skipping 16 matching lines...) Expand all
67 integrity_check walcrash-1.$i.6 67 integrity_check walcrash-1.$i.6
68 do_test walcrash-1.$i.7 { 68 do_test walcrash-1.$i.7 {
69 execsql { PRAGMA main.journal_mode } 69 execsql { PRAGMA main.journal_mode }
70 } {wal} 70 } {wal}
71 db close 71 db close
72 } 72 }
73 73
74 # walcrash-2.* 74 # walcrash-2.*
75 # 75 #
76 for {set i 1} {$i < $REPEATS} {incr i} { 76 for {set i 1} {$i < $REPEATS} {incr i} {
77 file delete -force test.db test.db-wal 77 forcedelete test.db test.db-wal
78 do_test walcrash-2.$i.1 { 78 do_test walcrash-2.$i.1 {
79 crashsql -delay 4 -file test.db-wal -seed [incr seed] { 79 crashsql -delay 5 -file test.db-wal -seed [incr seed] {
80 PRAGMA journal_mode = WAL; 80 PRAGMA journal_mode = WAL;
81 CREATE TABLE t1(a PRIMARY KEY, b); 81 CREATE TABLE t1(a PRIMARY KEY, b);
82 INSERT INTO t1 VALUES(1, 2); 82 INSERT INTO t1 VALUES(1, 2);
83 INSERT INTO t1 VALUES(3, 4); 83 INSERT INTO t1 VALUES(3, 4);
84 INSERT INTO t1 VALUES(5, 9); 84 INSERT INTO t1 VALUES(5, 9);
85 } 85 }
86 } {1 {child process exited abnormally}} 86 } {1 {child process exited abnormally}}
87 do_test walcrash-2.$i.2 { 87 do_test walcrash-2.$i.2 {
88 sqlite3 db test.db 88 sqlite3 db test.db
89 execsql { SELECT sum(a)==max(b) FROM t1 } 89 execsql { SELECT sum(a)==max(b) FROM t1 }
(...skipping 14 matching lines...) Expand all
104 integrity_check walcrash-2.$i.6 104 integrity_check walcrash-2.$i.6
105 do_test walcrash-2.$i.6 { 105 do_test walcrash-2.$i.6 {
106 execsql { PRAGMA main.journal_mode } 106 execsql { PRAGMA main.journal_mode }
107 } {wal} 107 } {wal}
108 db close 108 db close
109 } 109 }
110 110
111 # walcrash-3.* 111 # walcrash-3.*
112 # 112 #
113 # for {set i 1} {$i < $REPEATS} {incr i} { 113 # for {set i 1} {$i < $REPEATS} {incr i} {
114 # file delete -force test.db test.db-wal 114 # forcedelete test.db test.db-wal
115 # file delete -force test2.db test2.db-wal 115 # forcedelete test2.db test2.db-wal
116 # 116 #
117 # do_test walcrash-3.$i.1 { 117 # do_test walcrash-3.$i.1 {
118 # crashsql -delay 2 -file test2.db-wal -seed [incr seed] { 118 # crashsql -delay 2 -file test2.db-wal -seed [incr seed] {
119 # PRAGMA journal_mode = WAL; 119 # PRAGMA journal_mode = WAL;
120 # ATTACH 'test2.db' AS aux; 120 # ATTACH 'test2.db' AS aux;
121 # CREATE TABLE t1(a PRIMARY KEY, b); 121 # CREATE TABLE t1(a PRIMARY KEY, b);
122 # CREATE TABLE aux.t2(a PRIMARY KEY, b); 122 # CREATE TABLE aux.t2(a PRIMARY KEY, b);
123 # BEGIN; 123 # BEGIN;
124 # INSERT INTO t1 VALUES(1, 2); 124 # INSERT INTO t1 VALUES(1, 2);
125 # INSERT INTO t2 VALUES(1, 2); 125 # INSERT INTO t2 VALUES(1, 2);
(...skipping 10 matching lines...) Expand all
136 # } {} 136 # } {}
137 # do_test walcrash-3.$i.3 { execsql { PRAGMA main.integrity_check } } {ok} 137 # do_test walcrash-3.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
138 # do_test walcrash-3.$i.4 { execsql { PRAGMA aux.integrity_check } } {ok} 138 # do_test walcrash-3.$i.4 { execsql { PRAGMA aux.integrity_check } } {ok}
139 # 139 #
140 # db close 140 # db close
141 # } 141 # }
142 142
143 # walcrash-4.* 143 # walcrash-4.*
144 # 144 #
145 for {set i 1} {$i < $REPEATS} {incr i} { 145 for {set i 1} {$i < $REPEATS} {incr i} {
146 file delete -force test.db test.db-wal 146 forcedelete test.db test.db-wal
147 file delete -force test2.db test2.db-wal 147 forcedelete test2.db test2.db-wal
148 148
149 do_test walcrash-4.$i.1 { 149 do_test walcrash-4.$i.1 {
150 crashsql -delay 3 -file test.db-wal -seed [incr seed] -blocksize 4096 { 150 crashsql -delay 4 -file test.db-wal -seed [incr seed] -blocksize 4096 {
151 PRAGMA journal_mode = WAL; 151 PRAGMA journal_mode = WAL;
152 PRAGMA page_size = 1024; 152 PRAGMA page_size = 1024;
153 CREATE TABLE t1(a PRIMARY KEY, b); 153 CREATE TABLE t1(a PRIMARY KEY, b);
154 INSERT INTO t1 VALUES(1, 2); 154 INSERT INTO t1 VALUES(1, 2);
155 INSERT INTO t1 VALUES(3, 4); 155 INSERT INTO t1 VALUES(3, 4);
156 } 156 }
157 } {1 {child process exited abnormally}} 157 } {1 {child process exited abnormally}}
158 158
159 do_test walcrash-4.$i.2 { 159 do_test walcrash-4.$i.2 {
160 sqlite3 db test.db 160 sqlite3 db test.db
161 execsql { 161 execsql {
162 SELECT * FROM t1 WHERE a = 1; 162 SELECT * FROM t1 WHERE a = 1;
163 } 163 }
164 } {1 2} 164 } {1 2}
165 do_test walcrash-4.$i.3 { execsql { PRAGMA main.integrity_check } } {ok} 165 do_test walcrash-4.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
166 do_test walcrash-4.$i.4 { execsql { PRAGMA main.journal_mode } } {wal} 166 do_test walcrash-4.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
167 167
168 db close 168 db close
169 } 169 }
170 170
171 # walcrash-5.* 171 # walcrash-5.*
172 # 172 #
173 for {set i 1} {$i < $REPEATS} {incr i} { 173 for {set i 1} {$i < $REPEATS} {incr i} {
174 file delete -force test.db test.db-wal 174 forcedelete test.db test.db-wal
175 file delete -force test2.db test2.db-wal 175 forcedelete test2.db test2.db-wal
176 176
177 do_test walcrash-5.$i.1 { 177 do_test walcrash-5.$i.1 {
178 crashsql -delay 11 -file test.db-wal -seed [incr seed] -blocksize 4096 { 178 crashsql -delay 13 -file test.db-wal -seed [incr seed] -blocksize 4096 {
179 PRAGMA journal_mode = WAL; 179 PRAGMA journal_mode = WAL;
180 PRAGMA page_size = 1024; 180 PRAGMA page_size = 1024;
181 BEGIN; 181 BEGIN;
182 CREATE TABLE t1(x PRIMARY KEY); 182 CREATE TABLE t1(x PRIMARY KEY);
183 INSERT INTO t1 VALUES(randomblob(900)); 183 INSERT INTO t1 VALUES(randomblob(900));
184 INSERT INTO t1 VALUES(randomblob(900)); 184 INSERT INTO t1 VALUES(randomblob(900));
185 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */ 185 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
186 COMMIT; 186 COMMIT;
187 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 8 */ 187 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 8 */
188 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */ 188 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */
(...skipping 16 matching lines...) Expand all
205 } {1} 205 } {1}
206 do_test walcrash-5.$i.3 { execsql { PRAGMA main.integrity_check } } {ok} 206 do_test walcrash-5.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
207 do_test walcrash-5.$i.4 { execsql { PRAGMA main.journal_mode } } {wal} 207 do_test walcrash-5.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
208 208
209 db close 209 db close
210 } 210 }
211 211
212 # walcrash-6.* 212 # walcrash-6.*
213 # 213 #
214 for {set i 1} {$i < $REPEATS} {incr i} { 214 for {set i 1} {$i < $REPEATS} {incr i} {
215 file delete -force test.db test.db-wal 215 forcedelete test.db test.db-wal
216 file delete -force test2.db test2.db-wal 216 forcedelete test2.db test2.db-wal
217 217
218 do_test walcrash-6.$i.1 { 218 do_test walcrash-6.$i.1 {
219 crashsql -delay 12 -file test.db-wal -seed [incr seed] -blocksize 512 { 219 crashsql -delay 14 -file test.db-wal -seed [incr seed] -blocksize 512 {
220 PRAGMA journal_mode = WAL; 220 PRAGMA journal_mode = WAL;
221 PRAGMA page_size = 1024; 221 PRAGMA page_size = 1024;
222 BEGIN; 222 BEGIN;
223 CREATE TABLE t1(x PRIMARY KEY); 223 CREATE TABLE t1(x PRIMARY KEY);
224 INSERT INTO t1 VALUES(randomblob(900)); 224 INSERT INTO t1 VALUES(randomblob(900));
225 INSERT INTO t1 VALUES(randomblob(900)); 225 INSERT INTO t1 VALUES(randomblob(900));
226 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */ 226 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 4 */
227 COMMIT; 227 COMMIT;
228 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 8 */ 228 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 8 */
229 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */ 229 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */
230 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 16 */ 230 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 16 */
231 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 20 */ 231 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 20 */
232 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 24 */ 232 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 24 */
233 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */ 233 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
234 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */ 234 INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
235 235
236 PRAGMA wal_checkpoint; 236 PRAGMA wal_checkpoint;
237 INSERT INTO t1 VALUES(randomblob(900)); 237 INSERT INTO t1 VALUES(randomblob(9000));
238 INSERT INTO t1 VALUES(randomblob(900)); 238 INSERT INTO t1 VALUES(randomblob(9000));
239 INSERT INTO t1 VALUES(randomblob(900)); 239 INSERT INTO t1 VALUES(randomblob(9000));
240 } 240 }
241 } {1 {child process exited abnormally}} 241 } {1 {child process exited abnormally}}
242 242
243 do_test walcrash-6.$i.2 { 243 do_test walcrash-6.$i.2 {
244 sqlite3 db test.db 244 sqlite3 db test.db
245 execsql { SELECT count(*)==34 OR count(*)==35 FROM t1 WHERE x != 1 } 245 execsql { SELECT count(*)==34 OR count(*)==35 FROM t1 WHERE x != 1 }
246 } {1} 246 } {1}
247 do_test walcrash-6.$i.3 { execsql { PRAGMA main.integrity_check } } {ok} 247 do_test walcrash-6.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
248 do_test walcrash-6.$i.4 { execsql { PRAGMA main.journal_mode } } {wal} 248 do_test walcrash-6.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
249 249
250 db close 250 db close
251 } 251 }
252 252
253 #------------------------------------------------------------------------- 253 #-------------------------------------------------------------------------
254 # This test case simulates a crash while checkpointing the database. Page 254 # This test case simulates a crash while checkpointing the database. Page
255 # 1 is one of the pages overwritten by the checkpoint. This is a special 255 # 1 is one of the pages overwritten by the checkpoint. This is a special
256 # case because it means the content of page 1 may be damaged. SQLite will 256 # case because it means the content of page 1 may be damaged. SQLite will
257 # have to determine: 257 # have to determine:
258 # 258 #
259 # (a) that the database is a WAL database, and 259 # (a) that the database is a WAL database, and
260 # (b) the database page-size 260 # (b) the database page-size
261 # 261 #
262 # based on the log file. 262 # based on the log file.
263 # 263 #
264 for {set i 1} {$i < $REPEATS} {incr i} { 264 for {set i 1} {$i < $REPEATS} {incr i} {
265 file delete -force test.db test.db-wal 265 forcedelete test.db test.db-wal
266 266
267 # Select a page-size for this test. 267 # Select a page-size for this test.
268 # 268 #
269 set pgsz [lindex {512 1024 2048 4096 8192 16384} [expr $i%6]] 269 set pgsz [lindex {512 1024 2048 4096 8192 16384} [expr $i%6]]
270 270
271 do_test walcrash-7.$i.1 { 271 do_test walcrash-7.$i.1 {
272 crashsql -delay 3 -file test.db -seed [incr seed] -blocksize 512 " 272 crashsql -delay 3 -file test.db -seed [incr seed] -blocksize 512 "
273 PRAGMA page_size = $pgsz; 273 PRAGMA page_size = $pgsz;
274 PRAGMA journal_mode = wal; 274 PRAGMA journal_mode = wal;
275 BEGIN; 275 BEGIN;
(...skipping 10 matching lines...) Expand all
286 sqlite3 db test.db 286 sqlite3 db test.db
287 execsql { SELECT b FROM t1 WHERE a = 1 } 287 execsql { SELECT b FROM t1 WHERE a = 1 }
288 } {2} 288 } {2}
289 do_test walcrash-7.$i.3 { execsql { PRAGMA main.integrity_check } } {ok} 289 do_test walcrash-7.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}
290 do_test walcrash-7.$i.4 { execsql { PRAGMA main.journal_mode } } {wal} 290 do_test walcrash-7.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}
291 291
292 db close 292 db close
293 } 293 }
294 294
295 finish_test 295 finish_test
296
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698