• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 2010 September 17
2#
3#    May you do good and not evil.
4#    May you find forgiveness for yourself and forgive others.
5#    May you share freely, never taking more than you give.
6#
7#***********************************************************************
8#
9
10set testdir [file dirname $argv0]
11source $testdir/tester.tcl
12
13ifcapable !fts3||!shared_cache {
14  finish_test
15  return
16}
17
18db close
19set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
20
21# Open two connections to the database in shared-cache mode.
22#
23sqlite3 db test.db
24sqlite3 db2 test.db
25
26# Create a virtual FTS3 table. Populate it with some initial data.
27#
28do_execsql_test fts3shared-1.1 {
29  CREATE VIRTUAL TABLE t1 USING fts3(x);
30  BEGIN;
31  INSERT INTO t1 VALUES('We listened and looked sideways up!');
32  INSERT INTO t1 VALUES('Fear at my heart, as at a cup,');
33  INSERT INTO t1 VALUES('My life-blood seemed to sip!');
34  INSERT INTO t1 VALUES('The stars were dim, and thick the night');
35  COMMIT;
36} {}
37
38# Open a write transaction and insert rows into the FTS3 table. This takes
39# a write-lock on the underlying t1_content table.
40#
41do_execsql_test fts3shared-1.2 {
42  BEGIN;
43    INSERT INTO t1 VALUES('The steersman''s face by his lamp gleamed white;');
44} {}
45
46# Now try a SELECT on the full-text table. This particular SELECT does not
47# read data from the %_content table. But it still attempts to obtain a lock
48# on that table and so the SELECT fails.
49#
50do_test fts3shared-1.3 {
51  catchsql {
52    BEGIN;
53      SELECT rowid FROM t1 WHERE t1 MATCH 'stars'
54  } db2
55} {1 {database table is locked}}
56
57# Verify that the first connection can commit its transaction.
58#
59do_test fts3shared-1.4 { sqlite3_get_autocommit db } 0
60do_execsql_test fts3shared-1.5 { COMMIT } {}
61do_test fts3shared-1.6 { sqlite3_get_autocommit db } 1
62
63# Verify that the second connection still has an open transaction.
64#
65do_test fts3shared-1.6 { sqlite3_get_autocommit db2 } 0
66
67db close
68db2 close
69
70sqlite3_enable_shared_cache $::enable_shared_cache
71finish_test
72
73