SQLite

View Ticket
Login
2014-03-11
13:13 Closed ticket [33fdaab1]: Need to cancel an integrity check in progress with sqlite3_interrupt plus 3 other changes (artifact: 6cf22fec user: drh)
2009-11-06
04:42 Ticket [33fdaab1]: 3 changes (artifact: 5b925eca user: rogerb)
04:41 New ticket [33fdaab1]. (artifact: c1ba3846 user: rogerb)

Ticket Hash: 33fdaab1a048cbdaf0e72043b70361c60613d9b4
Title: Need to cancel an integrity check in progress with sqlite3_interrupt
Status: Closed Type: Feature_Request
Severity: Minor Priority: Immediate
Subsystem: Virtual_Machine Resolution: Rejected
Last Modified: 2014-03-11 13:13:26
Version Found In: 3.6.20
Description:
http://article.gmane.org/gmane.comp.db.sqlite.general/52203

sqlite3_interrupt does not appear to cancel an integrity check (pragma integrity_check or quick_check) in progress. Given how long these checks can take on big DBs, it's nice to be able to abort them (if your app is asked to exit for example).

I've hacked in my own support for doing this, but would love to see an official version committed for a future release.

The simple fix I put in place was to add:

sqlite3_snprintf(sizeof(zContext), zContext, "Page %d: ", iPage);
/* allow checking to be aborted */
if (pCheck->pBt->db->u1.isInterrupted)
{
 checkAppendMsg(pCheck, zContext, "Check interrupted");
 return -1;
}
...near the top of: checkTreePage(...)

In practice this causes several other error messages to get appended to the check results as well, and the actual statement returns SQLITE_ROW. A better solution would be one that causes the execution to return SQLITE_INTERRUPT, but this is good enough for my case.