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