Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/fts5/test/fts5secure7.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / fts5 / test / fts5secure7.test` 116 lines ยท 2619 bytes Raw Blame History 1 # 2023 Feb 17 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 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. 9 # 10 #************************************************************************* 11 # 12 # TESTRUNNER: slow 13 # 14 15 source [file join [file dirname [info script]] fts5_common.tcl] 16 ifcapable !fts5 { finish_test ; return } 17 set ::testprefix fts5secure7 18 19 20 set NVOCAB 500 21 set NDOC [expr 1000] 22 23 set NREP 100 24 set nDeletePerRep [expr 5] 25 26 set VOCAB [list] 27 28 proc select_one {list} { 29 set n [llength $list] 30 lindex $list [expr {abs(int(rand()*$n))}] 31 } 32 33 proc init_vocab {} { 34 set L [split "abcdefghijklmnopqrstuvwxyz" {}] 35 set nL [llength $L] 36 for {set i 0} {$i < $::NVOCAB} {incr i} { 37 set n [expr {6 + int(rand()*8)}] 38 set word "" 39 for {set j 0} {$j < $n} {incr j} { 40 append word [select_one $L] 41 } 42 lappend ::VOCAB $word 43 } 44 } 45 46 proc get_word {} { 47 select_one $::VOCAB 48 } 49 50 proc get_document {nWord} { 51 set ret [list] 52 for {set i 0} {$i < $nWord} {incr i} { 53 lappend ret [get_word] 54 } 55 return $ret 56 } 57 58 init_vocab 59 60 db func document [list get_document 12] 61 62 do_execsql_test 1.0 { 63 CREATE VIRTUAL TABLE t1 USING fts5(body); 64 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1); 65 } 66 do_execsql_test 1.1 { 67 WITH s(i) AS ( 68 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$NDOC 69 ) 70 INSERT INTO t1 SELECT document() FROM s; 71 } 72 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] 77 db eval { 78 DELETE FROM t1 WHERE rowid=$idx 79 } 80 } 81 db eval { 82 WITH s(i) AS ( 83 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$nDeletePerRep 84 ) 85 INSERT INTO t1 SELECT document() FROM s; 86 } 87 do_execsql_test 1.2.$iRep { 88 INSERT INTO t1(t1) VALUES('integrity-check'); 89 } 90 } 91 92 reset_db 93 db func document [list get_document 12] 94 do_execsql_test 2.0 { 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); 98 } 99 do_execsql_test 2.1 { 100 WITH s(i) AS ( 101 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$NDOC 102 ) 103 INSERT INTO t1 SELECT document() FROM s; 104 } 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'); 111 } 112 } 113 114 finish_test 115 116