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 |
| 18 | db close |
| 19 | set ::enable_shared_cache [sqlite3_enable_shared_cache 1] |
| 20 | |
| 21 | sqlite3 db test.db |
| 22 | sqlite3 db2 test.db |
| 23 | |
| 24 | do_test walshared-1.0 { |
| 25 | execsql { |
| 26 | PRAGMA cache_size = 10; |
| 27 | PRAGMA journal_mode = WAL; |
| 28 | CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); |
| 29 | INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); |
| 30 | } |
| 31 | } {wal} |
| 32 | |
| 33 | do_test walshared-1.1 { |
| 34 | execsql { |
| 35 | BEGIN; |
| 36 | INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); |
| 37 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; |
| 38 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; |
| 39 | INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; |
| 40 | } |
| 41 | } {} |
| 42 | |
| 43 | do_test walshared-1.2 { |
| 44 | catchsql { PRAGMA wal_checkpoint } |
| 45 | } {1 {database table is locked}} |
| 46 | |
| 47 | do_test walshared-1.3 { |
| 48 | catchsql { PRAGMA wal_checkpoint } db2 |
| 49 | } {1 {database table is locked}} |
| 50 | |
| 51 | do_test walshared-1.4 { |
| 52 | execsql { COMMIT } |
| 53 | execsql { PRAGMA integrity_check } db2 |
| 54 | } {ok} |
| 55 | |
| 56 | |
| 57 | |
| 58 | sqlite3_enable_shared_cache $::enable_shared_cache |
| 59 | finish_test |
| 60 | |