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

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

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/sqlite/src/test/wal3.test ('k') | third_party/sqlite/src/test/wal6.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2010 April 13 1 # 2010 April 13
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 wal5-capi { 50 wal5-capi {
51 proc do_wal_checkpoint { dbhandle args } { 51 proc do_wal_checkpoint { dbhandle args } {
52 set a(-mode) passive 52 set a(-mode) passive
53 array set a $args 53 array set a $args
54 foreach key [array names a] { 54 foreach key [array names a] {
55 if {[lsearch {-mode -db} $key]<0} { error "unknown switch: $key" } 55 if {[lsearch {-mode -db} $key]<0} { error "unknown switch: $key" }
56 } 56 }
57 57
58 if {$a(-mode)!="restart" && $a(-mode)!="full"} { set a(-mode) passive } 58 set vals {restart full truncate}
59 if {[lsearch -exact $vals $a(-mode)]<0} { set a(-mode) passive }
59 60
60 set cmd [list sqlite3_wal_checkpoint_v2 $dbhandle $a(-mode)] 61 set cmd [list sqlite3_wal_checkpoint_v2 $dbhandle $a(-mode)]
61 if {[info exists a(-db)]} { lappend sql $a(-db) } 62 if {[info exists a(-db)]} { lappend sql $a(-db) }
62 63
63 uplevel $cmd 64 uplevel $cmd
64 } 65 }
65 } 66 }
66 } { 67 } {
67 68
68 eval $do_wal_checkpoint 69 eval $do_wal_checkpoint
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 3 FULL - {0 4 4} 2 272 3 FULL - {0 4 4} 2
272 4 FULL 1 {1 3 3} 1 273 4 FULL 1 {1 3 3} 1
273 5 FULL 2 {1 4 3} 2 274 5 FULL 2 {1 4 3} 2
274 6 FULL 3 {0 4 4} 2 275 6 FULL 3 {0 4 4} 2
275 276
276 7 RESTART - {0 4 4} 3 277 7 RESTART - {0 4 4} 3
277 8 RESTART 1 {1 3 3} 1 278 8 RESTART 1 {1 3 3} 1
278 9 RESTART 2 {1 4 3} 2 279 9 RESTART 2 {1 4 3} 2
279 10 RESTART 3 {1 4 4} 3 280 10 RESTART 3 {1 4 4} 3
280 281
282 11 TRUNCATE - {0 0 0} 3
283 12 TRUNCATE 1 {1 3 3} 1
284 13 TRUNCATE 2 {1 4 3} 2
285 14 TRUNCATE 3 {1 4 4} 3
286
281 } { 287 } {
282 do_multiclient_test tn { 288 do_multiclient_test tn {
283 setup_and_attach_aux 289 setup_and_attach_aux
284 290
285 proc busyhandler {x} { 291 proc busyhandler {x} {
286 set ::max_busyhandler $x 292 set ::max_busyhandler $x
287 if {$::busy_on!="-" && $x==$::busy_on} { return 1 } 293 if {$::busy_on!="-" && $x==$::busy_on} { return 1 }
288 switch -- $x { 294 switch -- $x {
289 1 { sql2 "COMMIT ; BEGIN ; SELECT * FROM t1" } 295 1 { sql2 "COMMIT ; BEGIN ; SELECT * FROM t1" }
290 2 { sql3 "COMMIT" } 296 2 { sql3 "COMMIT" }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 code3 {db3 close} 347 code3 {db3 close}
342 348
343 code1 {sqlite3 db test.db} 349 code1 {sqlite3 db test.db}
344 code2 {sqlite3 db2 test.db} 350 code2 {sqlite3 db2 test.db}
345 code3 {sqlite3 db3 test.db} 351 code3 {sqlite3 db3 test.db}
346 352
347 do_test 3.$tn.5 { sql3 { PRAGMA journal_mode } } {wal} 353 do_test 3.$tn.5 { sql3 { PRAGMA journal_mode } } {wal}
348 354
349 do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0} 355 do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}
350 } 356 }
357
358 # Test SQLITE_CHECKPOINT_TRUNCATE.
359 #
360 do_multiclient_test tn {
361
362 code1 $do_wal_checkpoint
363 code2 $do_wal_checkpoint
364 code3 $do_wal_checkpoint
365
366 do_test 4.$tn.1 {
367 sql1 {
368 PRAGMA page_size = 1024;
369 PRAGMA auto_vacuum = 0;
370 PRAGMA journal_mode = WAL;
371 PRAGMA synchronous = normal;
372 CREATE TABLE t1(x, y);
373 CREATE INDEX i1 ON t1(x, y);
374 INSERT INTO t1 VALUES(1, 2);
375 INSERT INTO t1 VALUES(3, 4);
376 }
377 file size test.db-wal
378 } [wal_file_size 8 1024]
379
380 do_test 4.$tn.2 { do_wal_checkpoint db -mode truncate } {0 0 0}
381 do_test 4.$tn.3 { file size test.db-wal } 0
382
383 do_test 4.$tn.4 {
384 sql2 { SELECT * FROM t1 }
385 } {1 2 3 4}
386
387 do_test 4.$tn.5 {
388 sql2 { INSERT INTO t1 VALUES('a', 'b') }
389 file size test.db-wal
390 } [wal_file_size 2 1024]
391
392 }
393
394 # Test that FULL, RESTART and TRUNCATE callbacks block on other clients
395 # and truncate the wal file as required even if the entire wal file has
396 # already been checkpointed when they are invoked.
397 #
398 do_multiclient_test tn {
399
400 code1 $do_wal_checkpoint
401 code2 $do_wal_checkpoint
402 code3 $do_wal_checkpoint
403
404 do_test 5.$tn.1 {
405 sql1 {
406 PRAGMA page_size = 1024;
407 PRAGMA auto_vacuum = 0;
408 PRAGMA journal_mode = WAL;
409 PRAGMA synchronous = normal;
410 CREATE TABLE t1(x, y);
411 CREATE INDEX i1 ON t1(x, y);
412 INSERT INTO t1 VALUES(1, 2);
413 INSERT INTO t1 VALUES(3, 4);
414 INSERT INTO t1 VALUES(5, 6);
415 }
416 file size test.db-wal
417 } [wal_file_size 10 1024]
418
419 do_test 5.$tn.2 {
420 sql2 { BEGIN; SELECT * FROM t1 }
421 } {1 2 3 4 5 6}
422
423 do_test 5.$tn.3 { do_wal_checkpoint db -mode passive } {0 10 10}
424
425 do_test 5.$tn.4 {
426 sql3 { BEGIN; INSERT INTO t1 VALUES(7, 8); }
427 } {}
428
429 do_test 5.$tn.5 { do_wal_checkpoint db -mode passive } {0 10 10}
430 do_test 5.$tn.6 { do_wal_checkpoint db -mode full } {1 10 10}
431
432 do_test 5.$tn.7 { sql3 { ROLLBACK } } {}
433
434 do_test 5.$tn.8 { do_wal_checkpoint db -mode full } {0 10 10}
435 do_test 5.$tn.9 { do_wal_checkpoint db -mode truncate } {1 10 10}
436
437 do_test 5.$tn.10 {
438 file size test.db-wal
439 } [wal_file_size 10 1024]
440
441 proc xBusyHandler {n} { sql2 { COMMIT } ; return 0 }
442 db busy xBusyHandler
443
444 do_test 5.$tn.11 { do_wal_checkpoint db -mode truncate } {0 0 0}
445 do_test 5.$tn.12 { file size test.db-wal } 0
446
447 do_test 5.$tn.13 {
448 sql1 {
449 INSERT INTO t1 VALUES(7, 8);
450 INSERT INTO t1 VALUES(9, 10);
451 SELECT * FROM t1;
452 }
453 } {1 2 3 4 5 6 7 8 9 10}
454
455 do_test 5.$tn.14 {
456 sql2 { BEGIN; SELECT * FROM t1 }
457 } {1 2 3 4 5 6 7 8 9 10}
458
459 proc xBusyHandler {n} { return 1 }
460 do_test 5.$tn.15 { do_wal_checkpoint db -mode truncate } {1 4 4}
461 do_test 5.$tn.16 { file size test.db-wal } [wal_file_size 4 1024]
462
463 do_test 5.$tn.17 { do_wal_checkpoint db -mode restart } {1 4 4}
464
465 proc xBusyHandler {n} { sql2 { COMMIT } ; return 0 }
466 db busy xBusyHandler
467 do_test 5.$tn.18 { do_wal_checkpoint db -mode restart } {0 4 4}
468 do_test 5.$tn.19 { file size test.db-wal } [wal_file_size 4 1024]
469
470 do_test 5.$tn.20 { do_wal_checkpoint db -mode truncate } {0 0 0}
471 do_test 5.$tn.21 { file size test.db-wal } 0
472 }
473
351 } 474 }
352 475
353 476
354 finish_test 477 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/wal3.test ('k') | third_party/sqlite/src/test/wal6.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698