Remove a lot of the text describing extended format options from the
[sqlite.git] / test / fts1j.test
blob4dac22abbfe82c89d6c93c0886d16e655955d893
1 # 2007 February 6
3 # The author disclaims copyright to this source code.
5 #*************************************************************************
6 # This file implements regression tests for SQLite library.  This
7 # tests creating fts1 tables in an attached database.
9 # $Id: fts1j.test,v 1.1 2007/02/07 01:01:18 shess Exp $
12 set testdir [file dirname $argv0]
13 source $testdir/tester.tcl
15 # If SQLITE_ENABLE_FTS1 is defined, omit this file.
16 ifcapable !fts1 {
17   finish_test
18   return
21 # Clean up anything left over from a previous pass.
22 forcedelete test2.db
23 forcedelete test2.db-journal
24 sqlite3 db2 test2.db
26 db eval {
27   CREATE VIRTUAL TABLE t3 USING fts1(content);
28   INSERT INTO t3 (rowid, content) VALUES(1, "hello world");
31 db2 eval {
32   CREATE VIRTUAL TABLE t1 USING fts1(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");
38 # This has always worked because the t1_* tables used by fts1 will be
39 # the defaults.
40 do_test fts1j-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.
48 catch {db eval {DETACH DATABASE two}}
50 # In older code, this appears to work fine, but the t2_* tables used
51 # by fts1 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.
55 do_test fts1j-1.2 {
56   execsql {
57     ATTACH DATABASE 'test2.db' AS two;
58     CREATE VIRTUAL TABLE two.t2 USING fts1(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}
66 catch {db eval {DETACH DATABASE two}}
68 # In older code, this broke because the fts1 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 # fts1 code would never be called in the first place.
72 do_test fts1j-1.3 {
73   execsql {
74     ATTACH DATABASE 'test2.db' AS two;
76     CREATE VIRTUAL TABLE two.t3 USING fts1(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';
81     DETACH DATABASE two;
82   } db2
83 } {2}
84 catch {db eval {DETACH DATABASE two}}
86 catch {db2 close}
87 forcedelete test2.db
89 finish_test