SQLite User Forum

Cancelling the query
Login
Hi, Larry,

> 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.

That's understandable.

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

OK, so I will still have to finalize the statement right?

> 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.

Its not about closed connection.

Like I said I am running a thread checking if a new table is created by querying sqlite_master. And then I want to run another thread where I will execute SELECT FROM abc; When I hit ESC I want to interrupt the second SELECT statement. I want the first thread to keep running querying the sqlite_master.

So it looks like the way to go is to use progress_handler().

Thank you.