mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add tests to pager1.test.
FossilOrigin-Name: 582fca89195af54e9668af249691654cfea63d04
This commit is contained in:
@ -22,6 +22,8 @@ source $testdir/malloc_common.tcl
|
||||
#
|
||||
# pager1-3.*: Savepoint related tests.
|
||||
#
|
||||
# pager1-4.*: Hot-journal related tests.
|
||||
#
|
||||
|
||||
proc do_execsql_test {testname sql result} {
|
||||
uplevel do_test $testname [list "execsql {$sql}"] [list $result]
|
||||
@ -210,6 +212,99 @@ do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}
|
||||
do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}
|
||||
do_execsql_test pager1-3.6 { COMMIT } {}
|
||||
|
||||
testvfs tv -default 1
|
||||
foreach code [list {
|
||||
set s 512
|
||||
set sql { PRAGMA synchronous = off }
|
||||
} {
|
||||
set s 1024
|
||||
set sql { PRAGMA journal_mode = memory }
|
||||
} {
|
||||
set s 2048
|
||||
tv devchar safe_append
|
||||
} {
|
||||
set s 4096
|
||||
set sql { PRAGMA journal_mode = WAL }
|
||||
}] {
|
||||
eval $code
|
||||
tv sectorsize $s
|
||||
|
||||
do_test pager1-3.7.$s.1 {
|
||||
faultsim_delete_and_reopen
|
||||
execsql $sql
|
||||
execsql {
|
||||
PRAGMA cache_size = 10;
|
||||
CREATE TABLE t1(i INTEGER PRIMARY KEY, j blob);
|
||||
}
|
||||
} {}
|
||||
|
||||
set tn 0
|
||||
set lowpoint 0
|
||||
foreach x {
|
||||
70 22 96 59 96 50 22 56 21 16 37 64 43 40 0 38 22 38 55 0 6
|
||||
43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69
|
||||
2 29 6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43
|
||||
x
|
||||
86 34 26 50 41 85 58 44 89 22 6 51 45 46 58 32 97 6 1 12 32 2
|
||||
69 39 48 71 33 31 5 58 90 43 24 54 12 9 18 57 4 38 91 42 27 45
|
||||
50 38 56 29 10 0 26 37 83 1 78 15 47 30 75 62 46 29 68 5 30 4
|
||||
27 96 33 95 79 75 56 10 29 70 32 75 52 88 5 36 50 57 46 63 88 65
|
||||
x
|
||||
44 95 64 20 24 35 69 61 61 2 35 92 42 46 23 98 78 1 38 72 79 35
|
||||
94 37 13 59 5 93 27 58 80 75 58 7 67 13 10 76 84 4 8 70 81 45
|
||||
8 41 98 5 60 26 92 29 91 90 2 62 40 4 5 22 80 15 83 76 52 88
|
||||
29 5 68 73 72 7 54 17 89 32 81 94 51 28 53 71 8 42 54 59 70 79
|
||||
x
|
||||
35 59 37 22 8 72 10 48 79 6 87 96 59 95 45 56 6 4 86 68 25 28
|
||||
43 75 47 9 53 18 69 51 11 94 86 65 23 87 49 19 20 20 33 14 11 86
|
||||
42 23 8 40 94 55 4 38 52 30 6 25 44 79 57 82 30 87 86 75 40 92
|
||||
29 26 82 91 67 64 15 51 17 11 15 27 32 7 38 1 52 82 26 99 17 18
|
||||
38 13 20 65 91 98 50 81 49 15 94 45 84 35 31 67 13 43 78 3 94 77
|
||||
47 18 96 66 99 77 11 11 70 18 1 29 79 57 59 86 94 34 91 15 24 53
|
||||
61 73 58 46 36 79 90 89 12 0 91 0 86 44 71 83 75 76 97 65 13 80
|
||||
42 39 15 44 90 18 67 69 1 72 17 99 12 72 77 17 3 34 75 59 92 76
|
||||
18 86 60 12 20 98 48 14 12 67 45 44 10 2 5 88 7 45 5 47 45 75
|
||||
19 25 42 62 66 17 94 63 0 53 38 81 26 11 97 33 13 36 81 82 73 26
|
||||
78 90 28 78 26 61 9 74 70 53 17 86 51 90 3 30 99 5 25 44 6 72
|
||||
84 32 74 46 16 44 74 82 84 9 58 90 85 82 53 40 37
|
||||
} {
|
||||
incr tn
|
||||
set now [db one {SELECT count(i) FROM t1}]
|
||||
if {$x == "x"} {
|
||||
execsql { COMMIT ; BEGIN }
|
||||
set lowpoint $now
|
||||
do_test pager1.3.7.$s.2.$tn {
|
||||
sqlite3 db2 test.db
|
||||
execsql {
|
||||
SELECT COALESCE(max(i), 0) FROM t1;
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} [list $lowpoint ok]
|
||||
db2 close
|
||||
} else {
|
||||
if {$now > $x } {
|
||||
if { $x>=$lowpoint } {
|
||||
execsql "ROLLBACK TO sp_$x"
|
||||
} else {
|
||||
execsql "DELETE FROM t1 WHERE i>$x"
|
||||
set lowpoint $x
|
||||
}
|
||||
} elseif {$now < $x} {
|
||||
for {set k $now} {$k < $x} {incr k} {
|
||||
execsql "SAVEPOINT sp_$k"
|
||||
execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }
|
||||
}
|
||||
}
|
||||
do_execsql_test pager1.3.7.$s.2.$tn {
|
||||
SELECT COALESCE(max(i), 0) FROM t1;
|
||||
PRAGMA integrity_check;
|
||||
} [list $x ok]
|
||||
}
|
||||
}
|
||||
}
|
||||
db close
|
||||
tv delete
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Hot journal rollback related test cases.
|
||||
#
|
||||
|
Reference in New Issue
Block a user