blob: 97a64be7f573e9428165d6b8d82956850658b8b7 [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
adam985be1b2010-11-09 00:43:59 +000018
19ifcapable !wal {finish_test ; return }
adam0cb33b62012-04-02 23:35:45 +000020if ![wal_is_ok] { finish_test; return }
adam985be1b2010-11-09 00:43:59 +000021
dana550f2d2010-08-02 10:47:05 +000022db close
23set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
24
25sqlite3 db test.db
26sqlite3 db2 test.db
27
28do_test walshared-1.0 {
29 execsql {
30 PRAGMA cache_size = 10;
31 PRAGMA journal_mode = WAL;
32 CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
33 INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
34 }
35} {wal}
36
37do_test walshared-1.1 {
38 execsql {
39 BEGIN;
40 INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
41 INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
42 INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
43 INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
44 }
45} {}
46
47do_test walshared-1.2 {
48 catchsql { PRAGMA wal_checkpoint }
49} {1 {database table is locked}}
50
51do_test walshared-1.3 {
52 catchsql { PRAGMA wal_checkpoint } db2
53} {1 {database table is locked}}
54
55do_test walshared-1.4 {
56 execsql { COMMIT }
57 execsql { PRAGMA integrity_check } db2
58} {ok}
59
60
61
62sqlite3_enable_shared_cache $::enable_shared_cache
63finish_test