]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add extra test cases to pager1.test.
authordan <dan@noemail.net>
Wed, 16 Jun 2010 12:30:10 +0000 (12:30 +0000)
committerdan <dan@noemail.net>
Wed, 16 Jun 2010 12:30:10 +0000 (12:30 +0000)
FossilOrigin-Name: ad3209572d0e6afe5c8b52313e334509661045e2

manifest
manifest.uuid
test/pager1.test

index 08fb6c94894dc20363903887a3b84de4c9716ad1..bab89a2a9923f0ea6f507eef7abaa541a465589f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\smemory\sleak\sthat\scan\soccur\sin\sos_unix.c\sif\san\sIO\serror\soccurs\swithin\sthe\sxUnlock\smethod.
-D 2010-06-16T10:55:43
+C Add\sextra\stest\scases\sto\spager1.test.
+D 2010-06-16T12:30:11
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -533,7 +533,7 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
 F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
 F test/null.test a8b09b8ed87852742343b33441a9240022108993
 F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
-F test/pager1.test 4e75fc0ebe91d3f96d929098048dedbd67fdc16f
+F test/pager1.test 60dec408563461f9fbf04d4d301b1b4db23f7525
 F test/pagerfault.test 16e560bc4332d5b089b369d82ae4b65b8805b5eb
 F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
 F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
@@ -822,7 +822,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P efe44564983f115017658dd8a130226366d42bab
-R b69e2f7f93141c1bf41706b2581f08b9
+P 6c5c04eea1f0e8d61883ee8675c249fbf895dc01
+R d490808417f08b44a0b162eb48b4aec9
 U dan
-Z cce4c5d034089301ab79e2d9334d049f
+Z 861e5ff117287c588eecf635e107e097
index 0747075dbd37565703212ca17ff2dd6da56afa35..4d0fbc3ef3b075a759e15f2627a56be3a03c8f54 100644 (file)
@@ -1 +1 @@
-6c5c04eea1f0e8d61883ee8675c249fbf895dc01
\ No newline at end of file
+ad3209572d0e6afe5c8b52313e334509661045e2
\ No newline at end of file
index e99bf0ed7f2744d0d52ec87602d1081f66303a69..d0caaa9d41abcdc8385377f46dbab942f58a3f4f 100644 (file)
@@ -30,6 +30,14 @@ proc do_catchsql_test {testname sql result} {
   uplevel do_test $testname [list "catchsql {$sql}"] [list $result]
 }
 
+set a_string_counter 1
+proc a_string {n} {
+  global a_string_counter
+  incr a_string_counter
+  string range [string repeat "${a_string_counter}." $n] 1 $n
+}
+db func a_string a_string
+
 do_multiclient_test tn {
 
   # Create and populate a database table using connection [db]. Check 
@@ -166,6 +174,9 @@ do_multiclient_test tn {
   do_test pager1-$tn.28 { sql3 { SELECT * FROM t1 } } {21 one 22 two 23 three}
 }
 
+#-------------------------------------------------------------------------
+# Savepoint related test cases.
+# 
 do_test pager1-3.1 {
   faultsim_delete_and_reopen
   execsql {
@@ -199,5 +210,103 @@ 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 } {}
 
+#-------------------------------------------------------------------------
+# Hot journal rollback related test cases.
+#
+# pager1.4.1.*: Test that the pager module deletes very small invalid
+#               journal files.
+#
+# pager1.4.2.*: Test that if the master journal pointer at the end of a
+#               hot-journal file appears to be corrupt (checksum does not
+#               compute) the associated journal is rolled back (and no
+#               xAccess() call to check for the presence of any master 
+#               journal file is made).
+# 
+do_test pager1.4.1.1 {
+  faultsim_delete_and_reopen
+  execsql { 
+    CREATE TABLE x(y, z);
+    INSERT INTO x VALUES(1, 2);
+  }
+  set fd [open test.db-journal w]
+  puts -nonewline $fd "helloworld"
+  close $fd
+  file exists test.db-journal
+} {1}
+do_test pager1.4.1.2 { execsql { SELECT * FROM x } } {1 2}
+do_test pager1.4.1.3 { file exists test.db-journal } {0}
+
+# Set up a [testvfs] to snapshot the file-system just before SQLite
+# deletes the master-journal to commit a multi-file transaction.
+#
+# In subsequent test cases, invoking [faultsim_restore_and_reopen] sets
+# up the file system to contain two databases, two hot-journal files and
+# a master-journal.
+#
+do_test pager1.4.2.1 {
+  testvfs tstvfs -default 1
+  tstvfs filter xDelete
+  tstvfs script xDeleteCallback
+  proc xDeleteCallback {method file args} {
+    set file [file tail $file]
+    if { [string match *mj* $file] } { faultsim_save }
+  }
+  faultsim_delete_and_reopen
+  db func a_string a_string
+  execsql {
+    ATTACH 'test.db2' AS aux;
+    PRAGMA journal_mode = DELETE;
+    PRAGMA main.cache_size = 10;
+    PRAGMA aux.cache_size = 10;
+    CREATE TABLE t1(a UNIQUE, b UNIQUE);
+    CREATE TABLE aux.t2(a UNIQUE, b UNIQUE);
+    INSERT INTO t1 VALUES(a_string(200), a_string(300));
+    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
+    INSERT INTO t2 SELECT * FROM t1;
+    BEGIN;
+      INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;
+      INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;
+      INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;
+      INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;
+      REPLACE INTO t2 SELECT * FROM t1;
+    COMMIT;
+  }
+  db close
+  tstvfs delete
+} {}
+do_test pager1.4.2.2 {
+  faultsim_restore_and_reopen
+  execsql {
+    SELECT count(*) FROM t1;
+    PRAGMA integrity_check;
+  }
+} {4 ok}
+do_test pager1.4.2.3 {
+  faultsim_restore_and_reopen
+  foreach f [glob test.db-mj*] { file delete -force $f }
+  execsql {
+    SELECT count(*) FROM t1;
+    PRAGMA integrity_check;
+  }
+} {64 ok}
+do_test pager1.4.2.4 {
+  faultsim_restore_and_reopen
+  hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456
+  execsql {
+    SELECT count(*) FROM t1;
+    PRAGMA integrity_check;
+  }
+} {4 ok}
+do_test pager1.4.2.5 {
+  faultsim_restore_and_reopen
+  hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456
+  foreach f [glob test.db-mj*] { file delete -force $f }
+  execsql {
+    SELECT count(*) FROM t1;
+    PRAGMA integrity_check;
+  }
+} {4 ok}
+
 finish_test