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 #*************************************************************************
13 source [file join [file dirname [info script]] fts5_common.tcl]
15 set ::testprefix fts5secure4
17 #-------------------------------------------------------------------------
18 # Test using the 'delete' command to attempt to delete a token that
19 # is not present in the index in secure-delete mode.
22 CREATE VIRTUAL TABLE t1 USING fts5(a, b, content=x1);
24 CREATE TABLE x1(rowid INTEGER PRIMARY KEY, a, b);
26 (1, 'hello world', 'today xyz'),
27 (2, 'not the day', 'crunch crumble and chomp'),
29 INSERT INTO t1(t1) VALUES('rebuild');
33 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
37 INSERT INTO t1(t1, rowid, a, b) VALUES('delete', 4, 'nosuchtoken', '');
41 INSERT INTO t1(t1) VALUES('integrity-check');
45 INSERT INTO t1(t1, rowid, a, b) VALUES('delete', 1, 'crunch', '');
49 INSERT INTO t1(t1, rowid, a, b) VALUES('delete', 3, 'crunch', '');
53 INSERT INTO t1(t1) VALUES('integrity-check');
57 CREATE VIRTUAL TABLE y1 USING fts5(xx, prefix='1,2');
58 INSERT INTO y1(y1, rank) VALUES('pgsz', 64);
59 INSERT INTO y1(y1, rank) VALUES('secure-delete', 1);
63 INSERT INTO y1(rowid, xx) VALUES(1, 'abc def');
64 INSERT INTO y1(rowid, xx) VALUES(2, 'reallyreallylongtoken');
68 DELETE FROM y1 WHERE rowid=1;
69 INSERT INTO y1(y1) VALUES('integrity-check');
72 do_execsql_test 1.10 {
73 CREATE VIRTUAL TABLE w1 USING fts5(ww, content="");
74 INSERT INTO w1(rowid, ww) VALUES(123, '');
76 do_catchsql_test 1.11 {
77 INSERT INTO w1(w1, rowid, ww) VALUES('delete', 123, 'xyz');
78 } {1 {database disk image is malformed}}
79 do_catchsql_test 1.12 {
81 CREATE VIRTUAL TABLE w1 USING fts5(ww, content="");
82 INSERT INTO w1(rowid, ww) VALUES(123, '');
83 DELETE FROM w1_data WHERE id>10;
84 INSERT INTO w1(w1, rowid, ww) VALUES('delete', 123, 'xyz');
85 } {1 {database disk image is malformed}}
87 #-------------------------------------------------------------------------
88 # Test using secure-delete with detail=none or detail=col.
90 foreach {tn d} {1 full 2 none 3 column} {
92 do_execsql_test 2.$tn.1 "
93 CREATE VIRTUAL TABLE x1 USING fts5(xx, yy, zz, detail=$d, prefix='10,20');
94 INSERT INTO x1(x1, rank) VALUES('pgsz', 64);
95 INSERT INTO x1(x1, rank) VALUES('secure-delete', 1);
98 do_execsql_test 2.$tn.2 {
100 INSERT INTO x1(xx, yy, zz) VALUES('a b c', 'd e f', 'a b c');
101 INSERT INTO x1(xx, yy, zz) VALUES('a b c', 'd e f', 'a b c');
102 INSERT INTO x1(xx, yy, zz) VALUES('a b c', 'd e f', 'a b c');
103 INSERT INTO x1(xx, yy, zz) VALUES('a b c', 'd e f', 'a b c');
104 INSERT INTO x1(xx, yy, zz) VALUES('a b c', 'd e f', 'a b c');
106 INSERT INTO x1(x1) VALUES('integrity-check');
109 do_execsql_test 2.$tn.3 {
110 DELETE FROM x1 WHERE rowid IN (2, 4, 6);
111 INSERT INTO x1(x1) VALUES('integrity-check');
114 do_execsql_test 2.$tn.4 {
115 DELETE FROM x1 WHERE rowid IN (1, 3, 5);
116 INSERT INTO x1(x1) VALUES('integrity-check');
119 do_execsql_test 2.$tn.5 {
121 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
124 SELECT 'seems to be', 'used brew to', 'everything is working' FROM s
126 SELECT 'used brew to', 'everything is working', 'seems to be' FROM s
128 SELECT 'everything is working', 'seems to be', 'used brew to' FROM s
130 SELECT 'abc', 'zzz', 'a b c d'
132 SELECT 'z', 'z', 'z' FROM s
136 for {set i 300} {$i > 200} {incr i -1} {
138 DELETE FROM x1 WHERE rowid=$i;
139 INSERT INTO x1(x1) VALUES('integrity-check');
145 for {set i 1} {$i < 100} {incr i} {
147 DELETE FROM x1 WHERE rowid=$i;
148 INSERT INTO x1(x1) VALUES('integrity-check');
154 foreach i [db eval {SELECT rowid FROM x1}] {
156 DELETE FROM x1 WHERE rowid=$i;
157 INSERT INTO x1(x1) VALUES('integrity-check');
162 do_execsql_test 2.$tn.9 {