Annotation of embedaddon/sqlite3/test/pager2.test, revision 1.1
1.1 ! misho 1: # 2010 June 15
! 2: #
! 3: # The author disclaims copyright to this source code. In place of
! 4: # a legal notice, here is a blessing:
! 5: #
! 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.
! 9: #
! 10: #***********************************************************************
! 11: #
! 12:
! 13: set testdir [file dirname $argv0]
! 14: source $testdir/tester.tcl
! 15: source $testdir/lock_common.tcl
! 16: source $testdir/malloc_common.tcl
! 17:
! 18: set otn 0
! 19: testvfs tv -default 1
! 20: foreach code [list {
! 21: set s 512
! 22: } {
! 23: set s 1024
! 24: set sql { PRAGMA journal_mode = memory }
! 25: } {
! 26: set s 1024
! 27: set sql {
! 28: PRAGMA journal_mode = memory;
! 29: PRAGMA locking_mode = exclusive;
! 30: }
! 31: } {
! 32: set s 2048
! 33: tv devchar safe_append
! 34: } {
! 35: set s 4096
! 36: } {
! 37: set s 4096
! 38: set sql { PRAGMA journal_mode = WAL }
! 39: } {
! 40: set s 4096
! 41: set sql { PRAGMA auto_vacuum = 1 }
! 42: } {
! 43: set s 8192
! 44: set sql { PRAGMA synchronous = off }
! 45: }] {
! 46:
! 47: incr otn
! 48: set sql ""
! 49: tv devchar {}
! 50: eval $code
! 51: tv sectorsize $s
! 52:
! 53: do_test pager2-1.$otn.0 {
! 54: faultsim_delete_and_reopen
! 55: execsql $sql
! 56: execsql {
! 57: PRAGMA cache_size = 10;
! 58: CREATE TABLE t1(i INTEGER PRIMARY KEY, j blob);
! 59: }
! 60: } {}
! 61:
! 62: set tn 0
! 63: set lowpoint 0
! 64: foreach x {
! 65: 100 x 0 100
! 66: x
! 67: 70 22 96 59 96 50 22 56 21 16 37 64 43 40 0 38 22 38 55 0 6
! 68: 43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69
! 69: 2 29 6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43
! 70: x
! 71: 86 34 26 50 41 85 58 44 89 22 6 51 45 46 58 32 97 6 1 12 32 2
! 72: 69 39 48 71 33 31 5 58 90 43 24 54 12 9 18 57 4 38 91 42 27 45
! 73: 50 38 56 29 10 0 26 37 83 1 78 15 47 30 75 62 46 29 68 5 30 4
! 74: 27 96 33 95 79 75 56 10 29 70 32 75 52 88 5 36 50 57 46 63 88 65
! 75: x
! 76: 44 95 64 20 24 35 69 61 61 2 35 92 42 46 23 98 78 1 38 72 79 35
! 77: 94 37 13 59 5 93 27 58 80 75 58 7 67 13 10 76 84 4 8 70 81 45
! 78: 8 41 98 5 60 26 92 29 91 90 2 62 40 4 5 22 80 15 83 76 52 88
! 79: 29 5 68 73 72 7 54 17 89 32 81 94 51 28 53 71 8 42 54 59 70 79
! 80: x
! 81: } {
! 82: incr tn
! 83: set now [db one {SELECT count(i) FROM t1}]
! 84: if {$x == "x"} {
! 85: execsql { COMMIT ; BEGIN }
! 86: set lowpoint $now
! 87: do_test pager2.1.$otn.$tn {
! 88: sqlite3 db2 test.db
! 89: execsql {
! 90: SELECT COALESCE(max(i), 0) FROM t1;
! 91: PRAGMA integrity_check;
! 92: }
! 93: } [list $lowpoint ok]
! 94: db2 close
! 95: } else {
! 96: if {$now > $x } {
! 97: if { $x>=$lowpoint } {
! 98: execsql "ROLLBACK TO sp_$x"
! 99: } else {
! 100: execsql "DELETE FROM t1 WHERE i>$x"
! 101: set lowpoint $x
! 102: }
! 103: } elseif {$now < $x} {
! 104: for {set k $now} {$k < $x} {incr k} {
! 105: execsql "SAVEPOINT sp_$k"
! 106: execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }
! 107: }
! 108: }
! 109: do_execsql_test pager2.1.$otn.$tn {
! 110: SELECT COALESCE(max(i), 0) FROM t1;
! 111: PRAGMA integrity_check;
! 112: } [list $x ok]
! 113: }
! 114: }
! 115: }
! 116: db close
! 117: tv delete
! 118:
! 119:
! 120: #-------------------------------------------------------------------------
! 121: #
! 122: # pager2-2.1: Test a ROLLBACK with journal_mode=off.
! 123: # pager2-2.2: Test shrinking the database (auto-vacuum) with
! 124: # journal_mode=off
! 125: #
! 126: do_test pager2-2.1 {
! 127: faultsim_delete_and_reopen
! 128: execsql {
! 129: CREATE TABLE t1(a, b);
! 130: PRAGMA journal_mode = off;
! 131: BEGIN;
! 132: INSERT INTO t1 VALUES(1, 2);
! 133: ROLLBACK;
! 134: SELECT * FROM t1;
! 135: }
! 136: } {off}
! 137: do_test pager2-2.2 {
! 138: faultsim_delete_and_reopen
! 139: execsql {
! 140: PRAGMA auto_vacuum = incremental;
! 141: PRAGMA page_size = 1024;
! 142: PRAGMA journal_mode = off;
! 143: CREATE TABLE t1(a, b);
! 144: INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));
! 145: DELETE FROM t1;
! 146: PRAGMA incremental_vacuum;
! 147: }
! 148: file size test.db
! 149: } {3072}
! 150:
! 151: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>