fts5secure8.test 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. source [file join [file dirname [info script]] fts5_common.tcl]
  13. ifcapable !fts5 { finish_test ; return }
  14. set ::testprefix fts5secure8
  15. proc sql_repeat {txt n} {
  16. string repeat $txt $n
  17. }
  18. db func repeat sql_repeat
  19. do_execsql_test 1.0 {
  20. CREATE VIRTUAL TABLE ft USING fts5(x);
  21. INSERT INTO ft(ft, rank) VALUES('pgsz', 64);
  22. INSERT INTO ft(rowid, x) VALUES(100, 'hello world');
  23. INSERT INTO ft(rowid, x) VALUES(200, 'one day');
  24. BEGIN;
  25. INSERT INTO ft(rowid, x) VALUES(45, 'one two three');
  26. UPDATE ft SET x = repeat('hello world ', 500) WHERE rowid=100;
  27. COMMIT
  28. }
  29. do_execsql_test 1.1 {
  30. INSERT INTO ft(ft, rank) VALUES('secure-delete', 1);
  31. DELETE FROM ft WHERE rowid=100;
  32. }
  33. do_execsql_test 1.2 {
  34. PRAGMA integrity_check;
  35. } {ok}
  36. do_execsql_test 2.0 {
  37. CREATE VIRTUAL TABLE xyz USING fts5 (
  38. name,
  39. content=''
  40. );
  41. INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 1);
  42. INSERT INTO xyz (rowid, name) VALUES(1, 'A');
  43. INSERT INTO xyz (rowid, name) VALUES(2, 'A');
  44. INSERT INTO xyz(xyz, rowid, name) VALUES('delete', 2, 'A');
  45. }
  46. do_execsql_test 2.1 {
  47. pragma quick_check;
  48. } {ok}
  49. do_catchsql_test 2.2 {
  50. INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 'hello world');
  51. } {1 {SQL logic error}}
  52. finish_test