OLD | NEW |
1 # 2009 January 8 | 1 # 2009 January 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 # large journal file allocated at the start of the transaction, this | 236 # large journal file allocated at the start of the transaction, this |
237 # may mean truncating the file so that the master journal name really | 237 # may mean truncating the file so that the master journal name really |
238 # is at the physical end of the file. | 238 # is at the physical end of the file. |
239 # | 239 # |
240 # This block of tests test that SQLite correctly truncates such | 240 # This block of tests test that SQLite correctly truncates such |
241 # journal files, and that the results behave correctly if a hot-journal | 241 # journal files, and that the results behave correctly if a hot-journal |
242 # rollback occurs. | 242 # rollback occurs. |
243 # | 243 # |
244 ifcapable pragma { | 244 ifcapable pragma { |
245 reset_db | 245 reset_db |
246 file delete -force test2.db | 246 forcedelete test2.db |
247 | 247 |
248 do_test crash8-4.1 { | 248 do_test crash8-4.1 { |
249 execsql { | 249 execsql { |
250 PRAGMA journal_mode = persist; | 250 PRAGMA journal_mode = persist; |
251 CREATE TABLE ab(a, b); | 251 CREATE TABLE ab(a, b); |
252 INSERT INTO ab VALUES(0, 'abc'); | 252 INSERT INTO ab VALUES(0, 'abc'); |
253 INSERT INTO ab VALUES(1, NULL); | 253 INSERT INTO ab VALUES(1, NULL); |
254 INSERT INTO ab VALUES(2, NULL); | 254 INSERT INTO ab VALUES(2, NULL); |
255 INSERT INTO ab VALUES(3, NULL); | 255 INSERT INTO ab VALUES(3, NULL); |
256 INSERT INTO ab VALUES(4, NULL); | 256 INSERT INTO ab VALUES(4, NULL); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 close $fd | 329 close $fd |
330 | 330 |
331 file exists $zMasterJournal | 331 file exists $zMasterJournal |
332 } {1} | 332 } {1} |
333 | 333 |
334 do_test crash8-4.9 { | 334 do_test crash8-4.9 { |
335 execsql { SELECT b FROM aux.ab WHERE a = 0 } | 335 execsql { SELECT b FROM aux.ab WHERE a = 0 } |
336 } {def} | 336 } {def} |
337 | 337 |
338 do_test crash8-4.10 { | 338 do_test crash8-4.10 { |
339 file delete $zMasterJournal | 339 delete_file $zMasterJournal |
340 execsql { SELECT b FROM main.ab WHERE a = 0 } | 340 execsql { SELECT b FROM main.ab WHERE a = 0 } |
341 } {jkl} | 341 } {jkl} |
342 } | 342 } |
343 | 343 |
344 for {set i 1} {$i < 10} {incr i} { | 344 # |
345 catch { db close } | 345 # Since the following tests (crash8-5.*) rely upon being able |
346 file delete -force test.db test.db-journal | 346 # to copy a file while open, they will not work on Windows. |
347 sqlite3 db test.db | 347 # |
348 do_test crash8-5.$i.1 { | 348 if {$::tcl_platform(platform)=="unix"} { |
349 execsql { | 349 for {set i 1} {$i < 10} {incr i} { |
350 CREATE TABLE t1(x PRIMARY KEY); | 350 catch { db close } |
351 INSERT INTO t1 VALUES(randomblob(900)); | 351 forcedelete test.db test.db-journal |
352 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 352 sqlite3 db test.db |
353 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 353 do_test crash8-5.$i.1 { |
354 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 354 execsql { |
355 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 355 CREATE TABLE t1(x PRIMARY KEY); |
356 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 356 INSERT INTO t1 VALUES(randomblob(900)); |
357 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */ | 357 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
358 } | 358 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
359 crashsql -file test.db -delay [expr ($::i%2) + 1] { | 359 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
360 PRAGMA cache_size = 10; | 360 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
361 BEGIN; | 361 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
362 UPDATE t1 SET x = randomblob(900); | 362 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */ |
363 ROLLBACK; | 363 } |
364 INSERT INTO t1 VALUES(randomblob(900)); | 364 crashsql -file test.db -delay [expr ($::i%2) + 1] { |
365 } | 365 PRAGMA cache_size = 10; |
366 execsql { PRAGMA integrity_check } | 366 BEGIN; |
367 } {ok} | 367 UPDATE t1 SET x = randomblob(900); |
| 368 ROLLBACK; |
| 369 INSERT INTO t1 VALUES(randomblob(900)); |
| 370 } |
| 371 execsql { PRAGMA integrity_check } |
| 372 } {ok} |
368 | 373 |
369 catch { db close } | 374 catch { db close } |
370 file delete -force test.db test.db-journal | 375 forcedelete test.db test.db-journal |
371 sqlite3 db test.db | 376 sqlite3 db test.db |
372 do_test crash8-5.$i.2 { | 377 do_test crash8-5.$i.2 { |
373 execsql { | 378 execsql { |
374 PRAGMA cache_size = 10; | 379 PRAGMA cache_size = 10; |
375 CREATE TABLE t1(x PRIMARY KEY); | 380 CREATE TABLE t1(x PRIMARY KEY); |
376 INSERT INTO t1 VALUES(randomblob(900)); | 381 INSERT INTO t1 VALUES(randomblob(900)); |
377 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 382 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
378 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 383 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
379 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 384 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
380 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 385 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
381 INSERT INTO t1 SELECT randomblob(900) FROM t1; | 386 INSERT INTO t1 SELECT randomblob(900) FROM t1; |
382 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */ | 387 INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */ |
383 BEGIN; | 388 BEGIN; |
384 UPDATE t1 SET x = randomblob(900); | 389 UPDATE t1 SET x = randomblob(900); |
385 } | 390 } |
386 file delete -force testX.db testX.db-journal testX.db-wal | 391 forcedelete testX.db testX.db-journal testX.db-wal |
387 copy_file test.db testX.db | 392 forcecopy test.db testX.db |
388 copy_file test.db-journal testX.db-journal | 393 forcecopy test.db-journal testX.db-journal |
389 db close | 394 db close |
390 | 395 |
391 crashsql -file test.db -delay [expr ($::i%2) + 1] { | 396 crashsql -file test.db -delay [expr ($::i%2) + 1] { |
392 SELECT * FROM sqlite_master; | 397 SELECT * FROM sqlite_master; |
393 INSERT INTO t1 VALUES(randomblob(900)); | 398 INSERT INTO t1 VALUES(randomblob(900)); |
394 } | 399 } |
395 | 400 |
396 sqlite3 db2 testX.db | 401 sqlite3 db2 testX.db |
397 execsql { PRAGMA integrity_check } db2 | 402 execsql { PRAGMA integrity_check } db2 |
398 } {ok} | 403 } {ok} |
| 404 } |
| 405 catch {db2 close} |
399 } | 406 } |
400 catch {db2 close} | |
401 | 407 |
402 finish_test | 408 finish_test |
OLD | NEW |