Small performance optimization in sqlite3VdbeRecordCompareWithSkip() for
[sqlite.git] / test / rowallock.test
bloba1cab8d327c2c22af141cb466230bcfaaa741bc2
2 # 2015-05-28
4 # The author disclaims copyright to this source code.  In place of
5 # a legal notice, here is a blessing:
7 #    May you do good and not evil.
8 #    May you find forgiveness for yourself and forgive others.
9 #    May you share freely, never taking more than you give.
11 #***********************************************************************
12 # This file implements regression tests for SQLite library.  The
13 # focus of this file is testing locks on read-only WAL-mode databases.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 source $testdir/lock_common.tcl
18 set testprefix rowallock
20 set mmap_res 1000000
21 ifcapable !mmap {
22   set mmap_res 0
25 do_multiclient_test tn {
26   code2 { db2 close }
27   code3 { db3 close }
28   
29   do_execsql_test 1.$tn.1 {
30     PRAGMA page_size = 4096;
31     CREATE TABLE t1(a, b);
32     CREATE TABLE t2(a, b);
33     INSERT INTO t1 VALUES(1, 2), (3, 4);
34     PRAGMA journal_mode = wal;
35   } {wal}
37   code1 { 
38     db close 
39     sqlite3 db test.db -readonly 1
40   }
42   do_execsql_test 1.$tn.2 {
43     PRAGMA mmap_size = 1000000;
44   } $mmap_res
45   do_execsql_test 1.$tn.2.1 {
46     SELECT * FROM t1;
47   } {1 2 3 4}
49   do_catchsql_test 1.$tn.3 {
50     INSERT INTO t1 VALUES(5, 6);
51   } {1 {attempt to write a readonly database}}
53   do_test 1.$tn.4 {
54     code2 { sqlite3 db2 test.db }
55     sql2 { INSERT INTO t1 VALUES(5, 6); }
56     code2 { db2 close }
57     file exists test.db-wal
58   } {1}
60   do_test 1.$tn.5 {
61     sql1 { SELECT * FROM t2 }
62     code1 { db close }
63     file exists test.db-wal
64   } {1}
67 finish_test