fts5savepoint.test 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # 2019 Dec 26
  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. set testprefix fts5savepoint
  14. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  15. ifcapable !fts5 {
  16. finish_test
  17. return
  18. }
  19. do_execsql_test 1.0 {
  20. CREATE VIRTUAL TABLE ft USING fts5(c);
  21. BEGIN;
  22. SAVEPOINT one;
  23. INSERT INTO ft VALUES('a');
  24. SAVEPOINT two;
  25. INSERT INTO ft VALUES('b');
  26. RELEASE two;
  27. SAVEPOINT four;
  28. INSERT INTO ft VALUES('c');
  29. RELEASE four;
  30. SAVEPOINT three;
  31. INSERT INTO ft VALUES('d');
  32. ROLLBACK TO three;
  33. COMMIT;
  34. SELECT * FROM ft
  35. } {a b c}
  36. reset_db
  37. do_catchsql_test 2.0 {
  38. CREATE VIRTUAL TABLE ft1 USING fts5(c);
  39. CREATE VIRTUAL TABLE ft2 USING fts5(c);
  40. DROP TABLE ft2_idx;
  41. BEGIN;
  42. INSERT INTO ft2 VALUES('a');
  43. INSERT INTO ft1 VALUES('a');
  44. SAVEPOINT two;
  45. INSERT INTO ft1 VALUES('b');
  46. COMMIT;
  47. } {1 {SQL logic error}}
  48. reset_db
  49. ifcapable fts3 {
  50. do_execsql_test 3.0 {
  51. CREATE VIRTUAL TABLE vt0 USING fts5(c0);
  52. CREATE VIRTUAL TABLE vt1 USING fts4(c0);
  53. INSERT INTO vt1(c0) VALUES(0);
  54. }
  55. do_execsql_test 3.1 {
  56. BEGIN;
  57. UPDATE vt1 SET c0 = 0;
  58. INSERT INTO vt1(c0) VALUES (0), (0);
  59. UPDATE vt0 SET c0 = 0;
  60. INSERT INTO vt1(c0) VALUES (0);
  61. UPDATE vt1 SET c0 = 0;
  62. INSERT INTO vt1(vt1) VALUES('automerge=1');
  63. UPDATE vt1 SET c0 = 0;
  64. }
  65. do_catchsql_test 3.2 {
  66. DROP TABLE vt1;
  67. } {0 {}}
  68. do_execsql_test 3.3 {
  69. SAVEPOINT x;
  70. INSERT INTO vt0 VALUES('x');
  71. COMMIT;
  72. INSERT INTO vt0(vt0) VALUES('integrity-check');
  73. }
  74. }
  75. finish_test