Overview
| SHA1 Hash: | bf57534188e044fb341315bfc05b7927e66a04e0 |
|---|---|
| Date: | 2013-02-25 12:06:55 |
| User: | dan |
| Comment: | Add test file incrvacuum3.test. No code changes. |
Tags And Properties
- branch=incr-vacuum-opt inherited from [c3939d2491]
- closed added by [9c847c9cdb] on 2013-03-06 11:31:57
- sym-incr-vacuum-opt inherited from [c3939d2491]
Changes
Added test/incrvacuum3.test
> 1 # 2013 Feb 25 > 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 # This file implements regression tests for the SQLite library, focusing > 12 # on the incremental vacuum feature. > 13 # > 14 # The tests in this file were added at the same time as optimizations > 15 # were made to: > 16 # > 17 # * Truncate the database after a rollback mode commit, and > 18 # > 19 # * Avoid moving pages to locations from which they may need to be moved > 20 # a second time if an incremental-vacuum proccess is allowed to vacuum > 21 # the entire database. > 22 # > 23 > 24 set testdir [file dirname $argv0] > 25 source $testdir/tester.tcl > 26 set testprefix incrvacuum3 > 27 > 28 # If this build of the library does not support auto-vacuum, omit this > 29 # whole file. > 30 ifcapable {!autovacuum || !pragma} { > 31 finish_test > 32 return > 33 } > 34 > 35 proc check_on_disk {} { > 36 > 37 # Copy the files for database "test.db" to "test2.db". > 38 forcedelete test2.db test2.db-journal test2.db-wal > 39 forcecopy test.db test2.db > 40 if {[file exists test.db-journal]} { > 41 forcecopy test.db-journal test2.db-journal > 42 } > 43 if {[file exists test.db-wal]} { > 44 forcecopy test.db-wal test2.db-wal > 45 } > 46 > 47 # Open "test2.db" and check it is Ok. > 48 sqlite3 dbcheck test2.db > 49 set ret [dbcheck eval { PRAGMA integrity_check }] > 50 dbcheck close > 51 set ret > 52 } > 53 > 54 # Run these tests once in rollback journal mode, and once in wal mode. > 55 # > 56 foreach {T jrnl_mode} { > 57 1 delete > 58 2 wal > 59 } { > 60 catch { db close } > 61 forcedelete test.db test.db-journal test.db-wal > 62 sqlite3 db test.db > 63 db eval { > 64 PRAGMA cache_size = 5; > 65 PRAGMA page_size = 1024; > 66 PRAGMA auto_vacuum = 2; > 67 } > 68 db eval "PRAGMA journal_mode = $jrnl_mode" > 69 > 70 foreach {tn sql} { > 71 1 { > 72 CREATE TABLE t1(x UNIQUE); > 73 INSERT INTO t1 VALUES(randomblob(400)); > 74 INSERT INTO t1 VALUES(randomblob(400)); > 75 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 4 > 76 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 8 > 77 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 16 > 78 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 32 > 79 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 > 80 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 > 81 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 > 82 } > 83 > 84 2 { > 85 DELETE FROM t1 WHERE rowid%8; > 86 } > 87 > 88 3 { > 89 BEGIN; > 90 PRAGMA incremental_vacuum = 100; > 91 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 > 92 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 > 93 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 > 94 ROLLBACK; > 95 } > 96 > 97 4 { > 98 BEGIN; > 99 SAVEPOINT one; > 100 PRAGMA incremental_vacuum = 100; > 101 SAVEPOINT two; > 102 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 > 103 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 > 104 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 > 105 } > 106 > 107 5 { ROLLBACK to two } > 108 > 109 6 { ROLLBACK to one } > 110 > 111 7 { > 112 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 > 113 PRAGMA incremental_vacuum = 1000; > 114 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 > 115 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 256 > 116 ROLLBACK; > 117 } > 118 > 119 8 { > 120 BEGIN; > 121 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 64 > 122 PRAGMA incremental_vacuum = 1000; > 123 INSERT INTO t1 SELECT randomblob(400) FROM t1; -- 128 > 124 COMMIT; > 125 } > 126 } { > 127 do_execsql_test $T.1.$tn.1 $sql > 128 do_execsql_test $T.1.$tn.2 {PRAGMA integrity_check} ok > 129 do_test $T.1.$tn.3 { check_on_disk } ok > 130 } > 131 > 132 do_execsql_test $T.1.x.1 { PRAGMA freelist_count } 0 > 133 do_execsql_test $T.1.x.2 { SELECT count(*) FROM t1 } 128 > 134 } > 135 > 136 finish_test > 137