sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / fts5 / test / fts5secure2.test
| 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 fts5secure2 |
| 16 | |
| 17 | do_execsql_test 1.0 { |
| 18 | CREATE VIRTUAL TABLE ft USING fts5(col); |
| 19 | INSERT INTO ft VALUES('data for the table'); |
| 20 | INSERT INTO ft VALUES('more of the same'); |
| 21 | INSERT INTO ft VALUES('and extra data'); |
| 22 | } |
| 23 | |
| 24 | do_execsql_test 1.1 { |
| 25 | SELECT * FROM ft_config |
| 26 | } {version 4} |
| 27 | |
| 28 | do_execsql_test 1.2 { |
| 29 | INSERT INTO ft(ft, rank) VALUES('secure-delete', 1); |
| 30 | SELECT * FROM ft_config; |
| 31 | } {secure-delete 1 version 4} |
| 32 | |
| 33 | do_execsql_test 1.3 { |
| 34 | INSERT INTO ft(ft, rank) VALUES('secure-delete', 1); |
| 35 | SELECT * FROM ft_config; |
| 36 | } {secure-delete 1 version 4} |
| 37 | |
| 38 | do_execsql_test 1.4 { |
| 39 | DELETE FROM ft WHERE rowid=2; |
| 40 | SELECT * FROM ft_config; |
| 41 | } {secure-delete 1 version 5} |
| 42 | |
| 43 | do_execsql_test 1.5 { |
| 44 | SELECT rowid, col FROM ft('data'); |
| 45 | } {1 {data for the table} 3 {and extra data}} |
| 46 | |
| 47 | db close |
| 48 | sqlite3 db test.db |
| 49 | |
| 50 | do_execsql_test 1.6 { |
| 51 | SELECT rowid, col FROM ft('data'); |
| 52 | } {1 {data for the table} 3 {and extra data}} |
| 53 | |
| 54 | #------------------------------------------------------------------------ |
| 55 | |
| 56 | reset_db |
| 57 | do_execsql_test 2.0 { |
| 58 | CREATE VIRTUAL TABLE ft USING fts5(col); |
| 59 | INSERT INTO ft VALUES('one zero one one zero'); |
| 60 | INSERT INTO ft(ft, rank) VALUES('secure-delete', 1); |
| 61 | } |
| 62 | |
| 63 | do_execsql_test 2.1 { |
| 64 | SELECT count(*) FROM ft_data WHERE block=X'00000004'; |
| 65 | } {0} |
| 66 | |
| 67 | do_execsql_test 2.2 { |
| 68 | UPDATE ft SET col = 'zero one zero zero one' WHERE rowid=1; |
| 69 | } |
| 70 | |
| 71 | do_execsql_test 2.3 { |
| 72 | SELECT count(*) FROM ft_data WHERE block=X'00000004'; |
| 73 | } {1} |
| 74 | |
| 75 | do_execsql_test 2.4 { |
| 76 | INSERT INTO ft VALUES('one zero zero one'); |
| 77 | DELETE FROM ft WHERE rowid=1; |
| 78 | } |
| 79 | |
| 80 | do_execsql_test 2.5 { |
| 81 | SELECT count(*) FROM ft_data WHERE block=X'00000004'; |
| 82 | } {2} |
| 83 | |
| 84 | |
| 85 | finish_test |
| 86 | |
| 87 |