]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Avoid running some particularly time-consuming tests as part of veryquick.test.
authordan <dan@noemail.net>
Thu, 4 Feb 2016 17:31:03 +0000 (17:31 +0000)
committerdan <dan@noemail.net>
Thu, 4 Feb 2016 17:31:03 +0000 (17:31 +0000)
FossilOrigin-Name: f465944b75a800ddc6920229ad32c2f39ff91e19

18 files changed:
manifest
manifest.uuid
test/fuzzer1.test
test/fuzzer2.test [new file with mode: 0644]
test/mmap1.test
test/mmap4.test [new file with mode: 0644]
test/permutations.test
test/savepointfault.test [moved from test/savepoint3.test with 94% similarity]
test/sort.test
test/sort2.test
test/sort3.test
test/tester.tcl
test/wal.test
test/wal3.test
test/walcksum.test
test/walprotocol.test [new file with mode: 0644]
test/walslow.test
test/wherefault.test [moved from test/where8m.test with 84% similarity]

index 194c646e6b20656c86ad7b0c920b765a11ae6535..7b935898baf72e436a7d07bab6307f8c411a9e37 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sunnecessary\ssets\sof\sdb->mallocFailed.
-D 2016-02-04T11:48:00.219
+C Avoid\srunning\ssome\sparticularly\stime-consuming\stests\sas\spart\sof\sveryquick.test.
+D 2016-02-04T17:31:03.368
 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 72b7858f02017611c3ac1ddc965251017fed0845
@@ -769,7 +769,8 @@ F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664
 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973
 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
 F test/fuzzdata4.db 1882f0055fb63214d8407ddc7aca9b0b1c59af21
-F test/fuzzer1.test d4c52aaf3ef923da293a2653cfab33d02f718a36
+F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
+F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536
 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98
 F test/hexlit.test d7b0a5f41123df1e43985b91b8b2e70f95282d21
@@ -897,9 +898,10 @@ F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test edd0b63e2ee29a256900b0514f6fff27e19e9bb2
 F test/misc8.test fc2754d38892f7dac30c22db3616c2764f117d66
 F test/misuse.test 3c34719944ba045cc6c188a4852ba04680728912
-F test/mmap1.test 1bfd611b9841eafb44f7d83c0788e146d84a33c9
+F test/mmap1.test 44a5ff1c1bcc7dcf2de50227d1f997e75a8ef1ae
 F test/mmap2.test 9d6dd9ddb4ad2379f29cc78f38ce1e63ed418022
 F test/mmap3.test c92273e16eb8d23c1d55c9815b446bb72ef0512e
+F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93
 F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3
 F test/multiplex.test efd015ca0b5b4a57dc9535b8feb1273eebeadb60
 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
@@ -942,7 +944,7 @@ F test/parser1.test 222b5cbf3e2e659fec1bf7d723488c8b9c94f1d0
 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
 F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
-F test/permutations.test 4ea119731c62d2f7d0aa86dd5b184cbb61ca411b
+F test/permutations.test 382a43c49f49bafe6fddffe904ea33d6bb3ff33e
 F test/pragma.test 507ac7ef2ea5682241ea0ef041799ca70bb5e0bf
 F test/pragma2.test a9400a7289605280576098b97f5cde3f204075c0
 F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c
@@ -974,11 +976,11 @@ F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798
 F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09
 F test/savepoint.test c671fdbd34cd3bfe1518a777526ada595180cf8d
 F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
-F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec
 F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
 F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd
 F test/savepoint6.test f41279c5e137139fa5c21485773332c7adb98cd7
 F test/savepoint7.test db3db281486c925095f305aad09fe806e5188ff3
+F test/savepointfault.test f044eac64b59f09746c7020ee261734de82bf9b2 w test/savepoint3.test
 F test/scanstatus.test 5253c219e331318a437f436268e0e82345700285
 F test/schema.test 8f7999be894260f151adf15c2c7540f1c6d6a481
 F test/schema2.test 906408621ea881fdb496d878b1822572a34e32c5
@@ -1034,9 +1036,9 @@ F test/snapshot.test efc6b4edc5d571161835f9dd8552e181ad1f0ac2
 F test/snapshot_fault.test 25973aeb1b86a280800e0bcf1eb5ce70e9ef57ab
 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f
 F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087
-F test/sort.test 3f492e5b7be1d3f756728d2ff6edf4f6091e84cb
-F test/sort2.test 37afbc03f5559f2eb0f18940b55d38dfbb5172ac
-F test/sort3.test 6178ade30810ac9166fcdf14b7065e49c0f534e2
+F test/sort.test c2adc635c2564241fefec0b3a68391ef6868fd3b
+F test/sort2.test cc23b7c19d684657559e8a55b02f7fcee03851d0
+F test/sort3.test 1d831e95076b92985754a122e92ebc23bdf6f712
 F test/sort4.test 5c34d9623a4ae5921d956dfa2b70e77ed0fc6e5c
 F test/sort5.test a448240a42b49239edc00f85d6d7ac7a1b261e1f
 F test/sortfault.test d4ccf606a0c77498e2beb542764fd9394acb4d66
@@ -1076,7 +1078,7 @@ F test/tclsqlite.test 7fb866443c7deceed22b63948ccd6f76b52ad054
 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c
 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
-F test/tester.tcl af4749cf4abf04291710c5e73f40bc8f411bae86
+F test/tester.tcl 462376b478c1429030911b4cb7c8c517ef1fbd9b
 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -1294,9 +1296,9 @@ F test/vtabI.test 751b07636700dbdea328e4265b6077ccd6811a3f
 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
 F test/vtab_shared.test ea8778d5b0df200adef2ca7c00c3c37d4375f772
-F test/wal.test 65bfc68f3f09dcbc62cee9f794e560428d96cec7
+F test/wal.test 0148c8b3421a25fdb4d9c160e84a681d0646371b
 F test/wal2.test 1f841d2048080d32f552942e333fd99ce541dada
-F test/wal3.test b1d425f68a1f61d12563f0fa1ee6fca7d5afabf4
+F test/wal3.test 5dd734147f1f8f958c5261a1f2775d346d7013ce
 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
 F test/wal5.test 88b5d9a6a3d1532497ee9f4296f010d66f07e33c
 F test/wal6.test 4421cd5a2fa99d29cc91ef12fb23bed171ed3a4c
@@ -1308,7 +1310,7 @@ F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe
 F test/walbak.test b9f68e39646375c2b877be906babcc15d38b4877
 F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434
 F test/walblock.test be48f3a75eff0b4456209f26b3ce186c2015497d
-F test/walcksum.test 9afeb96240296c08c72fc524d199c912cfe34daa
+F test/walcksum.test bb234a1bb42248b3515d992b719708015c384278
 F test/walcrash.test 21038858cc552077b0522f50b0fa87e38139306a
 F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36
 F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af
@@ -1318,9 +1320,10 @@ F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c
 F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
 F test/waloverwrite.test a0d2ae0783187374c1e6a9571e0916152977cb81
 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
+F test/walprotocol.test 059cb75484a1ecf6357a2c1b3324b8156749221e
 F test/walro.test 34422d1d95aaff0388f0791ec20edb34e2a3ed57
 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
-F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a
+F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
 F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e
 F test/where.test 9902a3d84e9bc80357a2c54ed0e76c0d6d04a867
 F test/where2.test af78c55589cbc82d793449493adba0dc3d659f23
@@ -1330,7 +1333,6 @@ F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b
 F test/where7.test f520bcec2c3d12dc4615623b06b2aec7c2d67e94
 F test/where8.test 98eedca0d375fb400b8377269c4b4686582dfb45
-F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739
 F test/where9.test 729c3ba9b47e8f9f1aab96bae7dad2a524f1d1a2
 F test/whereA.test 4d253178d135ec46d1671e440cd8f2b916aa6e6b
 F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5
@@ -1343,6 +1345,7 @@ F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2
 F test/whereI.test 1d89199697919d4930be05a71e7fe620f114e622
 F test/whereJ.test 55a3221706a7ab706293f17cc8f96da563bf0767
 F test/whereK.test f8e3cf26a8513ecc7f514f54df9f0572c046c42b
+F test/wherefault.test 1374c3aa198388925246475f84ad4cd5f9528864 w test/where8m.test
 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
 F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c
 F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c
@@ -1423,7 +1426,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 634d008c34bd237fc9cfb88dc291394fc5d31efa
-R 0723d194047e6276e554e1a515e620e8
-U drh
-Z 4a87610dafa418a613875dd84903b4d5
+P b787165b25a240fd5b4a5c7f73b395f30213a1d7
+R 2d9511ba502b30b0a28170783af34756
+U dan
+Z 9311e6c3b97d9e579dd5eb1512f82842
index 8a6b51b9d7277e59a1981c50593cb8a665b5bc37..81e89adc73d518f015c9b02a95f6c77febc1b4d0 100644 (file)
@@ -1 +1 @@
-b787165b25a240fd5b4a5c7f73b395f30213a1d7
\ No newline at end of file
+f465944b75a800ddc6920229ad32c2f39ff91e19
\ No newline at end of file
index 4ee573080762edbe2f658c7dd19a6a793ef7ecdf..5e361e9df0e220875816ae5a532676bcccfeb629 100644 (file)
@@ -23,7 +23,6 @@ ifcapable !vtab {
 }
 
 set ::testprefix fuzzer1
-
 load_static_extension db fuzzer
 
 # Check configuration errors.
@@ -1648,51 +1647,6 @@ do_catchsql_test 5.5.4 {
   CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');
 } {1 {fuzzer: ruleset must be between 0 and 2147483647}}
 
-#-------------------------------------------------------------------------
-# This test uses a fuzzer table with many rules. There is one rule to
-# map each possible two character string, where characters are lower-case
-# letters used in the English language, to all other possible two character
-# strings. In total, (26^4)-(26^2) mappings (the subtracted term represents
-# the no-op mappings discarded automatically by the fuzzer).
-#
-#
-do_execsql_test 6.1.1 {
-  DROP TABLE IF EXISTS x1;
-  DROP TABLE IF EXISTS x1_rules;
-  CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
-}
-puts "This test is slow - perhaps around 7 seconds on an average pc"
-do_test 6.1.2 {
-  set LETTERS {a b c d e f g h i j k l m n o p q r s t u v w x y z}
-  set cost 1
-  db transaction {
-    foreach c1 $LETTERS { 
-      foreach c2 $LETTERS { 
-        foreach c3 $LETTERS { 
-          foreach c4 $LETTERS { 
-            db eval {INSERT INTO x1_rules VALUES(0, $c1||$c2, $c3||$c4, $cost)}
-            set cost [expr ($cost%1000) + 1]
-          }
-        }
-      }
-    }
-    db eval {UPDATE x1_rules SET cost = 20 WHERE cost<20 AND cFrom!='xx'}
-  }
-} {}
-
-do_execsql_test 6.2 {
-  SELECT count(*) FROM x1_rules WHERE cTo!=cFrom;
-} [expr 26*26*26*26 - 26*26]
-
-do_execsql_test 6.2.1 {
-  CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
-  SELECT word FROM x1 WHERE word MATCH 'xx' LIMIT 10;
-} {xx hw hx hy hz ia ib ic id ie}
-do_execsql_test 6.2.2 {
-  SELECT cTo FROM x1_rules WHERE cFrom='xx' 
-  ORDER BY cost asc, rowid asc LIMIT 9;
-} {hw hx hy hz ia ib ic id ie}
-
 #-------------------------------------------------------------------------
 # Test using different types of quotes with CREATE VIRTUAL TABLE 
 # arguments.
diff --git a/test/fuzzer2.test b/test/fuzzer2.test
new file mode 100644 (file)
index 0000000..44ee9e3
--- /dev/null
@@ -0,0 +1,72 @@
+# 2016 February 4
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# The focus of the tests is the word-fuzzer virtual table. The tests
+# in this file are slower than those in fuzzer1.test. So this file does
+# not run as part of veryquick.test etc.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+  finish_test
+  return
+}
+
+set ::testprefix fuzzer2
+load_static_extension db fuzzer
+
+#-------------------------------------------------------------------------
+# This test uses a fuzzer table with many rules. There is one rule to
+# map each possible two character string, where characters are lower-case
+# letters used in the English language, to all other possible two character
+# strings. In total, (26^4)-(26^2) mappings (the subtracted term represents
+# the no-op mappings discarded automatically by the fuzzer).
+#
+#
+do_execsql_test 1.1.1 {
+  DROP TABLE IF EXISTS x1;
+  DROP TABLE IF EXISTS x1_rules;
+  CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);
+}
+puts "This test is slow - perhaps around 7 seconds on an average pc"
+do_test 1.1.2 {
+  set LETTERS {a b c d e f g h i j k l m n o p q r s t u v w x y z}
+  set cost 1
+  db transaction {
+    foreach c1 $LETTERS { 
+      foreach c2 $LETTERS { 
+        foreach c3 $LETTERS { 
+          foreach c4 $LETTERS { 
+            db eval {INSERT INTO x1_rules VALUES(0, $c1||$c2, $c3||$c4, $cost)}
+            set cost [expr ($cost%1000) + 1]
+          }
+        }
+      }
+    }
+    db eval {UPDATE x1_rules SET cost = 20 WHERE cost<20 AND cFrom!='xx'}
+  }
+} {}
+
+do_execsql_test 1.2 {
+  SELECT count(*) FROM x1_rules WHERE cTo!=cFrom;
+} [expr 26*26*26*26 - 26*26]
+
+do_execsql_test 1.2.1 {
+  CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);
+  SELECT word FROM x1 WHERE word MATCH 'xx' LIMIT 10;
+} {xx hw hx hy hz ia ib ic id ie}
+do_execsql_test 1.2.2 {
+  SELECT cTo FROM x1_rules WHERE cFrom='xx' 
+  ORDER BY cost asc, rowid asc LIMIT 9;
+} {hw hx hy hz ia ib ic id ie}
+
+finish_test
index 18aec9f8fa638e6e98776e83b6b6debea74e6a49..199a0587546c50463ab8f42435f2d093abed1040 100644 (file)
@@ -28,6 +28,10 @@ proc nRead {db} {
   return $stats(read)
 }
 
+# Return a Tcl script that registers a user-defined scalar function 
+# named rblob() with database handle $dbname. The function returns a
+# sequence of pseudo-random blobs based on seed value $seed.
+#
 proc register_rblob_code {dbname seed} {
   return [subst -nocommands {
     set ::rcnt $seed
@@ -40,6 +44,7 @@ proc register_rblob_code {dbname seed} {
   }]
 }
 
+
 # For cases 1.1 and 1.4, the number of pages read using xRead() is 4 on
 # unix and 9 on windows. The difference is that windows only ever maps
 # an integer number of OS pages (i.e. creates mappings that are a multiple
@@ -269,65 +274,5 @@ do_test 5.5 {
   sqlite3_finalize $::STMT
 } SQLITE_OK
 
-#-------------------------------------------------------------------------
-# Test various mmap_size settings.
-#
-foreach {tn1 mmap1 mmap2} {
-     1 6144       167773
-     2 18432      140399
-     3 43008      401302
-     4 92160      253899
-     5 190464          2
-     6 387072     752431
-     7 780288     291143
-     8 1566720    594306
-     9 3139584    829137
-     10 6285312   793963
-     11 12576768 1015590
-} {
-  do_multiclient_test tn {
-    sql1 {
-      CREATE TABLE t1(a PRIMARY KEY);
-      CREATE TABLE t2(x);
-      INSERT INTO t2 VALUES('');
-    }
-
-    code1 [register_rblob_code db  0]
-    code2 [register_rblob_code db2 444]
-
-    sql1 "PRAGMA mmap_size = $mmap1"
-    sql2 "PRAGMA mmap_size = $mmap2"
-
-    do_test $tn1.$tn {
-      for {set i 1} {$i <= 100} {incr i} {
-        if {$i % 2} {
-          set c1 sql1
-            set c2 sql2
-        } else {
-          set c1 sql2
-            set c2 sql1
-        }
-
-        $c1 {
-          INSERT INTO t1 VALUES( rblob(5000) );
-          UPDATE t2 SET x = (SELECT md5sum(a) FROM t1);
-        }
-
-        set res [$c2 {
-            SELECT count(*) FROM t1;
-            SELECT x == (SELECT md5sum(a) FROM t1) FROM t2;
-            PRAGMA integrity_check;
-        }]
-        if {$res != [list $i 1 ok]} {
-          do_test $tn1.$tn.$i {
-            set ::res
-          } [list $i 1 ok]
-        }
-      }
-      set res 1
-    } {1}
-  }
-}
-
 
 finish_test
diff --git a/test/mmap4.test b/test/mmap4.test
new file mode 100644 (file)
index 0000000..9701548
--- /dev/null
@@ -0,0 +1,104 @@
+# 2016 February 04
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file tests the effect of the mmap() or mremap() system calls 
+# returning an error on the library. 
+#
+# If either mmap() or mremap() fails, SQLite should log an error 
+# message, then continue accessing the database using read() and 
+# write() exclusively.
+# 
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !mmap {
+  finish_test
+  return
+}
+source $testdir/lock_common.tcl
+set testprefix mmap4
+
+# Return a Tcl script that registers a user-defined scalar function 
+# named rblob() with database handle $dbname. The function returns a
+# sequence of pseudo-random blobs based on seed value $seed.
+#
+proc register_rblob_code {dbname seed} {
+  return [subst -nocommands {
+    set ::rcnt $seed
+    proc rblob {n} {
+      set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]
+      set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]]
+      string range [string repeat [set str] [expr [set n]/4]] 1 [set n]
+    }
+    $dbname func rblob rblob
+  }]
+}
+
+#-------------------------------------------------------------------------
+# Test various mmap_size settings.
+#
+foreach {tn1 mmap1 mmap2} {
+     1 6144       167773
+     2 18432      140399
+     3 43008      401302
+     4 92160      253899
+     5 190464          2
+     6 387072     752431
+     7 780288     291143
+     8 1566720    594306
+     9 3139584    829137
+     10 6285312   793963
+     11 12576768 1015590
+} {
+  do_multiclient_test tn {
+    sql1 {
+      CREATE TABLE t1(a PRIMARY KEY);
+      CREATE TABLE t2(x);
+      INSERT INTO t2 VALUES('');
+    }
+
+    code1 [register_rblob_code db  0]
+    code2 [register_rblob_code db2 444]
+
+    sql1 "PRAGMA mmap_size = $mmap1"
+    sql2 "PRAGMA mmap_size = $mmap2"
+
+    do_test $tn1.$tn {
+      for {set i 1} {$i <= 100} {incr i} {
+        if {$i % 2} {
+          set c1 sql1
+            set c2 sql2
+        } else {
+          set c1 sql2
+            set c2 sql1
+        }
+
+        $c1 {
+          INSERT INTO t1 VALUES( rblob(5000) );
+          UPDATE t2 SET x = (SELECT md5sum(a) FROM t1);
+        }
+
+        set res [$c2 {
+            SELECT count(*) FROM t1;
+            SELECT x == (SELECT md5sum(a) FROM t1) FROM t2;
+            PRAGMA integrity_check;
+        }]
+        if {$res != [list $i 1 ok]} {
+          do_test $tn1.$tn.$i {
+            set ::res
+          } [list $i 1 ok]
+        }
+      }
+      set res 1
+    } {1}
+  }
+}
+
+finish_test
index 28bbd3017e9e8964e2c3bad2e0e792baf709ffe3..c0998890674a579e8570feee168b6e055a4de1f6 100644 (file)
@@ -113,7 +113,14 @@ set allquicktests [test_set $alltests -exclude {
   vtab_err.test walslow.test walcrash.test walcrash3.test
   walthread.test rtree3.test indexfault.test securedel2.test
   sort3.test sort4.test fts4growth.test fts4growth2.test
-  bigsort.test rbu.test
+  bigsort.test rbu.test walprotocol.test mmap4.test fuzzer2.test
+  walcrash2.test e_fkey.test backup.test
+
+  fts4merge.test fts4merge2.test fts4merge4.test fts4check.test
+  fts3cov.test fts3snippet.test fts3corrupt2.test fts3an.test
+  fts3defer.test fts4langid.test fts3sort.test fts5unicode.test
+
+  rtree4.test
 }]
 if {[info exists ::env(QUICKTEST_INCLUDE)]} {
   set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
@@ -150,7 +157,7 @@ test_suite "veryquick" -prefix "" -description {
   This test suite is the same as the "quick" tests, except that some files
   that test malloc and IO errors are omitted.
 } -files [
-  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile*
+  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err*
 ]
 
 test_suite "extraquick" -prefix "" -description {
@@ -158,7 +165,7 @@ test_suite "extraquick" -prefix "" -description {
   This test suite is the same as the "veryquick" tests, except that
   slower tests are omitted.
 } -files [
-  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* \
+  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
      wal3.test fts4merge* sort2.test mmap1.test walcrash* \
      percentile.test where8m.test walcksum.test savepoint3.test \
      fuzzer1.test fuzzer3.test fts3expr3.test
@@ -176,7 +183,7 @@ test_suite "valgrind" -prefix "" -description {
   Run the "veryquick" test suite with a couple of multi-process tests (that
   fail under valgrind) omitted.
 } -files [
-  test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test \
+  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err* wal.test \
               shell*.test crash8.test atof1.test selectG.test \
               tkt-fc62af4523.test numindex1.test
 ] -initialize {
@@ -189,7 +196,8 @@ test_suite "valgrind-nolookaside" -prefix "" -description {
   Run the "veryquick" test suite with a couple of multi-process tests (that
   fail under valgrind) omitted.
 } -files [
-  test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test atof1.test
+  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err* \
+      wal.test atof1.test
 ] -initialize {
   set ::G(valgrind) 1
   catch {db close}
@@ -266,7 +274,7 @@ test_suite "nofaultsim" -prefix "" -description {
   This test suite is the same as the "quick" tests, except that some files
   that test malloc and IO errors are omitted.
 } -files [
-  test_set $allquicktests -exclude *malloc* *ioerr* *fault*
+  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err*
 ] -initialize {
   catch {db close}
   sqlite3_shutdown
similarity index 94%
rename from test/savepoint3.test
rename to test/savepointfault.test
index 0dcb0aceba1f0b621e385879ff359415e26b2ad1..0329f8caa27839f17d97ad58634a26a54f537159 100644 (file)
@@ -9,14 +9,15 @@
 #
 #***********************************************************************
 #
-# $Id: savepoint3.test,v 1.5 2009/06/05 17:09:12 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
 source $testdir/malloc_common.tcl
 
-do_malloc_test savepoint3-1 -sqlprep {
+set testprefix savepointfault
+
+do_malloc_test 1 -sqlprep {
   CREATE TABLE t1(a, b, c);
   INSERT INTO t1 VALUES(1, 2, 3);
 } -sqlbody {
@@ -28,7 +29,7 @@ do_malloc_test savepoint3-1 -sqlprep {
   RELEASE one;
 }
 
-do_malloc_test savepoint3-2 -sqlprep {
+do_malloc_test 2 -sqlprep {
   PRAGMA cache_size = 10;
   CREATE TABLE t1(a, b, c);
   INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));
@@ -59,7 +60,7 @@ do_malloc_test savepoint3-2 -sqlprep {
   RELEASE one;
 }
 
-do_ioerr_test savepoint3.3 -sqlprep {
+do_ioerr_test 3 -sqlprep {
   CREATE TABLE t1(a, b, c);
   INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));
   INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));
@@ -79,7 +80,7 @@ do_ioerr_test savepoint3.3 -sqlprep {
 # The following test does a really big savepoint rollback. One involving
 # more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()
 # operation in pagerPlaybackSavepoint() to fail.
-#do_malloc_test savepoint3-4 -sqlprep {
+#do_malloc_test 4 -sqlprep {
 #  BEGIN;
 #    CREATE TABLE t1(a, b);
 #    CREATE INDEX i1 ON t1(a);
@@ -107,7 +108,7 @@ do_ioerr_test savepoint3.3 -sqlprep {
 
 # Cause a specific malloc in savepoint rollback code to fail.
 #
-do_malloc_test savepoint3-4 -start 7 -sqlprep {
+do_malloc_test 4 -start 7 -sqlprep {
   PRAGMA auto_vacuum = incremental;
   PRAGMA cache_size = 1000;
 
index 21b11d6c8818e239bee4f071290a1301bb995675..d73ecea4802d9a0dc82184bfa4d135cefa040c63 100644 (file)
@@ -491,52 +491,6 @@ do_execsql_test sort-13.3 {
   SELECT a, b FROM t10 ORDER BY a;
 } [db eval {SELECT a, b FROM t10 ORDER BY a, b}]
 
-#-------------------------------------------------------------------------
-# Sort some large ( > 4KiB) records.
-#
-proc cksum {x} {
-  set i1 1
-  set i2 2
-  binary scan $x c* L
-  foreach {a b} $L {
-    set i1 [expr (($i2<<3) + $a) & 0x7FFFFFFF]
-    set i2 [expr (($i1<<3) + $b) & 0x7FFFFFFF]
-  }
-  list $i1 $i2
-}
-db func cksum cksum
-
-do_execsql_test sort-14.0 {
-  PRAGMA cache_size = 5;
-  CREATE TABLE t11(a, b);
-  INSERT INTO t11 VALUES(randomblob(5000), NULL);
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --2
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --3
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --4
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --5
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --6
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --7
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --8
-  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --9
-  UPDATE t11 SET b = cksum(a);
-}
-
-foreach {tn mmap_limit} {
-  1 0
-  2 1000000
-} {
-  do_test sort-14.$tn {
-    sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
-    set prev ""
-    db eval { SELECT * FROM t11 ORDER BY b } {
-      if {$b != [cksum $a]} {error "checksum failed"}
-      if {[string compare $b $prev] < 0} {error "sort failed"}
-      set prev $b
-    }
-    set {} {}
-  } {}
-}
-
 #-------------------------------------------------------------------------
 #
 foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap softheaplimit} {
index 890025a5d0c5cf4692e6cc70f7cbcfdad8fff285..f686654d53a594128e7135d549432b82da35c1ac 100644 (file)
@@ -31,7 +31,6 @@ foreach {tn script} {
     catch { db eval {PRAGMA threads=7} }
   }
 } {
-
   eval $script
 
   do_execsql_test $tn.1 {
@@ -67,17 +66,22 @@ foreach {tn script} {
   
   do_execsql_test $tn.2.4 { PRAGMA integrity_check } {ok}
   
-  do_execsql_test $tn.3 {
-    PRAGMA cache_size = 5;
-    WITH r(x,y) AS (
-      SELECT 1, randomblob(100)
-      UNION ALL
-      SELECT x+1, randomblob(100) FROM r
-      LIMIT 1000000
-    )
-    SELECT count(x), length(y) FROM r GROUP BY (x%5)
-  } {
-    200000 100 200000 100 200000 100 200000 100 200000 100
+  # Because it uses so much data, this test can take 12-13 seconds even on
+  # a modern workstation. So it is omitted from "veryquick" and other
+  # permutations.test tests.
+  if {[isquick]==0} {
+    do_execsql_test $tn.3 {
+      PRAGMA cache_size = 5;
+      WITH r(x,y) AS (
+          SELECT 1, randomblob(100)
+          UNION ALL
+          SELECT x+1, randomblob(100) FROM r
+          LIMIT 1000000
+          )
+        SELECT count(x), length(y) FROM r GROUP BY (x%5)
+    } {
+      200000 100 200000 100 200000 100 200000 100 200000 100
+    }
   }
 }
 
index 80d8bbca3f0e0d0717d4ce03305a2ec722ac1065..3aa6512a4b964d8647d2bca800099075bcbc46df 100644 (file)
@@ -19,6 +19,53 @@ set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 set testprefix sort3
 
+#-------------------------------------------------------------------------
+# Sort some large ( > 4KiB) records.
+#
+proc cksum {x} {
+  set i1 1
+  set i2 2
+  binary scan $x c* L
+  foreach {a b} $L {
+    set i1 [expr (($i2<<3) + $a) & 0x7FFFFFFF]
+    set i2 [expr (($i1<<3) + $b) & 0x7FFFFFFF]
+  }
+  list $i1 $i2
+}
+db func cksum cksum
+
+do_execsql_test 1.0 {
+  PRAGMA cache_size = 5;
+  CREATE TABLE t11(a, b);
+  INSERT INTO t11 VALUES(randomblob(5000), NULL);
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --2
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --3
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --4
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --5
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --6
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --7
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --8
+  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --9
+  UPDATE t11 SET b = cksum(a);
+}
+
+foreach {tn mmap_limit} {
+  1 0
+  2 1000000
+} {
+  do_test 1.$tn {
+    sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
+    set prev ""
+    db eval { SELECT * FROM t11 ORDER BY b } {
+      if {$b != [cksum $a]} {error "checksum failed"}
+      if {[string compare $b $prev] < 0} {error "sort failed"}
+      set prev $b
+    }
+    set {} {}
+  } {}
+}
+
+
 # Sort roughly 20MB of data. Once with a mmap limit of 5MB and once without.
 #
 foreach {itest limit} {
@@ -26,7 +73,7 @@ foreach {itest limit} {
   2 0x7FFFFFFF
 } {
   sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $limit
-  do_execsql_test 1.$itest {
+  do_execsql_test 2.$itest {
     WITH r(x,y) AS (
         SELECT 1, randomblob(1000)
         UNION ALL
@@ -46,7 +93,7 @@ foreach {itest limit} {
 # Sort more than 2GB of data. At one point this was causing a problem.
 # This test might take one minute or more to run.
 #
-do_execsql_test 2 {
+do_execsql_test 3 {
   PRAGMA cache_size = 20000;
   WITH r(x,y) AS (
     SELECT 1, randomblob(1000)
index 426808ea9051cb4593538597898dc3d8bcac5dd8..dc532c97fa370be598f920bdda9c56a92e8573d9 100644 (file)
@@ -1905,6 +1905,12 @@ proc presql {} {
   set presql
 }
 
+proc isquick {} {
+  set ret 0
+  catch {set ret $::G(isquick)}
+  set ret
+}
+
 #-------------------------------------------------------------------------
 #
 proc slave_test_script {script} {
index abd3a3ce49b822d5bd8b3aa46771c4523bed4dcf..92b65e66bad5f5be1caa82f3d6f5bc53a4403340 100644 (file)
@@ -824,91 +824,6 @@ do_test wal-12.6 {
 db2 close
 db close
 
-#-------------------------------------------------------------------------
-# Test large log summaries.
-#
-# In this case "large" usually means a log file that requires a wal-index
-# mapping larger than 64KB (the default initial allocation). A 64KB wal-index
-# is large enough for a log file that contains approximately 13100 frames.
-# So the following tests create logs containing at least this many frames.
-#
-# wal-13.1.*: This test case creates a very large log file within the
-#             file-system (around 200MB). The log file does not contain
-#             any valid frames. Test that the database file can still be
-#             opened and queried, and that the invalid log file causes no 
-#             problems.
-#
-# wal-13.2.*: Test that a process may create a large log file and query
-#             the database (including the log file that it itself created).
-#
-# wal-13.3.*: Test that if a very large log file is created, and then a
-#             second connection is opened on the database file, it is possible
-#             to query the database (and the very large log) using the
-#             second connection.
-#
-# wal-13.4.*: Same test as wal-13.3.*. Except in this case the second
-#             connection is opened by an external process.
-#
-do_test wal-13.1.1 {
-  list [file exists test.db] [file exists test.db-wal]
-} {1 0}
-do_test wal-13.1.2 {
-  set fd [open test.db-wal w]
-  seek $fd [expr 200*1024*1024]
-  puts $fd ""
-  close $fd
-  sqlite3 db test.db
-  execsql { SELECT * FROM t2 }
-} {B 2}
-do_test wal-13.1.3 {
-  db close
-  file exists test.db-wal
-} {0}
-
-do_test wal-13.2.1 {
-  sqlite3 db test.db
-  execsql { SELECT count(*) FROM t2 }
-} {1}
-do_test wal-13.2.2 {
-  db function blob blob
-  for {set i 0} {$i < 16} {incr i} {
-    execsql { INSERT INTO t2 SELECT blob(400), blob(400) FROM t2 }
-  }
-  execsql { SELECT count(*) FROM t2 }
-} [expr int(pow(2, 16))]
-do_test wal-13.2.3 {
-  expr [file size test.db-wal] > [wal_file_size 33000 1024]
-} 1
-
-do_multiclient_test tn {
-  incr tn 2
-
-  do_test wal-13.$tn.0 {
-    sql1 {
-      PRAGMA journal_mode = WAL;
-      CREATE TABLE t1(x);
-      INSERT INTO t1 SELECT randomblob(800);
-    }
-    sql1 { SELECT count(*) FROM t1 }
-  } {1}
-
-  for {set ii 1} {$ii<16} {incr ii} {
-    do_test wal-13.$tn.$ii.a {
-      sql2 { INSERT INTO t1 SELECT randomblob(800) FROM t1 }
-      sql2 { SELECT count(*) FROM t1 }
-    } [expr (1<<$ii)]
-    do_test wal-13.$tn.$ii.b {
-      sql1 { SELECT count(*) FROM t1 }
-    } [expr (1<<$ii)]
-    do_test wal-13.$tn.$ii.c {
-      sql1 { SELECT count(*) FROM t1 }
-    } [expr (1<<$ii)]
-    do_test wal-13.$tn.$ii.d {
-      sql1 { PRAGMA integrity_check }
-    } {ok}
-  }
-}
-
 #-------------------------------------------------------------------------
 # Check a fun corruption case has been fixed.
 #
index 9ee8a9945815ffff2ca6bac6d77892c11128deb9..da3d31877395fb1546bac9e74fa2d43b01aa94ec 100644 (file)
@@ -61,7 +61,7 @@ do_test wal3-1.0 {
     PRAGMA cache_size = 10;
   }
   set x [wal_frame_count test.db-wal 1024]
-  if {$::G(perm:name)=="memsubsys1"} {
+  if {[permutation]=="memsubsys1"} {
     if {$x==4251 || $x==4290} {set x 4056}
   }
   set x
@@ -238,67 +238,6 @@ foreach {tn syncmode synccount} {
   T delete
 }
 
-#-------------------------------------------------------------------------
-# When recovering the contents of a WAL file, a process obtains the WRITER
-# lock, then locks all other bytes before commencing recovery. If it fails
-# to lock all other bytes (because some other process is holding a read
-# lock) it should retry up to 100 times. Then return SQLITE_PROTOCOL to the 
-# caller. Test this (test case wal3-4.3).
-#
-# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain
-# the WRITER lock (should be the same). Test case wal3-4.4.
-# 
-proc lock_callback {method filename handle lock} {
-  lappend ::locks $lock
-}
-do_test wal3-4.1 {
-  testvfs T
-  T filter xShmLock 
-  T script lock_callback
-  set ::locks [list]
-  sqlite3 db test.db -vfs T
-  execsql { SELECT * FROM x }
-  lrange $::locks 0 3
-} [list {0 1 lock exclusive} {1 7 lock exclusive}      \
-        {1 7 unlock exclusive} {0 1 unlock exclusive}  \
-]
-do_test wal3-4.2 {
-  db close
-  set ::locks [list]
-  sqlite3 db test.db -vfs T
-  execsql { SELECT * FROM x }
-  lrange $::locks 0 3
-} [list {0 1 lock exclusive} {1 7 lock exclusive}      \
-        {1 7 unlock exclusive} {0 1 unlock exclusive}  \
-]
-proc lock_callback {method filename handle lock} {
-  if {$lock == "1 7 lock exclusive"} { return SQLITE_BUSY }
-  return SQLITE_OK
-}
-puts "# Warning: This next test case causes SQLite to call xSleep(1) 100 times."
-puts "# Normally this equates to a 100ms delay, but if SQLite is built on unix"
-puts "# without HAVE_USLEEP defined, it may be 100 seconds."
-do_test wal3-4.3 {
-  db close
-  set ::locks [list]
-  sqlite3 db test.db -vfs T
-  catchsql { SELECT * FROM x }
-} {1 {locking protocol}}
-
-puts "# Warning: Same again!"
-proc lock_callback {method filename handle lock} {
-  if {$lock == "0 1 lock exclusive"} { return SQLITE_BUSY }
-  return SQLITE_OK
-}
-do_test wal3-4.4 {
-  db close
-  set ::locks [list]
-  sqlite3 db test.db -vfs T
-  catchsql { SELECT * FROM x }
-} {1 {locking protocol}}
-db close
-T delete
-
 
 #-------------------------------------------------------------------------
 # Only one client may run recovery at a time. Test this mechanism.
@@ -617,86 +556,6 @@ db close
 db2 close
 T delete
 
-#-------------------------------------------------------------------------
-# 
-do_test wal3-8.1 {
-  forcedelete test.db test.db-journal test.db wal
-  sqlite3 db test.db
-  sqlite3 db2 test.db
-  execsql {
-    PRAGMA auto_vacuum = off;
-    PRAGMA journal_mode = WAL;
-    CREATE TABLE b(c);
-    INSERT INTO b VALUES('Tehran');
-    INSERT INTO b VALUES('Qom');
-    INSERT INTO b VALUES('Markazi');
-    PRAGMA wal_checkpoint;
-  }
-} {wal 0 5 5}
-do_test wal3-8.2 {
-  execsql { SELECT * FROM b }
-} {Tehran Qom Markazi}
-do_test wal3-8.3 {
-  db eval { SELECT * FROM b } {
-    db eval { INSERT INTO b VALUES('Qazvin') }
-    set r [db2 eval { SELECT * FROM b }]
-    break
-  }
-  set r
-} {Tehran Qom Markazi Qazvin}
-do_test wal3-8.4 {
-  execsql {
-    INSERT INTO b VALUES('Gilan');
-    INSERT INTO b VALUES('Ardabil');
-  }
-} {}
-db2 close
-
-faultsim_save_and_close
-testvfs T -default 1
-faultsim_restore_and_reopen
-T filter xShmLock
-T script lock_callback
-
-proc lock_callback {method file handle spec} {
-  if {$spec == "1 7 unlock exclusive"} {
-    T filter {}
-    set ::r [catchsql { SELECT * FROM b } db2]
-  }
-}
-sqlite3 db test.db
-sqlite3 db2 test.db
-do_test wal3-8.5 {
-  execsql { SELECT * FROM b }
-} {Tehran Qom Markazi Qazvin Gilan Ardabil}
-do_test wal3-8.6 {
-  set ::r
-} {1 {locking protocol}}
-
-db close
-db2 close
-
-faultsim_restore_and_reopen
-sqlite3 db2 test.db
-T filter xShmLock
-T script lock_callback
-proc lock_callback {method file handle spec} {
-  if {$spec == "1 7 unlock exclusive"} {
-    T filter {}
-    set ::r [catchsql { SELECT * FROM b } db2]
-  }
-}
-unset ::r
-do_test wal3-8.5 {
-  execsql { SELECT * FROM b }
-} {Tehran Qom Markazi Qazvin Gilan Ardabil}
-do_test wal3-8.6 {
-  set ::r
-} {1 {locking protocol}}
-
-db close
-db2 close
-T delete
 
 #-------------------------------------------------------------------------
 # When a connection opens a read-lock on the database, it searches for
index 3005a758acd1af0fbcf505991409524f2edf4ce6..f3fc427115cc86edf5282b62fe3b1e7a1d78d42d 100644 (file)
@@ -334,59 +334,5 @@ do_test walcksum-2.1 {
 catch { db close }
 catch { db2 close }
 
-#-------------------------------------------------------------------------
-# Test case walcksum-3.* tests that the checksum calculation detects single 
-# byte changes to frame or frame-header data and considers the frame
-# invalid as a result.
-#
-do_test walcksum-3.1 {
-  forcedelete test.db test.db-wal test.db-journal
-  sqlite3 db test.db
-
-  execsql {
-    PRAGMA synchronous = NORMAL;
-    PRAGMA page_size = 1024;
-    CREATE TABLE t1(a, b);
-    INSERT INTO t1 VALUES(1, randomblob(300));
-    INSERT INTO t1 VALUES(2, randomblob(300));
-    PRAGMA journal_mode = WAL;
-    INSERT INTO t1 VALUES(3, randomblob(300));
-  }
-
-  file size test.db-wal
-} [wal_file_size 1 1024]
-do_test walcksum-3.2 {
-  forcecopy test.db-wal test2.db-wal
-  forcecopy test.db test2.db
-  sqlite3 db2 test2.db
-  execsql { SELECT a FROM t1 } db2
-} {1 2 3}
-db2 close
-forcecopy test.db test2.db
-
-
-foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
-  do_test walcksum-3.3.$incr {
-    set FAIL 0
-    for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} {
-
-      forcecopy test.db-wal test2.db-wal
-      set fd [open test2.db-wal r+]
-      fconfigure $fd -encoding binary
-      fconfigure $fd -translation binary
-  
-      seek $fd $iOff
-      binary scan [read $fd 1] c x
-      seek $fd $iOff
-      puts -nonewline $fd [binary format c [expr {($x+$incr)&0xFF}]]
-      close $fd
-    
-      sqlite3 db2 test2.db
-      if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1}
-      db2 close
-    }
-    set FAIL
-  } {0}
-}
   
 finish_test
diff --git a/test/walprotocol.test b/test/walprotocol.test
new file mode 100644 (file)
index 0000000..d658de9
--- /dev/null
@@ -0,0 +1,177 @@
+# 2016 February 4
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode.
+#
+# More specifically, it tests "locking protocol" errors - errors that
+# may be caused if one or more SQLite clients does not follow the expected
+# locking protocol when accessing a wal-mode database. These tests take
+# quite a while to run.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+source $testdir/wal_common.tcl
+ifcapable !wal {finish_test ; return }
+
+set testprefix walprotocol
+
+#-------------------------------------------------------------------------
+# When recovering the contents of a WAL file, a process obtains the WRITER
+# lock, then locks all other bytes before commencing recovery. If it fails
+# to lock all other bytes (because some other process is holding a read
+# lock) it should retry up to 100 times. Then return SQLITE_PROTOCOL to the 
+# caller. Test this (test case 1.3).
+#
+# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain
+# the WRITER lock (should be the same). Test case 1.4.
+# 
+do_execsql_test 1.0 {
+  PRAGMA journal_mode = wal;
+  CREATE TABLE x(y);
+  INSERT INTO x VALUES('z');
+} {wal}
+
+proc lock_callback {method filename handle lock} {
+  lappend ::locks $lock
+}
+do_test 1.1 {
+  testvfs T
+  T filter xShmLock 
+  T script lock_callback
+  set ::locks [list]
+  sqlite3 db test.db -vfs T
+  execsql { SELECT * FROM x }
+  lrange $::locks 0 3
+} [list {0 1 lock exclusive} {1 7 lock exclusive}      \
+        {1 7 unlock exclusive} {0 1 unlock exclusive}  \
+]
+do_test 1.2 {
+  db close
+  set ::locks [list]
+  sqlite3 db test.db -vfs T
+  execsql { SELECT * FROM x }
+  lrange $::locks 0 3
+} [list {0 1 lock exclusive} {1 7 lock exclusive}      \
+        {1 7 unlock exclusive} {0 1 unlock exclusive}  \
+]
+proc lock_callback {method filename handle lock} {
+  if {$lock == "1 7 lock exclusive"} { return SQLITE_BUSY }
+  return SQLITE_OK
+}
+puts "# Warning: This next test case causes SQLite to call xSlee(1) 100 times."
+puts "# Normally this equates to a delay of roughly 10 seconds, but if SQLite"
+puts "# is built on unix without HAVE_USLEEP defined, it may be much longer."
+do_test 1.3 {
+  db close
+  set ::locks [list]
+  sqlite3 db test.db -vfs T
+  catchsql { SELECT * FROM x }
+} {1 {locking protocol}}
+
+puts "# Warning: Same again!"
+proc lock_callback {method filename handle lock} {
+  if {$lock == "0 1 lock exclusive"} { return SQLITE_BUSY }
+  return SQLITE_OK
+}
+do_test 1.4 {
+  db close
+  set ::locks [list]
+  sqlite3 db test.db -vfs T
+  catchsql { SELECT * FROM x }
+} {1 {locking protocol}}
+db close
+T delete
+
+#-------------------------------------------------------------------------
+# 
+do_test 2.1 {
+  forcedelete test.db test.db-journal test.db wal
+  sqlite3 db test.db
+  sqlite3 db2 test.db
+  execsql {
+    PRAGMA auto_vacuum = off;
+    PRAGMA journal_mode = WAL;
+    CREATE TABLE b(c);
+    INSERT INTO b VALUES('Tehran');
+    INSERT INTO b VALUES('Qom');
+    INSERT INTO b VALUES('Markazi');
+    PRAGMA wal_checkpoint;
+  }
+} {wal 0 5 5}
+do_test 2.2 {
+  execsql { SELECT * FROM b }
+} {Tehran Qom Markazi}
+do_test 2.3 {
+  db eval { SELECT * FROM b } {
+    db eval { INSERT INTO b VALUES('Qazvin') }
+    set r [db2 eval { SELECT * FROM b }]
+    break
+  }
+  set r
+} {Tehran Qom Markazi Qazvin}
+do_test 2.4 {
+  execsql {
+    INSERT INTO b VALUES('Gilan');
+    INSERT INTO b VALUES('Ardabil');
+  }
+} {}
+db2 close
+
+faultsim_save_and_close
+testvfs T -default 1
+faultsim_restore_and_reopen
+T filter xShmLock
+T script lock_callback
+
+proc lock_callback {method file handle spec} {
+  if {$spec == "1 7 unlock exclusive"} {
+    T filter {}
+    set ::r [catchsql { SELECT * FROM b } db2]
+  }
+}
+sqlite3 db test.db
+sqlite3 db2 test.db
+do_test 2.5 {
+  execsql { SELECT * FROM b }
+} {Tehran Qom Markazi Qazvin Gilan Ardabil}
+do_test 2.6 {
+  set ::r
+} {1 {locking protocol}}
+
+db close
+db2 close
+
+faultsim_restore_and_reopen
+sqlite3 db2 test.db
+T filter xShmLock
+T script lock_callback
+proc lock_callback {method file handle spec} {
+  if {$spec == "1 7 unlock exclusive"} {
+    T filter {}
+    set ::r [catchsql { SELECT * FROM b } db2]
+  }
+}
+unset ::r
+do_test 2.7 {
+  execsql { SELECT * FROM b }
+} {Tehran Qom Markazi Qazvin Gilan Ardabil}
+do_test 2.8 {
+  set ::r
+} {1 {locking protocol}}
+
+db close
+db2 close
+T delete
+
+finish_test
index 83f292281a33030bec43abfb20ef97bf3c586272..2a52a225d80e6c11a7b4df3f3a085c4905bcf5fe 100644 (file)
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
+source $testdir/wal_common.tcl
+source $testdir/lock_common.tcl
 
 ifcapable !wal {finish_test ; return }
 
+set testprefix walslow
+
 proc reopen_db {} {
   catch { db close }
   forcedelete test.db test.db-wal
@@ -69,5 +73,159 @@ for {set seed 1} {$seed<10} {incr seed} {
   }
 }
 
+#-------------------------------------------------------------------------
+# Test case walslow-3.* tests that the checksum calculation detects single 
+# byte changes to frame or frame-header data and considers the frame
+# invalid as a result.
+#
+reset_db
+do_test 3.1 {
+
+  execsql {
+    PRAGMA synchronous = NORMAL;
+    PRAGMA page_size = 1024;
+    CREATE TABLE t1(a, b);
+    INSERT INTO t1 VALUES(1, randomblob(300));
+    INSERT INTO t1 VALUES(2, randomblob(300));
+    PRAGMA journal_mode = WAL;
+    INSERT INTO t1 VALUES(3, randomblob(300));
+  }
+
+  file size test.db-wal
+} [wal_file_size 1 1024]
+do_test 3.2 {
+  forcecopy test.db-wal test2.db-wal
+  forcecopy test.db test2.db
+  sqlite3 db2 test2.db
+  execsql { SELECT a FROM t1 } db2
+} {1 2 3}
+db2 close
+forcecopy test.db test2.db
+
+foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {
+  do_test 3.3.$incr {
+    set FAIL 0
+    for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} {
+
+      forcecopy test.db-wal test2.db-wal
+      set fd [open test2.db-wal r+]
+      fconfigure $fd -encoding binary
+      fconfigure $fd -translation binary
+  
+      seek $fd $iOff
+      binary scan [read $fd 1] c x
+      seek $fd $iOff
+      puts -nonewline $fd [binary format c [expr {($x+$incr)&0xFF}]]
+      close $fd
+    
+      sqlite3 db2 test2.db
+      if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1}
+      db2 close
+    }
+    set FAIL
+  } {0}
+}
+
+
+#-------------------------------------------------------------------------
+# Test large log summaries.
+#
+# In this case "large" usually means a log file that requires a wal-index
+# mapping larger than 64KB (the default initial allocation). A 64KB wal-index
+# is large enough for a log file that contains approximately 13100 frames.
+# So the following tests create logs containing at least this many frames.
+#
+# 4.1.*: This test case creates a very large log file within the
+#        file-system (around 200MB). The log file does not contain
+#        any valid frames. Test that the database file can still be
+#        opened and queried, and that the invalid log file causes no 
+#        problems.
+#
+# 4.2.*: Test that a process may create a large log file and query
+#        the database (including the log file that it itself created).
+#
+# 4.3.*: Test that if a very large log file is created, and then a
+#        second connection is opened on the database file, it is possible
+#        to query the database (and the very large log) using the
+#        second connection.
+#
+# 4.4.*: Same test as wal-13.3.*. Except in this case the second
+#        connection is opened by an external process.
+#
+set ::blobcnt 0
+proc blob {nByte} {
+  incr ::blobcnt
+  return [string range [string repeat "${::blobcnt}x" $nByte] 1 $nByte]
+}
+
+reset_db
+do_execsql_test 4.1 {
+  PRAGMA journal_mode = wal;
+  CREATE TABLE t1(x, y);
+  INSERT INTO "t1" VALUES('A',0);
+  CREATE TABLE t2(x, y);
+  INSERT INTO "t2" VALUES('B',2);
+} {wal}
+db close
+
+do_test 4.1.1 {
+  list [file exists test.db] [file exists test.db-wal]
+} {1 0}
+do_test 4.1.2 {
+  set fd [open test.db-wal w]
+  seek $fd [expr 200*1024*1024]
+  puts $fd ""
+  close $fd
+  sqlite3 db test.db
+  execsql { SELECT * FROM t2 }
+} {B 2}
+do_test 4.1.3 {
+  db close
+  file exists test.db-wal
+} {0}
+
+do_test 4.2.1 {
+  sqlite3 db test.db
+  execsql { SELECT count(*) FROM t2 }
+} {1}
+do_test 4.2.2 {
+  db function blob blob
+  for {set i 0} {$i < 16} {incr i} {
+    execsql { INSERT INTO t2 SELECT blob(400), blob(400) FROM t2 }
+  }
+  execsql { SELECT count(*) FROM t2 }
+} [expr int(pow(2, 16))]
+do_test 4.2.3 {
+  expr [file size test.db-wal] > [wal_file_size 33000 1024]
+} 1
+
+do_multiclient_test tn {
+  incr tn 2
+
+  do_test 4.$tn.0 {
+    sql1 {
+      PRAGMA journal_mode = WAL;
+      CREATE TABLE t1(x);
+      INSERT INTO t1 SELECT randomblob(800);
+    }
+    sql1 { SELECT count(*) FROM t1 }
+  } {1}
+
+  for {set ii 1} {$ii<16} {incr ii} {
+    do_test 4.$tn.$ii.a {
+      sql2 { INSERT INTO t1 SELECT randomblob(800) FROM t1 }
+      sql2 { SELECT count(*) FROM t1 }
+    } [expr (1<<$ii)]
+    do_test 4.$tn.$ii.b {
+      sql1 { SELECT count(*) FROM t1 }
+    } [expr (1<<$ii)]
+    do_test 4.$tn.$ii.c {
+      sql1 { SELECT count(*) FROM t1 }
+    } [expr (1<<$ii)]
+    do_test 4.$tn.$ii.d {
+      sql1 { PRAGMA integrity_check }
+    } {ok}
+  }
+}
 
 finish_test
similarity index 84%
rename from test/where8m.test
rename to test/wherefault.test
index 4fce3db7c3bc6de78516ecb4b74e9d4500199c7e..60330a92ddfab800ec66360d82a8da63ee534ad9 100644 (file)
@@ -9,17 +9,19 @@
 #
 #***********************************************************************
 # This file implements regression tests for SQLite library. The focus
-# is testing of where.c. More specifically, the focus is the optimization
-# of WHERE clauses that feature the OR operator.
+# is testing of where.c. More specifically, the focus is on handling OOM
+# errors within the code that optimizes WHERE clauses that feature the 
+# OR operator.
 #
-# $Id: where8m.test,v 1.3 2009/06/05 17:09:12 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
 source $testdir/malloc_common.tcl
 
-do_malloc_test where8m-1 -sqlprep {
+set testprefix wherefault
+
+do_malloc_test 1 -sqlprep {
   CREATE TABLE t1(a, b, c);
   CREATE INDEX i1 ON t1(a);
   CREATE INDEX i2 ON t1(b);
@@ -37,7 +39,7 @@ do_malloc_test where8m-1 -sqlprep {
     a BETWEEN 1 AND 3  AND b < 5 AND b > 2 AND c = 4;
 }
 
-do_malloc_test where8m-2 -tclprep {
+do_malloc_test 2 -tclprep {
   db eval {
     BEGIN;
     CREATE TABLE t1(a, b, c);