blob: 658a25f9e11e3aba8ae1201564f3012ecb4bfd23 [file] [log] [blame]
dana550f2d2010-08-02 10:47:05 +00001# 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
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18db close
19set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
20
21sqlite3 db test.db
22sqlite3 db2 test.db
23
24do_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
33do_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
43do_test walshared-1.2 {
44 catchsql { PRAGMA wal_checkpoint }
45} {1 {database table is locked}}
46
47do_test walshared-1.3 {
48 catchsql { PRAGMA wal_checkpoint } db2
49} {1 {database table is locked}}
50
51do_test walshared-1.4 {
52 execsql { COMMIT }
53 execsql { PRAGMA integrity_check } db2
54} {ok}
55
56
57
58sqlite3_enable_shared_cache $::enable_shared_cache
59finish_test
60