fts5secure2.test 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. source [file join [file dirname [info script]] fts5_common.tcl]
  13. ifcapable !fts5 { finish_test ; return }
  14. set ::testprefix fts5secure2
  15. do_execsql_test 1.0 {
  16. CREATE VIRTUAL TABLE ft USING fts5(col);
  17. INSERT INTO ft VALUES('data for the table');
  18. INSERT INTO ft VALUES('more of the same');
  19. INSERT INTO ft VALUES('and extra data');
  20. }
  21. do_execsql_test 1.1 {
  22. SELECT * FROM ft_config
  23. } {version 4}
  24. do_execsql_test 1.2 {
  25. INSERT INTO ft(ft, rank) VALUES('secure-delete', 1);
  26. SELECT * FROM ft_config;
  27. } {secure-delete 1 version 4}
  28. do_execsql_test 1.3 {
  29. INSERT INTO ft(ft, rank) VALUES('secure-delete', 1);
  30. SELECT * FROM ft_config;
  31. } {secure-delete 1 version 4}
  32. do_execsql_test 1.4 {
  33. DELETE FROM ft WHERE rowid=2;
  34. SELECT * FROM ft_config;
  35. } {secure-delete 1 version 5}
  36. do_execsql_test 1.5 {
  37. SELECT rowid, col FROM ft('data');
  38. } {1 {data for the table} 3 {and extra data}}
  39. db close
  40. sqlite3 db test.db
  41. do_execsql_test 1.6 {
  42. SELECT rowid, col FROM ft('data');
  43. } {1 {data for the table} 3 {and extra data}}
  44. #------------------------------------------------------------------------
  45. reset_db
  46. do_execsql_test 2.0 {
  47. CREATE VIRTUAL TABLE ft USING fts5(col);
  48. INSERT INTO ft VALUES('one zero one one zero');
  49. INSERT INTO ft(ft, rank) VALUES('secure-delete', 1);
  50. }
  51. do_execsql_test 2.1 {
  52. SELECT count(*) FROM ft_data WHERE block=X'00000004';
  53. } {0}
  54. do_execsql_test 2.2 {
  55. UPDATE ft SET col = 'zero one zero zero one' WHERE rowid=1;
  56. }
  57. do_execsql_test 2.3 {
  58. SELECT count(*) FROM ft_data WHERE block=X'00000004';
  59. } {1}
  60. do_execsql_test 2.4 {
  61. INSERT INTO ft VALUES('one zero zero one');
  62. DELETE FROM ft WHERE rowid=1;
  63. }
  64. do_execsql_test 2.5 {
  65. SELECT count(*) FROM ft_data WHERE block=X'00000004';
  66. } {2}
  67. finish_test