-C Modifications\sto\sbtree\sintegrity\scheck\sso\sthat\sit\scan\sbe\srun\sinside\sa\stransaction\safter\san\sincr\svacuum.\s(CVS\s3878)
-D 2007-04-27T07:05:44
+C Extra\stests\sfor\sincremental\svacuum.\s(CVS\s3879)
+D 2007-04-27T07:55:38
F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F test/func.test d66c42af501a77bd9b36c3d675d844b04db04765
F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
-F test/incrvacuum.test 6c14f0492f00437ebf8275eac0a80f97799d99d4
+F test/incrvacuum.test fc5e88ac32095fb65ea11b739bc4e310c4852ef4
F test/index.test e65df12bed94b2903ee89987115e1578687e9266
F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
F test/index3.test f66718cd92ce1216819d47e6a156755e4b2c4ca1
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P e6a0c90dd9b4f7efe2153dd0c899b6e3d9846bd8
-R 3e1e2e05e5e9e264674bc6629d08b7ad
+P 4d4180d6474d8d74460fb9333580b9b60c89f353
+R cb55629cd4ed6b5c3bd0582e6bc3a138
U danielk1977
-Z 1d29f050695ac44aa0f3dcac643e125b
+Z f3e9134088bb4d98704fded975f43270
# This file implements regression tests for SQLite library. The
# focus of this file is testing the incremental vacuum feature.
#
-# $Id: incrvacuum.test,v 1.2 2007/04/27 07:05:44 danielk1977 Exp $
+# $Id: incrvacuum.test,v 1.3 2007/04/27 07:55:38 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
SELECT * FROM tbl2;
}
} {{a nice string}}
+do_test incrvacuum-5.2.5 {
+ execsql {
+ DROP TABLE tbl1;
+ DROP TABLE tbl2;
+ INCREMENTAL VACUUM;
+ }
+ expr {[file size test.db] / 1024}
+} {1}
+
+# Test cases incrvacuum-5.3.* use the following list as input data.
+# Two new databases are opened, one with incremental vacuum enabled,
+# the other with no auto-vacuum completely disabled. After executing
+# each element of the following list on both databases, test that
+# the integrity-check passes and the contents of each are identical.
+#
set TestScriptList [list {
BEGIN;
CREATE TABLE t1(a, b);
} {
CREATE INDEX t3_i ON t3(a);
COMMIT;
-}]
-
-file delete -force test1.db test1.db-journal
-file delete -force test2.db test2.db-journal
-
+} {
+ BEGIN;
+ DROP INDEX t3_i;
+ INCREMENTAL VACUUM;
+ INSERT INTO t3 VALUES('hello', 'world');
+ ROLLBACK;
+} {
+ INSERT INTO t3 VALUES('hello', 'world');
+}
+]
+# Compare the contents of databases $A and $B.
+#
proc compare_dbs {A B tname} {
set tbl_list [execsql {
SELECT tbl_name FROM sqlite_master WHERE type = 'table'
set ::str1 [string repeat abcdefghij 130]
set ::str2 [string repeat 1234567890 105]
+
+file delete -force test1.db test1.db-journal test2.db test2.db-journal
sqlite3 db1 test1.db
sqlite3 db2 test2.db
execsql { PRAGMA auto_vacuum = 'none' } db1
execsql $sql db2
compare_dbs db1 db2 incrvacuum-5.3.${tn}
- do_test incrvacuum-5.3.${tn}.integrity {
- execsql {
- PRAGMA integrity_check;
- } db2
+ do_test incrvacuum-5.3.${tn}.integrity1 {
+ execsql { PRAGMA integrity_check; } db1
+ } {ok}
+ do_test incrvacuum-5.3.${tn}.integrity2 {
+ execsql { PRAGMA integrity_check; } db2
} {ok}
incr tn
}
-
-
db1 close
db2 close
+#
+# End of test cases 5.3.*
+#---------------------------------------------------------------------
+# The following tests - incrvacuum-6.* - test running incremental
+# vacuum while another statement (a read) is being executed.
+#
+for {set jj 0} {$jj < 10} {incr jj} {
+ # Build some test data. Two tables are created in an empty
+ # database. tbl1 data is a contiguous block starting at page 5 (pages
+ # 3 and 4 are the table roots). tbl2 is a contiguous block starting
+ # right after tbl1.
+ #
+ # Then drop tbl1 so that when an incr vacuum is run the pages
+ # of tbl2 have to be moved to fill the gap.
+ #
+ do_test incrvacuum-6.${jj}.1 {
+ execsql {
+ DROP TABLE IF EXISTS tbl1;
+ DROP TABLE IF EXISTS tbl2;
+ INCREMENTAL VACUUM;
+ CREATE TABLE tbl1(a, b);
+ CREATE TABLE tbl2(a, b);
+ BEGIN;
+ }
+ for {set ii 0} {$ii < 1000} {incr ii} {
+ db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)}
+ }
+ execsql {
+ INSERT INTO tbl2 SELECT * FROM tbl1;
+ COMMIT;
+ DROP TABLE tbl1;
+ }
+ expr {[file size test.db] / 1024}
+ } {36}
+
+ # Run a linear scan query on tbl2. After reading ($jj*100) rows,
+ # run the incremental vacuum to shrink the database.
+ #
+ do_test incrvacuum-6.${jj}.2 {
+ set ::nRow 0
+ db eval {SELECT a FROM tbl2} {} {
+ if {$a == [expr $jj*100]} {
+ db eval {INCREMENTAL VACUUM}
+ }
+ incr ::nRow
+ }
+ list [expr {[file size test.db] / 1024}] $nRow
+ } {19 1000}
+}
#---------------------------------------------------------------------
-# TODO: The following tests - incrvacuum-6.* - test that rolling back
-# a transaction that contains an incremental vacuum operation
-# works Ok.
+# This test - incrvacuum-7.* - is to check that the database can be
+# written in the middle of an incremental vacuum.
#
+set ::iWrite 1
+while 1 {
+ do_test incrvacuum-7.${::iWrite}.1 {
+ execsql {
+ DROP TABLE IF EXISTS tbl1;
+ DROP TABLE IF EXISTS tbl2;
+ INCREMENTAL VACUUM;
+ CREATE TABLE tbl1(a, b);
+ CREATE TABLE tbl2(a, b);
+ BEGIN;
+ }
+ for {set ii 0} {$ii < 1000} {incr ii} {
+ db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)}
+ }
+ execsql {
+ INSERT INTO tbl2 SELECT * FROM tbl1;
+ COMMIT;
+ DROP TABLE tbl1;
+ }
+ expr {[file size test.db] / 1024}
+ } {36}
+
+ do_test incrvacuum-7.${::iWrite}.2 {
+ set ::nRow 0
+ db eval {INCREMENTAL VACUUM} {
+ incr ::nRow
+ if {$::nRow == $::iWrite} {
+ db eval {
+ CREATE TABLE tbl1(a, b);
+ INSERT INTO tbl1 VALUES('hello', 'world');
+ }
+ }
+ }
+ list [expr {[file size test.db] / 1024}]
+ } {20}
+
+ do_test incrvacuum-7.${::iWrite}.3 {
+ execsql {
+ SELECT * FROM tbl1;
+ }
+ } {hello world}
+
+ if {$::nRow == $::iWrite} break
+ incr ::iWrite
+}
finish_test