diff options
author | drh <> | 2023-01-11 00:27:06 +0000 |
---|---|---|
committer | drh <> | 2023-01-11 00:27:06 +0000 |
commit | 3b7a19b033a8177e0897ee5e9799f0dea480265c (patch) | |
tree | 552c2f15d826f31512772592bdd127353b6de2bc /src/test1.c | |
parent | 706631de32efdc9c043f1b8822040ce41eaf756c (diff) | |
download | sqlite-3b7a19b033a8177e0897ee5e9799f0dea480265c.tar.gz sqlite-3b7a19b033a8177e0897ee5e9799f0dea480265c.zip |
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
Diffstat (limited to 'src/test1.c')
-rw-r--r-- | src/test1.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/test1.c b/src/test1.c index a314e90d8..dda77a90a 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5537,7 +5537,6 @@ static int SQLITE_TCLAPI test_stmt_int( return TCL_OK; } - /* ** Usage: sqlite3_interrupt DB ** @@ -5560,6 +5559,29 @@ static int SQLITE_TCLAPI test_interrupt( } /* +** Usage: sqlite3_is_interrupted DB +** +** return true if an interrupt is current in effect on DB +*/ +static int SQLITE_TCLAPI test_is_interrupted( + void * clientData, + Tcl_Interp *interp, + int argc, + char **argv +){ + sqlite3 *db; + int rc; + if( argc!=2 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB", 0); + return TCL_ERROR; + } + if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; + rc = sqlite3_is_interrupted(db); + Tcl_AppendResult(interp, rc ? "1" : "0", (void*)0); + return TCL_OK; +} + +/* ** Usage: sqlite_delete_function DB function-name ** ** Delete the user function 'function-name' from database handle DB. It @@ -8631,6 +8653,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_key", (Tcl_CmdProc*)test_key }, { "sqlite3_rekey", (Tcl_CmdProc*)test_rekey }, { "sqlite3_interrupt", (Tcl_CmdProc*)test_interrupt }, + { "sqlite3_is_interrupted", (Tcl_CmdProc*)test_is_interrupted }, { "sqlite_delete_function", (Tcl_CmdProc*)delete_function }, { "sqlite_delete_collation", (Tcl_CmdProc*)delete_collation }, { "sqlite3_get_autocommit", (Tcl_CmdProc*)get_autocommit }, |