3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/lock_common.tcl
16 source $testdir/wal_common.tcl
18 finish_test; return; # Feature currently not implemented.
19 ifcapable !wal {finish_test ; return }
20 if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
21 set testprefix walblock
24 testvfs tvfs -fullshm 1
25 foreach f [glob test.db*] { forcedelete $f }
27 sqlite3 db test.db -vfs tvfs
28 do_execsql_test 1.1.0 {
29 CREATE TABLE t1(x, y);
30 INSERT INTO t1 VALUES(1, 2);
31 INSERT INTO t1 VALUES(3, 4);
32 INSERT INTO t1 VALUES(5, 6);
33 PRAGMA journal_mode = wal;
34 INSERT INTO t1 VALUES(7, 8);
39 } {test.db test.db-shm test.db-wal}
42 set C [launch_testfixture]
45 db eval { SELECT * FROM t1 }
52 db eval { SELECT * FROM t1 }
63 # Test that if a read client cannot read the wal-index header because a
64 # write client is in the middle of updating it, the reader blocks until
65 # the writer finishes.
67 # 1. Open a write transaction using client [db] in this process.
69 # 2. Attempt to commit the write transaction. Intercept the xShmBarrier()
70 # call made by the writer between updating the two copies of the
73 # 3. Within the xShmBarrier() callback, make an asynchronous request to
74 # the other process to read from the database. It should block, as it
75 # cannot get read the wal-index header.
77 # 4. Still in xShmBarrier(), wait for 5 seconds. Check that the other
78 # process has not answered the request.
80 # 5: Finish committing the transaction. Then wait for 0.5 seconds more.
81 # Ensure that the second process has by this stage read the database
82 # and that the snapshot it read included the transaction committed in
85 do_execsql_test 1.2.1 {
87 INSERT INTO t1 VALUES(9, 10);
90 tvfs script barrier_callback
91 tvfs filter xShmBarrier
92 proc barrier_callback {method args} {
94 testfixture $::C { db eval { SELECT * FROM t1 } } {set ::out}
96 do_test "1.2.2.(blocking 10 seconds)" {
98 after 10000 {set ::continue 1}
106 do_test "1.2.3.(blocking 0.5 seconds)" {
108 after 500 {set ::continue 1}
111 } {1 2 3 4 5 6 7 8 9 10}