fts5interrupt.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # 2019 Jan 4
  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. # This file implements regression tests for SQLite library. The
  12. # focus of this script is testing the FTS5 module.
  13. #
  14. source [file join [file dirname [info script]] fts5_common.tcl]
  15. set testprefix fts5interrupt
  16. # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
  17. ifcapable !fts5 {
  18. finish_test
  19. return
  20. }
  21. do_execsql_test 1.0 {
  22. CREATE VIRTUAL TABLE t1 USING fts5(a);
  23. INSERT INTO t1(t1, rank) VALUES('pgsz', 40);
  24. }
  25. db_save_and_close
  26. proc progress_handler {args} {
  27. incr ::progress_handler_delay -1
  28. if {$::progress_handler_delay<=0} { return 1 }
  29. return 0
  30. }
  31. unset -nocomplain res
  32. foreach {tn sql} {
  33. 1 { INSERT INTO t1(rowid, a) VALUES(0, 'z z z z') }
  34. 2 { COMMIT }
  35. } {
  36. set bDone 0
  37. for {set i 1} {$bDone==0} {incr i} {
  38. do_test 1.$tn.$i {
  39. db_restore_and_reopen
  40. execsql {
  41. BEGIN;
  42. INSERT INTO t1(rowid, a) VALUES(1, 'a b c d');
  43. INSERT INTO t1(rowid, a) VALUES(2, 'd e f g');
  44. INSERT INTO t1(rowid, a) VALUES(3, 'h i j k');
  45. INSERT INTO t1(rowid, a) VALUES(4, 'l m n o');
  46. }
  47. set ::progress_handler_delay $i
  48. db progress 1 progress_handler
  49. set res [catchsql $sql]
  50. db close
  51. if {$res=="0 {}"} {
  52. set bDone 1
  53. } else {
  54. if {$res!="1 interrupted"} { error "got: $res" }
  55. }
  56. set {} {}
  57. } {}
  58. }
  59. }
  60. finish_test