Debian Codegraph @

ext/fts5/test/fts5secure8.test

raw
1 # 2023 Nov 23
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 fts5secure8
16
17 proc sql_repeat {txt n} {
18 string repeat $txt $n
19 }
20 db func repeat sql_repeat
21
22 do_execsql_test 1.0 {
23 CREATE VIRTUAL TABLE ft USING fts5(x);
24
25 INSERT INTO ft(ft, rank) VALUES('pgsz', 64);
26
27 INSERT INTO ft(rowid, x) VALUES(100, 'hello world');
28 INSERT INTO ft(rowid, x) VALUES(200, 'one day');
29
30 BEGIN;
31 INSERT INTO ft(rowid, x) VALUES(45, 'one two three');
32 UPDATE ft SET x = repeat('hello world ', 500) WHERE rowid=100;
33 COMMIT
34 }
35
36 do_execsql_test 1.1 {
37 INSERT INTO ft(ft, rank) VALUES('secure-delete', 1);
38 DELETE FROM ft WHERE rowid=100;
39 }
40
41 do_execsql_test 1.2 {
42 PRAGMA integrity_check;
43 } {ok}
44
45 do_execsql_test 2.0 {
46 CREATE VIRTUAL TABLE xyz USING fts5 (
47 name,
48 content=''
49 );
50
51 INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 1);
52 INSERT INTO xyz (rowid, name) VALUES(1, 'A');
53 INSERT INTO xyz (rowid, name) VALUES(2, 'A');
54 INSERT INTO xyz(xyz, rowid, name) VALUES('delete', 2, 'A');
55 }
56
57 do_execsql_test 2.1 {
58 pragma quick_check;
59 } {ok}
60
61 do_catchsql_test 2.2 {
62 INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 'hello world');
63 } {1 {SQL logic error}}
64
65
66
67
68
69 finish_test
70
71