| 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 |
|
| 15 |
source [file join [file dirname [info script]] fts5_common.tcl] |
| 16 |
set testprefix fts5interrupt |
| 17 |
|
| 18 |
# If SQLITE_ENABLE_FTS5 is not defined, omit this file. |
| 19 |
ifcapable !fts5 { |
| 20 |
finish_test |
| 21 |
return |
| 22 |
} |
| 23 |
|
| 24 |
do_execsql_test 1.0 { |
| 25 |
CREATE VIRTUAL TABLE t1 USING fts5(a); |
| 26 |
INSERT INTO t1(t1, rank) VALUES('pgsz', 40); |
| 27 |
} |
| 28 |
db_save_and_close |
| 29 |
|
| 30 |
proc progress_handler {args} { |
| 31 |
incr ::progress_handler_delay -1 |
| 32 |
if {$::progress_handler_delay<=0} { return 1 } |
| 33 |
return 0 |
| 34 |
} |
| 35 |
|
| 36 |
unset -nocomplain res |
| 37 |
foreach {tn sql} { |
| 38 |
1 { INSERT INTO t1(rowid, a) VALUES(0, 'z z z z') } |
| 39 |
2 { COMMIT } |
| 40 |
} { |
| 41 |
set bDone 0 |
| 42 |
for {set i 1} {$bDone==0} {incr i} { |
| 43 |
do_test 1.$tn.$i { |
| 44 |
db_restore_and_reopen |
| 45 |
execsql { |
| 46 |
BEGIN; |
| 47 |
INSERT INTO t1(rowid, a) VALUES(1, 'a b c d'); |
| 48 |
INSERT INTO t1(rowid, a) VALUES(2, 'd e f g'); |
| 49 |
INSERT INTO t1(rowid, a) VALUES(3, 'h i j k'); |
| 50 |
INSERT INTO t1(rowid, a) VALUES(4, 'l m n o'); |
| 51 |
} |
| 52 |
|
| 53 |
set ::progress_handler_delay $i |
| 54 |
db progress 1 progress_handler |
| 55 |
set res [catchsql $sql] |
| 56 |
db close |
| 57 |
if {$res=="0 {}"} { |
| 58 |
set bDone 1 |
| 59 |
} else { |
| 60 |
if {$res!="1 interrupted"} { error "got: $res" } |
| 61 |
} |
| 62 |
set {} {} |
| 63 |
} {} |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
#------------------------------------------------------------------------- |
| 68 |
# Verify that https://sqlite.org/forum/forumpost/95413eb410 has been |
| 69 |
# fixed. |
| 70 |
# |
| 71 |
reset_db |
| 72 |
do_execsql_test 2.0 { |
| 73 |
CREATE VIRTUAL TABLE f1 USING fts5(x); |
| 74 |
BEGIN TRANSACTION; |
| 75 |
INSERT INTO f1(x) VALUES('abc def ghi'); |
| 76 |
} |
| 77 |
do_test 2.1 { |
| 78 |
sqlite3_interrupt db |
| 79 |
} {} |
| 80 |
do_execsql_test 2.2 { |
| 81 |
ROLLBACK |
| 82 |
} |
| 83 |
|
| 84 |
finish_test |