1.Dd January 24, 2024 2.Dt SQLITE3_INTERRUPT 3 3.Os 4.Sh NAME 5.Nm sqlite3_interrupt , 6.Nm sqlite3_is_interrupted 7.Nd interrupt a long-Running query 8.Sh SYNOPSIS 9.In sqlite3.h 10.Ft void 11.Fo sqlite3_interrupt 12.Fa "sqlite3*" 13.Fc 14.Ft int 15.Fo sqlite3_is_interrupted 16.Fa "sqlite3*" 17.Fc 18.Sh DESCRIPTION 19This function causes any pending database operation to abort and return 20at its earliest opportunity. 21This routine is typically called in response to a user action such 22as pressing "Cancel" or Ctrl-C where the user wants a long query operation 23to halt immediately. 24.Pp 25It is safe to call this routine from a thread different from the thread 26that is currently running the database operation. 27But it is not safe to call this routine with a database connection 28that is closed or might close before sqlite3_interrupt() returns. 29.Pp 30If an SQL operation is very nearly finished at the time when sqlite3_interrupt() 31is called, then it might not have an opportunity to be interrupted 32and might continue to completion. 33.Pp 34An SQL operation that is interrupted will return SQLITE_INTERRUPT. 35If the interrupted SQL operation is an INSERT, UPDATE, or DELETE that 36is inside an explicit transaction, then the entire transaction will 37be rolled back automatically. 38.Pp 39The sqlite3_interrupt(D) call is in effect until all currently running 40SQL statements on database connection D complete. 41Any new SQL statements that are started after the sqlite3_interrupt() 42call and before the running statement count reaches zero are interrupted 43as if they had been running prior to the sqlite3_interrupt() call. 44New SQL statements that are started after the running statement count 45reaches zero are not effected by the sqlite3_interrupt(). 46A call to sqlite3_interrupt(D) that occurs when there are no running 47SQL statements is a no-op and has no effect on SQL statements that 48are started after the sqlite3_interrupt() call returns. 49.Pp 50The sqlite3_is_interrupted(D) interface can 51be used to determine whether or not an interrupt is currently in effect 52for database connection D. 53It returns 1 if an interrupt is currently in effect, or 0 otherwise. 54.Sh IMPLEMENTATION NOTES 55These declarations were extracted from the 56interface documentation at line 2703. 57.Bd -literal 58SQLITE_API void sqlite3_interrupt(sqlite3*); 59SQLITE_API int sqlite3_is_interrupted(sqlite3*); 60.Ed 61.Sh SEE ALSO 62.Xr sqlite3 3 , 63.Xr SQLITE_OK 3 64