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 #*************************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the FTS5 module.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5delete
18 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
23 fts5_aux_test_functions db
26 CREATE VIRTUAL TABLE t1 USING fts5(x);
28 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<5000
30 INSERT INTO t1(rowid, x) SELECT i, (i/2)*2 FROM s;
35 for {set i 1} {$i<=5000} {incr i} {
37 execsql { INSERT INTO t1 VALUES($i) }
39 execsql { DELETE FROM t1 WHERE rowid = $i }
46 execsql { INSERT INTO t1(t1, rank) VALUES('usermerge', 2); }
47 for {set i 0} {$i < 5} {incr i} {
48 execsql { INSERT INTO t1(t1, rank) VALUES('merge', 1) }
49 execsql { INSERT INTO t1(t1) VALUES('integrity-check') }
53 #-------------------------------------------------------------------------
57 id INTEGER PRIMARY KEY,
61 CREATE VIRTUAL TABLE test_idx USING fts5(
62 name, content=test, content_rowid=id
66 do_catchsql_test 2.1 {
67 INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 1, 'quick');
68 } {1 {database disk image is malformed}}
70 do_catchsql_test 2.2 {
71 INSERT INTO test_idx(rowid, name) VALUES(123, 'one one one');
72 INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one');
73 INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one');
74 } {1 {database disk image is malformed}}
78 CREATE VIRTUAL TABLE test_idx USING fts5(
79 name, content=test, content_rowid=id
82 INSERT INTO test_idx(rowid, name) VALUES(123, 'one one one');
83 INSERT INTO test_idx(rowid, name) VALUES(124, 'two two two');
84 INSERT INTO test_idx(rowid, name) VALUES(125, 'two two two');
85 INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one');
86 INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one');
87 INSERT INTO test_idx (test_idx, rowid, name) VALUES('delete', 123, 'one');
90 do_catchsql_test 2.4 {
91 SELECT rowid FROM test_idx WHERE test_idx MATCH 'two' ORDER BY rank;
92 } {1 {database disk image is malformed}}
94 #-------------------------------------------------------------------------
97 CREATE VIRTUAL TABLE tx USING fts5(a, b, c, d, content=);
98 INSERT INTO tx(rowid, a, c) VALUES(1, 'abc def', 'a b c');
99 INSERT INTO tx(rowid, a, c) VALUES(5, 'a b c', 'a b d def');
101 do_execsql_test 3.1 {
102 INSERT INTO tx(tx, rowid, a, b, c, d)
103 VALUES('delete', 5, 'a b c', NULL, 'a b d def', NULL);
105 do_execsql_test 3.2 {
106 INSERT INTO tx(tx) VALUES('integrity-check');
108 do_execsql_test 3.3 {
109 INSERT INTO tx(tx, rowid, a, b, c, d)
110 VALUES('delete', 1, 'abc def', NULL, 'a b c', NULL);
112 do_execsql_test 3.4 {
113 INSERT INTO tx(tx) VALUES('integrity-check');