@@ -5779,6 +5779,8 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
5779
5779
SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
5780
5780
5781
5781
5782
+ SQLITE_API void libsql_stmt_interrupt(sqlite3_stmt *stmt);
5783
+
5782
5784
/*
5783
5785
** CAPI3REF: Create Or Redefine SQL Functions
5784
5786
** KEYWORDS: {function creation routines}
@@ -24195,6 +24197,7 @@ struct Vdbe {
24195
24197
int nScan; /* Entries in aScan[] */
24196
24198
ScanStatus *aScan; /* Scan definitions for sqlite3_stmt_scanstatus() */
24197
24199
#endif
24200
+ u8 isInterrupted; /* True if the statement has been interrupted */
24198
24201
};
24199
24202
24200
24203
void libsql_inc_row_read(Vdbe *p, int count);
@@ -67644,9 +67647,11 @@ static int walCheckpoint(
67644
67647
if (xCb) {
67645
67648
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
67646
67649
}
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
+ }
67650
67655
if( rc==SQLITE_OK ){
67651
67656
rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
67652
67657
}
@@ -89473,6 +89478,7 @@ SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){
89473
89478
#ifdef SQLITE_DEBUG
89474
89479
p->nWrite = 0;
89475
89480
#endif
89481
+ p->isInterrupted = 0;
89476
89482
89477
89483
/* Save profiling information from this VDBE run.
89478
89484
*/
@@ -92277,6 +92283,18 @@ static int sqlite3Step(Vdbe *p){
92277
92283
return (rc&db->errMask);
92278
92284
}
92279
92285
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
+
92280
92298
/*
92281
92299
** This is the top-level implementation of sqlite3_step(). Call
92282
92300
** sqlite3Step() to do most of the work. If a schema error occurs,
@@ -92291,6 +92309,9 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
92291
92309
if( vdbeSafetyNotNull(v) ){
92292
92310
return SQLITE_MISUSE_BKPT;
92293
92311
}
92312
+ if( v->isInterrupted ){
92313
+ return SQLITE_INTERRUPT;
92314
+ }
92294
92315
db = v->db;
92295
92316
sqlite3_mutex_enter(db->mutex);
92296
92317
while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
0 commit comments