SQLite Forum

Cancelling the query
Login
The flag set by sqlite3_interrupt() is checked when the VDBE code loops, which is during sqlite3_step() operation. There will be no interruption of prepare and certainly not of finalize.

Nothing untoward happens to SQLite library managed state. The usual rules apply to the user helping the library do so.

If you cannot be sure that a connection may become closed just before calling sqlite3_interrupt(), then using the sqlite3_progress_handler() interface would be a safer way to effect interruption. The progress callback can cause the VDBE execution in progress to be stopped, with no danger of the connection being closed while the callback runs.