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 fts5secure7
24 set nDeletePerRep [expr 5]
28 proc select_one {list} {
30 lindex $list [expr {abs(int(rand()*$n))}]
34 set L [split "abcdefghijklmnopqrstuvwxyz" {}]
36 for {set i 0} {$i < $::NVOCAB} {incr i} {
37 set n [expr {6 + int(rand()*8)}]
39 for {set j 0} {$j < $n} {incr j} {
40 append word [select_one $L]
50 proc get_document {nWord} {
52 for {set i 0} {$i < $nWord} {incr i} {
53 lappend ret [get_word]
60 db func document [list get_document 12]
63 CREATE VIRTUAL TABLE t1 USING fts5(body);
64 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
68 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$NDOC
70 INSERT INTO t1 SELECT document() FROM s;
73 for {set iRep 0} {$iRep < $NREP} {incr iRep} {
74 set lRowid [db eval {SELECT rowid FROM t1}]
75 for {set iDel 0} {$iDel < $nDeletePerRep} {incr iDel} {
76 set idx [select_one $lRowid]
78 DELETE FROM t1 WHERE rowid=$idx
83 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$nDeletePerRep
85 INSERT INTO t1 SELECT document() FROM s;
87 do_execsql_test 1.2.$iRep {
88 INSERT INTO t1(t1) VALUES('integrity-check');
93 db func document [list get_document 12]
95 CREATE VIRTUAL TABLE t1 USING fts5(body);
96 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
97 INSERT INTO t1(t1, rank) VALUES('pgsz', 128);
101 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$NDOC
103 INSERT INTO t1 SELECT document() FROM s;
105 for {set ii 0} {$ii < $NDOC} {incr ii} {
106 set lRowid [db eval {SELECT rowid FROM t1}]
107 set idx [select_one $lRowid]
108 db eval { DELETE FROM t1 WHERE rowid=$idx }
109 do_execsql_test 2.2.$ii {
110 INSERT INTO t1(t1) VALUES('integrity-check');