Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsql-sqlite: Add libsql_stmt_interrupt() API #1888

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libsql-sqlite3/src/sqlite.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5390,6 +5390,8 @@ int sqlite3_finalize(sqlite3_stmt *pStmt);
int sqlite3_reset(sqlite3_stmt *pStmt);


void libsql_stmt_interrupt(sqlite3_stmt *stmt);

/*
** CAPI3REF: Create Or Redefine SQL Functions
** KEYWORDS: {function creation routines}
Expand Down
1 change: 1 addition & 0 deletions libsql-sqlite3/src/vdbeInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ struct Vdbe {
int nScan; /* Entries in aScan[] */
ScanStatus *aScan; /* Scan definitions for sqlite3_stmt_scanstatus() */
#endif
u8 isInterrupted; /* True if the statement has been interrupted */
};

void libsql_inc_row_read(Vdbe *p, int count);
Expand Down
15 changes: 15 additions & 0 deletions libsql-sqlite3/src/vdbeapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,18 @@ static int sqlite3Step(Vdbe *p){
return (rc&db->errMask);
}

/*
** Interrupt the statement.
*/
void libsql_stmt_interrupt(sqlite3_stmt *pStmt){
Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
if( vdbeSafetyNotNull(v) ){
(void)SQLITE_MISUSE_BKPT;
return;
}
v->isInterrupted = 1;
}

/*
** This is the top-level implementation of sqlite3_step(). Call
** sqlite3Step() to do most of the work. If a schema error occurs,
Expand All @@ -902,6 +914,9 @@ int sqlite3_step(sqlite3_stmt *pStmt){
if( vdbeSafetyNotNull(v) ){
return SQLITE_MISUSE_BKPT;
}
if( v->isInterrupted ){
return SQLITE_INTERRUPT;
}
db = v->db;
sqlite3_mutex_enter(db->mutex);
while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
Expand Down
Loading