aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/fts3aj.test
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/fts3aj.test')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/fts3aj.test89
1 files changed, 89 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/fts3aj.test b/libraries/sqlite/unix/sqlite-3.5.1/test/fts3aj.test
new file mode 100644
index 0000000..60d26c0
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/fts3aj.test
@@ -0,0 +1,89 @@
1# 2007 February 6
2#
3# The author disclaims copyright to this source code.
4#
5#*************************************************************************
6# This file implements regression tests for SQLite library. This
7# tests creating fts3 tables in an attached database.
8#
9# $Id: fts3aj.test,v 1.1 2007/08/20 17:38:42 shess Exp $
10#
11
12set testdir [file dirname $argv0]
13source $testdir/tester.tcl
14
15# If SQLITE_ENABLE_FTS3 is defined, omit this file.
16ifcapable !fts3 {
17 finish_test
18 return
19}
20
21# Clean up anything left over from a previous pass.
22file delete -force test2.db
23file delete -force test2.db-journal
24sqlite3 db2 test2.db
25
26db eval {
27 CREATE VIRTUAL TABLE t3 USING fts3(content);
28 INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
29}
30
31db2 eval {
32 CREATE VIRTUAL TABLE t1 USING fts3(content);
33 INSERT INTO t1 (rowid, content) VALUES(1, "hello world");
34 INSERT INTO t1 (rowid, content) VALUES(2, "hello there");
35 INSERT INTO t1 (rowid, content) VALUES(3, "cruel world");
36}
37
38# This has always worked because the t1_* tables used by fts3 will be
39# the defaults.
40do_test fts3aj-1.1 {
41 execsql {
42 ATTACH DATABASE 'test2.db' AS two;
43 SELECT rowid FROM t1 WHERE t1 MATCH 'hello';
44 DETACH DATABASE two;
45 }
46} {1 2}
47# Make certain we're detached if there was an error.
48catch {db eval {DETACH DATABASE two}}
49
50# In older code, this appears to work fine, but the t2_* tables used
51# by fts3 will be created in database 'main' instead of database
52# 'two'. It appears to work fine because the tables end up being the
53# defaults, but obviously is badly broken if you hope to use things
54# other than in the exact same ATTACH setup.
55do_test fts3aj-1.2 {
56 execsql {
57 ATTACH DATABASE 'test2.db' AS two;
58 CREATE VIRTUAL TABLE two.t2 USING fts3(content);
59 INSERT INTO t2 (rowid, content) VALUES(1, "hello world");
60 INSERT INTO t2 (rowid, content) VALUES(2, "hello there");
61 INSERT INTO t2 (rowid, content) VALUES(3, "cruel world");
62 SELECT rowid FROM t2 WHERE t2 MATCH 'hello';
63 DETACH DATABASE two;
64 }
65} {1 2}
66catch {db eval {DETACH DATABASE two}}
67
68# In older code, this broke because the fts3 code attempted to create
69# t3_* tables in database 'main', but they already existed. Normally
70# this wouldn't happen without t3 itself existing, in which case the
71# fts3 code would never be called in the first place.
72do_test fts3aj-1.3 {
73 execsql {
74 ATTACH DATABASE 'test2.db' AS two;
75
76 CREATE VIRTUAL TABLE two.t3 USING fts3(content);
77 INSERT INTO two.t3 (rowid, content) VALUES(2, "hello there");
78 INSERT INTO two.t3 (rowid, content) VALUES(3, "cruel world");
79 SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';
80
81 DETACH DATABASE two;
82 } db2
83} {2}
84catch {db eval {DETACH DATABASE two}}
85
86catch {db2 close}
87file delete -force test2.db
88
89finish_test