fts5rebuild.test 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # 2014 Dec 20
  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. set testprefix fts5rebuild
  15. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  16. ifcapable !fts5 {
  17. finish_test
  18. return
  19. }
  20. do_execsql_test 1.1 {
  21. CREATE VIRTUAL TABLE f1 USING fts5(a, b);
  22. INSERT INTO f1(a, b) VALUES('one', 'o n e');
  23. INSERT INTO f1(a, b) VALUES('two', 't w o');
  24. INSERT INTO f1(a, b) VALUES('three', 't h r e e');
  25. }
  26. do_execsql_test 1.2 {
  27. INSERT INTO f1(f1) VALUES('integrity-check');
  28. } {}
  29. do_execsql_test 1.3 {
  30. INSERT INTO f1(f1) VALUES('rebuild');
  31. } {}
  32. do_execsql_test 1.4 {
  33. INSERT INTO f1(f1) VALUES('integrity-check');
  34. } {}
  35. sqlite3_db_config db DEFENSIVE 0
  36. do_execsql_test 1.5 {
  37. DELETE FROM f1_data;
  38. } {}
  39. do_catchsql_test 1.6 {
  40. INSERT INTO f1(f1) VALUES('integrity-check');
  41. } {1 {database disk image is malformed}}
  42. do_execsql_test 1.7 {
  43. INSERT INTO f1(f1) VALUES('rebuild');
  44. INSERT INTO f1(f1) VALUES('integrity-check');
  45. } {}
  46. #-------------------------------------------------------------------------
  47. # Check that 'rebuild' may not be used with a contentless table.
  48. #
  49. do_execsql_test 2.1 {
  50. CREATE VIRTUAL TABLE nc USING fts5(doc, content=);
  51. }
  52. do_catchsql_test 2.2 {
  53. INSERT INTO nc(nc) VALUES('rebuild');
  54. } {1 {'rebuild' may not be used with a contentless fts5 table}}
  55. finish_test