mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 09:09:19 +08:00
Replace execute_batch usages by execute
Because execute_batch does not support unlock_notify
This commit is contained in:
parent
a9b700c841
commit
f37519ad51
@ -256,7 +256,8 @@ impl Connection {
|
|||||||
// The two syntaxes yield identical results.
|
// The two syntaxes yield identical results.
|
||||||
sql.push_equal_sign();
|
sql.push_equal_sign();
|
||||||
sql.push_value(pragma_value)?;
|
sql.push_value(pragma_value)?;
|
||||||
self.execute_batch(&sql)
|
self.execute(&sql, NO_PARAMS)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a new value to `pragma_name` and return the updated value.
|
/// Set a new value to `pragma_name` and return the updated value.
|
||||||
|
@ -646,7 +646,7 @@ impl Statement<'_> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn check_update(&self) -> Result<()> {
|
fn check_update(&self) -> Result<()> {
|
||||||
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
||||||
if self.column_count() > 0 || self.stmt.readonly() {
|
if self.column_count() > 0 && self.stmt.readonly() {
|
||||||
return Err(Error::ExecuteReturnedResults);
|
return Err(Error::ExecuteReturnedResults);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{Connection, Result};
|
use crate::{Connection, Result, NO_PARAMS};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
/// Options for transaction behavior. See [BEGIN
|
/// Options for transaction behavior. See [BEGIN
|
||||||
@ -120,7 +120,7 @@ impl Transaction<'_> {
|
|||||||
TransactionBehavior::Immediate => "BEGIN IMMEDIATE",
|
TransactionBehavior::Immediate => "BEGIN IMMEDIATE",
|
||||||
TransactionBehavior::Exclusive => "BEGIN EXCLUSIVE",
|
TransactionBehavior::Exclusive => "BEGIN EXCLUSIVE",
|
||||||
};
|
};
|
||||||
conn.execute_batch(query).map(move |_| Transaction {
|
conn.execute(query, NO_PARAMS).map(move |_| Transaction {
|
||||||
conn,
|
conn,
|
||||||
drop_behavior: DropBehavior::Rollback,
|
drop_behavior: DropBehavior::Rollback,
|
||||||
})
|
})
|
||||||
@ -180,7 +180,7 @@ impl Transaction<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn commit_(&mut self) -> Result<()> {
|
fn commit_(&mut self) -> Result<()> {
|
||||||
self.conn.execute_batch("COMMIT")?;
|
self.conn.execute("COMMIT", NO_PARAMS)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ impl Transaction<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rollback_(&mut self) -> Result<()> {
|
fn rollback_(&mut self) -> Result<()> {
|
||||||
self.conn.execute_batch("ROLLBACK")?;
|
self.conn.execute("ROLLBACK", NO_PARAMS)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ impl Savepoint<'_> {
|
|||||||
name: T,
|
name: T,
|
||||||
) -> Result<Savepoint<'_>> {
|
) -> Result<Savepoint<'_>> {
|
||||||
let name = name.into();
|
let name = name.into();
|
||||||
conn.execute_batch(&format!("SAVEPOINT {}", name))
|
conn.execute(&format!("SAVEPOINT {}", name), NO_PARAMS)
|
||||||
.map(|_| Savepoint {
|
.map(|_| Savepoint {
|
||||||
conn,
|
conn,
|
||||||
name,
|
name,
|
||||||
@ -291,7 +291,7 @@ impl Savepoint<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn commit_(&mut self) -> Result<()> {
|
fn commit_(&mut self) -> Result<()> {
|
||||||
self.conn.execute_batch(&format!("RELEASE {}", self.name))?;
|
self.conn.execute(&format!("RELEASE {}", self.name), NO_PARAMS)?;
|
||||||
self.committed = true;
|
self.committed = true;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -304,7 +304,8 @@ impl Savepoint<'_> {
|
|||||||
/// rolled back, and can be rolled back again or committed.
|
/// rolled back, and can be rolled back again or committed.
|
||||||
pub fn rollback(&mut self) -> Result<()> {
|
pub fn rollback(&mut self) -> Result<()> {
|
||||||
self.conn
|
self.conn
|
||||||
.execute_batch(&format!("ROLLBACK TO {}", self.name))
|
.execute(&format!("ROLLBACK TO {}", self.name), NO_PARAMS)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes the savepoint, committing or rolling back according to the
|
/// Consumes the savepoint, committing or rolling back according to the
|
||||||
|
Loading…
Reference in New Issue
Block a user