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 #***********************************************************************
12 # This file focuses on testing the planner (xBestIndex function).
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5restart
18 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
25 CREATE VIRTUAL TABLE f1 USING fts5(ff);
28 #-------------------------------------------------------------------------
29 # Run the 'optimize' command. Check that it does not disturb ongoing
33 for {set i 1} {$i < 1000} {incr i} {
34 execsql { INSERT INTO f1 VALUES('a b c d e') }
40 SELECT rowid FROM f1 WHERE f1 MATCH 'c';
45 db eval { SELECT rowid FROM f1 WHERE f1 MATCH 'c' } {
47 execsql { INSERT INTO f1(f1) VALUES('optimize') }
57 db2 eval { SELECT rowid FROM f1 WHERE f1 MATCH 'c' } {
59 set cres [catchsql { INSERT INTO f1(f1) VALUES('optimize') }]
69 } {1 {database is locked}}
71 #-------------------------------------------------------------------------
72 # Open a couple of cursors. Then close them in the same order.
75 set ::s1 [sqlite3_prepare db "SELECT rowid FROM f1 WHERE f1 MATCH 'b'" -1 X]
76 set ::s2 [sqlite3_prepare db "SELECT rowid FROM f1 WHERE f1 MATCH 'c'" -1 X]
85 sqlite3_finalize $::s1
86 sqlite3_finalize $::s2
89 #-------------------------------------------------------------------------
90 # Copy data between two FTS5 tables.
93 CREATE VIRTUAL TABLE f2 USING fts5(gg);
94 INSERT INTO f2 SELECT ff FROM f1 WHERE f1 MATCH 'b+c+d';
97 SELECT rowid FROM f2 WHERE f2 MATCH 'a+b+c+d+e'
100 #-------------------------------------------------------------------------
101 # Remove the row that an FTS5 cursor is currently pointing to. And
102 # various other similar things. Check that this does not disturb
105 do_execsql_test 4.0 {
106 CREATE VIRTUAL TABLE n4 USING fts5(n);
107 INSERT INTO n4(rowid, n) VALUES(100, '1 2 3 4 5');
108 INSERT INTO n4(rowid, n) VALUES(200, '1 2 3 4');
109 INSERT INTO n4(rowid, n) VALUES(300, '2 3 4');
110 INSERT INTO n4(rowid, n) VALUES(400, '2 3');
111 INSERT INTO n4(rowid, n) VALUES(500, '3');
116 db eval { SELECT rowid FROM n4 WHERE n4 MATCH '3' } {
118 execsql { DELETE FROM n4 WHERE rowid=300 }
123 } {100 200 300 400 500}
126 execsql { INSERT INTO n4(rowid, n) VALUES(300, '2 3 4') }
128 db eval { SELECT rowid FROM n4 WHERE n4 MATCH '3' ORDER BY rowid DESC} {
130 execsql { DELETE FROM n4 WHERE rowid=300 }
135 } {500 400 300 200 100}
138 execsql { INSERT INTO n4(rowid, n) VALUES(300, '2 3 4') }
140 db eval { SELECT rowid FROM n4 WHERE n4 MATCH '3' ORDER BY rowid DESC} {
142 execsql { DELETE FROM n4 }