@@ -5779,6 +5779,8 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
57795779SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
57805780
57815781
5782+ SQLITE_API void libsql_stmt_interrupt(sqlite3_stmt *stmt);
5783+
57825784/*
57835785** CAPI3REF: Create Or Redefine SQL Functions
57845786** KEYWORDS: {function creation routines}
@@ -24195,6 +24197,7 @@ struct Vdbe {
2419524197 int nScan; /* Entries in aScan[] */
2419624198 ScanStatus *aScan; /* Scan definitions for sqlite3_stmt_scanstatus() */
2419724199#endif
24200+ u8 isInterrupted; /* True if the statement has been interrupted */
2419824201};
2419924202
2420024203void libsql_inc_row_read(Vdbe *p, int count);
@@ -67644,9 +67647,11 @@ static int walCheckpoint(
6764467647 if (xCb) {
6764567648 rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
6764667649 }
67647- i64 szDb = pWal->hdr.nPage*(i64)szPage;
67648- testcase( IS_BIG_INT(szDb) );
67649- rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
67650+ if( rc==SQLITE_OK ){
67651+ i64 szDb = pWal->hdr.nPage*(i64)szPage;
67652+ testcase( IS_BIG_INT(szDb) );
67653+ rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
67654+ }
6765067655 if( rc==SQLITE_OK ){
6765167656 rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
6765267657 }
@@ -89473,6 +89478,7 @@ SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){
8947389478#ifdef SQLITE_DEBUG
8947489479 p->nWrite = 0;
8947589480#endif
89481+ p->isInterrupted = 0;
8947689482
8947789483 /* Save profiling information from this VDBE run.
8947889484 */
@@ -92277,6 +92283,18 @@ static int sqlite3Step(Vdbe *p){
9227792283 return (rc&db->errMask);
9227892284}
9227992285
92286+ /*
92287+ ** Interrupt the statement.
92288+ */
92289+ void libsql_stmt_interrupt(sqlite3_stmt *pStmt){
92290+ Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
92291+ if( vdbeSafetyNotNull(v) ){
92292+ (void)SQLITE_MISUSE_BKPT;
92293+ return;
92294+ }
92295+ v->isInterrupted = 1;
92296+ }
92297+
9228092298/*
9228192299** This is the top-level implementation of sqlite3_step(). Call
9228292300** sqlite3Step() to do most of the work. If a schema error occurs,
@@ -92291,6 +92309,9 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
9229192309 if( vdbeSafetyNotNull(v) ){
9229292310 return SQLITE_MISUSE_BKPT;
9229392311 }
92312+ if( v->isInterrupted ){
92313+ return SQLITE_INTERRUPT;
92314+ }
9229492315 db = v->db;
9229592316 sqlite3_mutex_enter(db->mutex);
9229692317 while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
0 commit comments