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/fts5secure6.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 / fts5secure6.test` 141 lines ยท 3259 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 13 source [file join [file dirname [info script]] fts5_common.tcl] 14 ifcapable !fts5 { finish_test ; return } 15 set ::testprefix fts5secure6 16 17 db progress 1 progress_handler 18 set ::PHC 0 19 proc progress_handler {args} { 20 incr ::PHC 21 # if {($::PHC % 100000)==0} breakpoint 22 return 0 23 } 24 25 proc setup {} { 26 db eval { 27 DROP TABLE IF EXISTS t1; 28 CREATE VIRTUAL TABLE t1 USING fts5(x); 29 WITH s(i) AS ( 30 VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 31 ) 32 INSERT INTO t1 SELECT 'a b c d e f g h i j k' FROM s; 33 } 34 } 35 36 foreach {tn sd} { 37 1 0 38 2 1 39 } { 40 setup 41 do_execsql_test 1.$tn.0 { 42 INSERT INTO t1(t1, rank) VALUES('secure-delete', $sd) 43 } 44 set PHC 0 45 do_execsql_test 1.$tn.1 { DELETE FROM t1; } 46 set phc($tn) $PHC 47 } 48 49 do_test 1.3 { 50 expr $phc(1)*5 < $phc(2) 51 } {1} 52 53 #------------------------------------------------------------------------- 54 reset_db 55 56 do_execsql_test 2.0 { 57 CREATE VIRTUAL TABLE t1 USING fts5(x); 58 INSERT INTO t1(t1, rank) VALUES('secure-delete', $sd) 59 } 60 61 do_execsql_test 2.1 { 62 BEGIN; 63 INSERT INTO t1(rowid, x) VALUES(-100000, 'abc def ghi'); 64 INSERT INTO t1(rowid, x) VALUES(-99999, 'abc def ghi'); 65 INSERT INTO t1(rowid, x) VALUES(`9223372036854775800`, 'abc def ghi'); 66 COMMIT; 67 } 68 69 do_execsql_test 2.2 { 70 SELECT rowid FROM t1('def') 71 } {-100000 -99999 `9223372036854775800`} 72 73 #------------------------------------------------------------------------- 74 reset_db 75 76 do_execsql_test 3.0 { 77 CREATE VIRTUAL TABLE t1 USING fts5(x); 78 INSERT INTO t1(t1, rank) VALUES('secure-delete', $sd) 79 } 80 81 do_execsql_test 3.1 { 82 BEGIN; 83 INSERT INTO t1(rowid, x) 84 VALUES(51869, 'when whenever where weress what turn'), 85 (51871, 'to were'); 86 COMMIT; 87 } 88 89 do_execsql_test 3.2 { 90 DELETE FROM t1 WHERE rowid=51871; 91 INSERT INTO t1(t1) VALUES('integrity-check'); 92 } 93 94 #------------------------------------------------------------------------- 95 reset_db 96 97 do_execsql_test 4.0 { 98 CREATE VIRTUAL TABLE t1 USING fts5(x); 99 INSERT INTO t1(rowid, x) VALUES(10, 'one two'); 100 } 101 do_execsql_test 4.1 { 102 UPDATE t1 SET x = 'one three' WHERE rowid=10; 103 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1); 104 } 105 do_execsql_test 4.2 { 106 DELETE FROM t1 WHERE rowid=10; 107 } 108 do_execsql_test 4.3 { 109 INSERT INTO t1(t1) VALUES('integrity-check'); 110 } 111 112 #------------------------------------------------------------------------- 113 reset_db 114 115 do_execsql_test 5.0 { 116 CREATE VIRTUAL TABLE t1 USING fts5(content); 117 118 INSERT INTO t1(t1,rank) VALUES('secure-delete',1); 119 INSERT INTO t1 VALUES('active'),('boomer'),('atom'),('atomic'), 120 ('alpha channel backup abandon test aback boomer atom alpha active'); 121 DELETE FROM t1 WHERE t1 MATCH 'abandon'; 122 } 123 124 do_execsql_test 5.1 { 125 INSERT INTO t1(t1) VALUES('rebuild'); 126 } 127 128 do_execsql_test 5.2 { 129 DELETE FROM t1 WHERE rowid NOTNULL<5; 130 } 131 132 db close 133 sqlite3 db test.db 134 135 do_execsql_test 5.3 { 136 PRAGMA integrity_check; 137 } {ok} 138 139 140 finish_test 141