Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/fts3aj.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / fts3aj.test` 87 lines ยท 2711 bytes Raw Blame History 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 10 set testdir [file dirname $argv0] 11 source $testdir/tester.tcl 12 13 # If SQLITE_ENABLE_FTS3 is defined, omit this file. 14 ifcapable !fts3 { 15 finish_test 16 return 17 } 18 19 # Clean up anything left over from a previous pass. 20 forcedelete test2.db 21 forcedelete test2.db-journal 22 sqlite3 db2 test2.db 23 24 db eval { 25 CREATE VIRTUAL TABLE t3 USING fts3(content); 26 INSERT INTO t3 (rowid, content) VALUES(1, 'hello world'); 27 } 28 29 db2 eval { 30 CREATE VIRTUAL TABLE t1 USING fts3(content); 31 INSERT INTO t1 (rowid, content) VALUES(1, 'hello world'); 32 INSERT INTO t1 (rowid, content) VALUES(2, 'hello there'); 33 INSERT INTO t1 (rowid, content) VALUES(3, 'cruel world'); 34 } 35 36 # This has always worked because the t1_* tables used by fts3 will be 37 # the defaults. 38 do_test fts3aj-1.1 { 39 execsql { 40 ATTACH DATABASE 'test2.db' AS two; 41 SELECT rowid FROM t1 WHERE t1 MATCH 'hello'; 42 DETACH DATABASE two; 43 } 44 } {1 2} 45 # Make certain we're detached if there was an error. 46 catch {db eval {DETACH DATABASE two}} 47 48 # In older code, this appears to work fine, but the t2_* tables used 49 # by fts3 will be created in database 'main' instead of database 50 # 'two'. It appears to work fine because the tables end up being the 51 # defaults, but obviously is badly broken if you hope to use things 52 # other than in the exact same ATTACH setup. 53 do_test fts3aj-1.2 { 54 execsql { 55 ATTACH DATABASE 'test2.db' AS two; 56 CREATE VIRTUAL TABLE two.t2 USING fts3(content); 57 INSERT INTO t2 (rowid, content) VALUES(1, 'hello world'); 58 INSERT INTO t2 (rowid, content) VALUES(2, 'hello there'); 59 INSERT INTO t2 (rowid, content) VALUES(3, 'cruel world'); 60 SELECT rowid FROM t2 WHERE t2 MATCH 'hello'; 61 DETACH DATABASE two; 62 } 63 } {1 2} 64 catch {db eval {DETACH DATABASE two}} 65 66 # In older code, this broke because the fts3 code attempted to create 67 # t3_* tables in database 'main', but they already existed. Normally 68 # this wouldn't happen without t3 itself existing, in which case the 69 # fts3 code would never be called in the first place. 70 do_test fts3aj-1.3 { 71 execsql { 72 ATTACH DATABASE 'test2.db' AS two; 73 74 CREATE VIRTUAL TABLE two.t3 USING fts3(content); 75 INSERT INTO two.t3 (rowid, content) VALUES(2, 'hello there'); 76 INSERT INTO two.t3 (rowid, content) VALUES(3, 'cruel world'); 77 SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello'; 78 79 DETACH DATABASE two; 80 } db2 81 } {2} 82 catch {db eval {DETACH DATABASE two}} 83 84 catch {db2 close} 85 forcedelete test2.db 86 87 finish_test