OLD | NEW |
(Empty) | |
| 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 |
| 15 set testdir [file dirname $argv0] |
| 16 source $testdir/tester.tcl |
| 17 source $testdir/lock_common.tcl |
| 18 set testprefix rowallock |
| 19 |
| 20 set mmap_res 1000000 |
| 21 ifcapable !mmap { |
| 22 set mmap_res 0 |
| 23 } |
| 24 |
| 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} |
| 36 |
| 37 code1 { |
| 38 db close |
| 39 sqlite3 db test.db -readonly 1 |
| 40 } |
| 41 |
| 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} |
| 48 |
| 49 do_catchsql_test 1.$tn.3 { |
| 50 INSERT INTO t1 VALUES(5, 6); |
| 51 } {1 {attempt to write a readonly database}} |
| 52 |
| 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} |
| 59 |
| 60 do_test 1.$tn.5 { |
| 61 sql1 { SELECT * FROM t2 } |
| 62 code1 { db close } |
| 63 file exists test.db-wal |
| 64 } {1} |
| 65 } |
| 66 |
| 67 finish_test |
OLD | NEW |