mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Remove second field from RawStatement
Use sqlite3_db_handle instead
This commit is contained in:
parent
a0151f9073
commit
83775ee62d
@ -895,7 +895,7 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.decode_result(r).map(|_| {
|
self.decode_result(r).map(|_| {
|
||||||
Statement::new(conn, RawStatement::new(c_stmt, self.db()))
|
Statement::new(conn, RawStatement::new(c_stmt))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ use super::unlock_notify;
|
|||||||
|
|
||||||
// Private newtype for raw sqlite3_stmts that finalize themselves when dropped.
|
// Private newtype for raw sqlite3_stmts that finalize themselves when dropped.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RawStatement(*mut ffi::sqlite3_stmt, *mut ffi::sqlite3);
|
pub struct RawStatement(*mut ffi::sqlite3_stmt);
|
||||||
|
|
||||||
impl RawStatement {
|
impl RawStatement {
|
||||||
pub fn new(stmt: *mut ffi::sqlite3_stmt, db: *mut ffi::sqlite3) -> RawStatement {
|
pub fn new(stmt: *mut ffi::sqlite3_stmt) -> RawStatement {
|
||||||
RawStatement(stmt, db)
|
RawStatement(stmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn ptr(&self) -> *mut ffi::sqlite3_stmt {
|
pub unsafe fn ptr(&self) -> *mut ffi::sqlite3_stmt {
|
||||||
@ -31,13 +31,14 @@ impl RawStatement {
|
|||||||
|
|
||||||
pub fn step(&self) -> c_int {
|
pub fn step(&self) -> c_int {
|
||||||
if cfg!(feature = "unlock_notify") {
|
if cfg!(feature = "unlock_notify") {
|
||||||
|
let db = unsafe { ffi::sqlite3_db_handle(self.0) };
|
||||||
let mut rc;
|
let mut rc;
|
||||||
loop {
|
loop {
|
||||||
rc = unsafe { ffi::sqlite3_step(self.0) };
|
rc = unsafe { ffi::sqlite3_step(self.0) };
|
||||||
if !unlock_notify::is_locked(self.1, rc) {
|
if !unlock_notify::is_locked(db, rc) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rc = unlock_notify::wait_for_unlock_notify(self.1);
|
rc = unlock_notify::wait_for_unlock_notify(db);
|
||||||
if rc != ffi::SQLITE_OK {
|
if rc != ffi::SQLITE_OK {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finalize_(&mut self) -> Result<()> {
|
fn finalize_(&mut self) -> Result<()> {
|
||||||
let mut stmt = RawStatement::new(ptr::null_mut(), ptr::null_mut());
|
let mut stmt = RawStatement::new(ptr::null_mut());
|
||||||
mem::swap(&mut stmt, &mut self.stmt);
|
mem::swap(&mut stmt, &mut self.stmt);
|
||||||
self.conn.decode_result(stmt.finalize())
|
self.conn.decode_result(stmt.finalize())
|
||||||
}
|
}
|
||||||
@ -470,7 +470,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
|
|
||||||
impl<'conn> Into<RawStatement> for Statement<'conn> {
|
impl<'conn> Into<RawStatement> for Statement<'conn> {
|
||||||
fn into(mut self) -> RawStatement {
|
fn into(mut self) -> RawStatement {
|
||||||
let mut stmt = RawStatement::new(ptr::null_mut(), ptr::null_mut());
|
let mut stmt = RawStatement::new(ptr::null_mut());
|
||||||
mem::swap(&mut stmt, &mut self.stmt);
|
mem::swap(&mut stmt, &mut self.stmt);
|
||||||
stmt
|
stmt
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user