File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,4 +24,30 @@ class Issue1838Tests: GRDBTestCase {
2424 }
2525 XCTAssertEqual ( documentCount, 0 )
2626 }
27+
28+ /// Tests about how we handle the FTS5 bug <https://sqlite.org/forum/forumpost/95413eb410>
29+ func test_interrupted_commit( ) throws {
30+ let dbQueue = try makeDatabaseQueue ( )
31+
32+ try dbQueue. write { db in
33+ try db. execute ( sql: " CREATE VIRTUAL TABLE documents USING FTS5(content) " )
34+ }
35+
36+ do {
37+ try dbQueue. write { db in
38+ try db. execute ( sql: " INSERT INTO documents(content) VALUES ('Document') " )
39+ dbQueue. interrupt ( )
40+ }
41+ // Do not assert that the above code throws, because the
42+ // FTS5 bug might be fixed in the tested SQLite version.
43+ } catch DatabaseError . SQLITE_INTERRUPT {
44+ // Fine: That's the FTS5 bug.
45+ }
46+
47+ // Make sure the interrupted state created by the FTS5 bug is no longer active.
48+ let documentCount = try dbQueue. read { db in
49+ try Int . fetchOne ( db, sql: " SELECT COUNT(*) FROM documents " ) !
50+ }
51+ XCTAssertEqual ( documentCount, 0 )
52+ }
2753}
You can’t perform that action at this time.
0 commit comments