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 #*************************************************************************
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 ifcapable !fts5 { finish_test ; return }
17 set ::testprefix fts5secure3
20 CREATE VIRTUAL TABLE ft USING fts5(col);
21 INSERT INTO ft VALUES('data for the table');
22 INSERT INTO ft VALUES('more of the same');
23 INSERT INTO ft VALUES('and extra data');
25 INSERT INTO ft(ft, rank) VALUES('secure-delete', 1);
30 INSERT INTO ft(rowid, col) VALUES(0, 'the next data');
31 DELETE FROM ft WHERE rowid=1;
32 DELETE FROM ft WHERE rowid=2;
33 INSERT INTO ft(rowid, col) VALUES(6, 'with some more of the same data');
38 INSERT INTO ft(ft) VALUES('integrity-check');
41 #-------------------------------------------------------------------------
45 CREATE VIRTUAL TABLE t1 USING fts5(x);
46 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
47 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
49 INSERT INTO t1 VALUES('the start');
52 for {set i 0} {$i < 1000} {incr i} {
53 execsql { INSERT INTO t1 VALUES('the ' || hex(randomblob(3))) }
56 INSERT INTO t1 VALUES('the end');
62 DELETE FROM t1 WHERE rowid BETWEEN 2 AND 1000;
66 INSERT INTO t1(t1) VALUES('integrity-check');
70 INSERT INTO t1(rowid, x) VALUES(500, 'middle');
71 INSERT INTO t1(rowid, x) VALUES(501, 'value');
72 SELECT * FROM t1('the middle');
76 INSERT INTO t1(t1) VALUES('optimize');
80 SELECT count(*) FROM t1_data
83 #execsql_pp { SELECT id, quote(block), fts5_decode(id, block) FROM t1_data; }
85 #-------------------------------------------------------------------------
86 # Tests with large/small rowid values.
91 2 "INSERT INTO fff(fff, rank) VALUES('secure-delete', 1)"
98 Popper Poppins Popsicle Porfirio Porrima Porsche
99 Porter Portia Portland Portsmouth Portugal Portuguese
100 Poseidon Post PostgreSQL Potemkin Potomac Potsdam
101 Pottawatomie Potter Potts Pound Poussin Powell
102 PowerPC PowerPoint Powers Powhatan Poznan Prada
103 Prado Praetorian Prague Praia Prakrit Pratchett
104 Pratt Pravda Praxiteles Preakness Precambrian Preminger
105 Premyslid Prensa Prentice Pres Presbyterian Presbyterianism
108 for {set i 0} {$i<8} {incr i} {
109 lappend ret [lindex $::vocab [expr int(abs(rand()) * [llength $::vocab])]]
113 db func newdoc newdoc
115 do_execsql_test 3.$tn.0 {
116 CREATE VIRTUAL TABLE fff USING fts5(y);
117 INSERT INTO fff(fff, rank) VALUES('pgsz', 64);
119 WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
120 INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
122 WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
123 INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
125 WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
126 INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
133 while {[llength $in]>0} {
134 set idx [expr int(abs(rand()) * [llength $in])]
135 lappend out [lindex $in $idx]
136 set in [lreplace $in $idx $idx]
144 foreach ii [lshuffle [db eval {SELECT rowid FROM fff}]] {
145 #if {$iTest==1} { dump fff }
146 #if {$iTest==1} { breakpoint }
147 do_execsql_test 3.$tn.1.$iTest.$ii {
148 DELETE FROM fff WHERE rowid=$ii;
150 #if {$iTest==1} { dump fff }
151 if {($iTest % 20)==0} {
152 do_execsql_test 3.$tn.1.$iTest.$ii.ic {
153 INSERT INTO fff(fff) VALUES('integrity-check');
156 #if {$iTest==1} { break }
161 #execsql_pp { SELECT rowid FROM fff('post') ORDER BY rowid ASC }
164 # SELECT rowid FROM fff('post') ORDER BY rowid DESC