summaryrefslogtreecommitdiff
path: root/test/io.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/io.test')
-rw-r--r--test/io.test77
1 files changed, 76 insertions, 1 deletions
diff --git a/test/io.test b/test/io.test
index 9363b0c..11f9cc8 100644
--- a/test/io.test
+++ b/test/io.test
@@ -16,6 +16,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+set ::testprefix io
db close
sqlite3_simulate_device
@@ -38,6 +39,10 @@ sqlite3 db test.db -vfs devsym
#
# io-5.* - Test that the default page size is selected and used
# correctly.
+#
+# io-6.* - Test that the pager-cache is not being flushed unnecessarily
+# after a transaction that uses the special atomic-write path
+# is committed.
#
set ::nWrite 0
@@ -207,7 +212,7 @@ do_test io-2.5.3 {
# Changed 2010-03-27: The size of the database is now stored in
# bytes 28..31 and so when a page is added to the database, page 1
# is immediately modified and the journal file immediately comes into
-# existance. To fix this test, the BEGIN is changed into a a
+# existence. To fix this test, the BEGIN is changed into a a
# BEGIN IMMEDIATE and the INSERT is omitted.
#
do_test io-2.6.1 {
@@ -565,5 +570,75 @@ foreach {char sectorsize pgsize} {
} $pgsize
}
+#----------------------------------------------------------------------
+#
+do_test io-6.1 {
+ db close
+ sqlite3_simulate_device -char atomic
+ forcedelete test.db
+ sqlite3 db test.db -vfs devsym
+ execsql {
+ PRAGMA mmap_size = 0;
+ PRAGMA page_size = 1024;
+ PRAGMA cache_size = 2000;
+ CREATE TABLE t1(x);
+ CREATE TABLE t2(x);
+ CREATE TABLE t3(x);
+ CREATE INDEX i3 ON t3(x);
+ INSERT INTO t3 VALUES(randomblob(100));
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ INSERT INTO t3 SELECT randomblob(100) FROM t3;
+ }
+
+ db_save_and_close
+} {}
+
+foreach {tn sql} {
+ 1 { BEGIN;
+ INSERT INTO t1 VALUES('123');
+ INSERT INTO t2 VALUES('456');
+ COMMIT;
+ }
+ 2 { BEGIN;
+ INSERT INTO t1 VALUES('123');
+ COMMIT;
+ }
+} {
+
+ # These tests don't work with memsubsys1, as it causes the effective page
+ # cache size to become too small to hold the entire db in memory.
+ if {[permutation] == "memsubsys1"} continue
+
+ db_restore
+ sqlite3 db test.db -vfs devsym
+ execsql {
+ PRAGMA cache_size = 2000;
+ PRAGMA mmap_size = 0;
+ SELECT x FROM t3 ORDER BY rowid;
+ SELECT x FROM t3 ORDER BY x;
+ }
+ do_execsql_test 6.2.$tn.1 { PRAGMA integrity_check } {ok}
+ do_execsql_test 6.2.$tn.2 $sql
+
+ # Corrupt the database file on disk. This should not matter for the
+ # purposes of the following "PRAGMA integrity_check", as the entire
+ # database should be cached in the pager-cache. If corruption is
+ # reported, it indicates that executing $sql caused the pager cache
+ # to be flushed. Which is a bug.
+ hexio_write test.db [expr 1024 * 5] [string repeat 00 2048]
+ do_execsql_test 6.2.$tn.3 { PRAGMA integrity_check } {ok}
+ db close
+}
+
sqlite3_simulate_device -char {} -sectorsize 0
finish_test
+