1 2# 2015-05-28 3# 4# The author disclaims copyright to this source code. In place of 5# a legal notice, here is a blessing: 6# 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. 10# 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. 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17source $testdir/lock_common.tcl 18set testprefix rowallock 19 20do_multiclient_test tn { 21 code2 { db2 close } 22 code3 { db3 close } 23 24 do_execsql_test 1.$tn.1 { 25 PRAGMA page_size = 4096; 26 CREATE TABLE t1(a, b); 27 CREATE TABLE t2(a, b); 28 INSERT INTO t1 VALUES(1, 2), (3, 4); 29 PRAGMA journal_mode = wal; 30 } {wal} 31 32 code1 { 33 db close 34 sqlite3 db test.db -readonly 1 35 } 36 37 do_execsql_test 1.$tn.2 { 38 PRAGMA mmap_size = 1000000; 39 } {1000000} 40 do_execsql_test 1.$tn.2.1 { 41 SELECT * FROM t1; 42 } {1 2 3 4} 43 44 do_catchsql_test 1.$tn.3 { 45 INSERT INTO t1 VALUES(5, 6); 46 } {1 {attempt to write a readonly database}} 47 48 do_test 1.$tn.4 { 49 code2 { sqlite3 db2 test.db } 50 sql2 { INSERT INTO t1 VALUES(5, 6); } 51 code2 { db2 close } 52 file exists test.db-wal 53 } {1} 54 55 do_test 1.$tn.5 { 56 sql1 { SELECT * FROM t2 } 57 code1 { db close } 58 file exists test.db-wal 59 } {1} 60} 61 62finish_test 63