Skip to content

Commit ed837f0

Browse files
committed
libsql: Add Statement::interrupt()
1 parent 867c3f1 commit ed837f0

File tree

7 files changed

+37
-0
lines changed

7 files changed

+37
-0
lines changed

libsql-sys/src/statement.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ impl Statement {
8282
unsafe { crate::ffi::sqlite3_step(self.raw_stmt) }
8383
}
8484

85+
pub fn interrupt(&self) {
86+
unsafe { crate::ffi::libsql_stmt_interrupt(self.raw_stmt) }
87+
}
88+
8589
pub fn reset(&self) -> std::ffi::c_int {
8690
unsafe { crate::ffi::sqlite3_reset(self.raw_stmt) }
8791
}

libsql/src/hrana/hyper.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ impl crate::statement::Stmt for crate::hrana::Statement<HttpSender> {
205205
self.run(params).await
206206
}
207207

208+
fn interrupt(&mut self) -> crate::Result<()> {
209+
Err(crate::Error::Misuse(
210+
"interrupt is not supported for remote connections".to_string(),
211+
))
212+
}
213+
208214
fn reset(&mut self) {}
209215

210216
fn parameter_count(&self) -> usize {

libsql/src/local/impls.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ impl Stmt for LibsqlStmt {
120120
stmt.run(&params)
121121
}
122122

123+
fn interrupt(&mut self) -> Result<()> {
124+
self.0.interrupt()
125+
}
126+
123127
fn reset(&mut self) {
124128
self.0.reset();
125129
}

libsql/src/local/statement.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ impl Statement {
134134
}
135135
}
136136

137+
/// Interrupt the statement.
138+
pub fn interrupt(&self) -> Result<()> {
139+
self.inner.interrupt();
140+
Ok(())
141+
}
142+
137143
/// Reset the prepared statement to initial state for reuse.
138144
pub fn reset(&self) {
139145
self.inner.reset();

libsql/src/replication/connection.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,12 @@ impl Stmt for RemoteStatement {
732732
Ok(())
733733
}
734734

735+
fn interrupt(&mut self) -> Result<()> {
736+
Err(Error::Misuse(
737+
"interrupt is not supported for remote connections".to_string(),
738+
))
739+
}
740+
735741
fn reset(&mut self) {}
736742

737743
fn parameter_count(&self) -> usize {

libsql/src/statement.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub(crate) trait Stmt {
1414

1515
async fn run(&mut self, params: &Params) -> Result<()>;
1616

17+
fn interrupt(&mut self) -> Result<()>;
18+
1719
fn reset(&mut self);
1820

1921
fn parameter_count(&self) -> usize;
@@ -60,6 +62,11 @@ impl Statement {
6062
Ok(())
6163
}
6264

65+
/// Interrupt the statement.
66+
pub fn interrupt(&mut self) -> Result<()> {
67+
self.inner.interrupt()
68+
}
69+
6370
/// Execute a query that returns the first [`Row`].
6471
///
6572
/// # Errors

libsql/src/sync/statement.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ impl Stmt for SyncedStatement {
4040
result
4141
}
4242

43+
fn interrupt(&mut self) -> Result<()> {
44+
self.inner.interrupt()
45+
}
46+
4347
fn reset(&mut self) {
4448
self.inner.reset()
4549
}

0 commit comments

Comments
 (0)