mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add a new sqlite3_is_interrupted() interface that can be used by long-running
app-defined functions and similar to see if they need to exit early due to an sqlite3_interrupt() call. FossilOrigin-Name: d030f341369b7f32789cbcf3d0ad9a2ac5cad99a56dac7dfe68b7f06dc339b17
This commit is contained in:
19
src/main.c
19
src/main.c
@@ -1796,7 +1796,9 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){
|
||||
*/
|
||||
void sqlite3_interrupt(sqlite3 *db){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db) && (db==0 || db->eOpenState!=SQLITE_STATE_ZOMBIE) ){
|
||||
if( !sqlite3SafetyCheckOk(db)
|
||||
&& (db==0 || db->eOpenState!=SQLITE_STATE_ZOMBIE)
|
||||
){
|
||||
(void)SQLITE_MISUSE_BKPT;
|
||||
return;
|
||||
}
|
||||
@@ -1804,6 +1806,21 @@ void sqlite3_interrupt(sqlite3 *db){
|
||||
AtomicStore(&db->u1.isInterrupted, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true or false depending on whether or not an interrupt is
|
||||
** pending on connection db.
|
||||
*/
|
||||
int sqlite3_is_interrupted(sqlite3 *db){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db)
|
||||
&& (db==0 || db->eOpenState!=SQLITE_STATE_ZOMBIE)
|
||||
){
|
||||
(void)SQLITE_MISUSE_BKPT;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return AtomicLoad(&db->u1.isInterrupted)!=0;
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is exactly the same as sqlite3_create_function(), except
|
||||
|
Reference in New Issue
Block a user