dan | a550f2d | 2010-08-02 10:47:05 +0000 | [diff] [blame] | 1 | # 2010 August 2 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # This file implements regression tests for SQLite library. The |
| 12 | # focus of this file is testing the operation of the library in |
| 13 | # "PRAGMA journal_mode=WAL" mode with shared-cache turned on. |
| 14 | # |
| 15 | |
| 16 | set testdir [file dirname $argv0] |
| 17 | source $testdir/tester.tcl |
shaneh | 9091f77 | 2010-08-24 18:35:12 +0000 | [diff] [blame] | 18 | |
| 19 | ifcapable !wal {finish_test ; return } |
| 20 | |
dan | a550f2d | 2010-08-02 10:47:05 +0000 | [diff] [blame] | 21 | db close |
| 22 | set ::enable_shared_cache [sqlite3_enable_shared_cache 1] |
| 23 | |
| 24 | sqlite3 db test.db |
| 25 | sqlite3 db2 test.db |
| 26 | |
| 27 | do_test walshared-1.0 { |
| 28 | execsql { |
| 29 | PRAGMA cache_size = 10; |
| 30 | PRAGMA journal_mode = WAL; |
| 31 | CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); |
| 32 | INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); |
| 33 | } |
| 34 | } {wal} |
| 35 | |
| 36 | do_test walshared-1.1 { |
| 37 | execsql { |
| 38 | BEGIN; |
| 39 | INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); |
| 40 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; |
| 41 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; |
| 42 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; |
| 43 | } |
| 44 | } {} |
| 45 | |
| 46 | do_test walshared-1.2 { |
| 47 | catchsql { PRAGMA wal_checkpoint } |
| 48 | } {1 {database table is locked}} |
| 49 | |
| 50 | do_test walshared-1.3 { |
| 51 | catchsql { PRAGMA wal_checkpoint } db2 |
| 52 | } {1 {database table is locked}} |
| 53 | |
| 54 | do_test walshared-1.4 { |
| 55 | execsql { COMMIT } |
| 56 | execsql { PRAGMA integrity_check } db2 |
| 57 | } {ok} |
| 58 | |
| 59 | |
| 60 | |
| 61 | sqlite3_enable_shared_cache $::enable_shared_cache |
| 62 | finish_test |