From 83775ee62d6ca8d281c9dc25c96fb669127bd8cd Mon Sep 17 00:00:00 2001 From: gwenn Date: Tue, 3 Apr 2018 20:18:51 +0200 Subject: [PATCH] Remove second field from RawStatement Use sqlite3_db_handle instead --- src/lib.rs | 2 +- src/raw_statement.rs | 11 ++++++----- src/statement.rs | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0a30078..3f71362 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -895,7 +895,7 @@ impl InnerConnection { } }; self.decode_result(r).map(|_| { - Statement::new(conn, RawStatement::new(c_stmt, self.db())) + Statement::new(conn, RawStatement::new(c_stmt)) }) } diff --git a/src/raw_statement.rs b/src/raw_statement.rs index 9b756da..3c33ea3 100644 --- a/src/raw_statement.rs +++ b/src/raw_statement.rs @@ -6,11 +6,11 @@ use super::unlock_notify; // Private newtype for raw sqlite3_stmts that finalize themselves when dropped. #[derive(Debug)] -pub struct RawStatement(*mut ffi::sqlite3_stmt, *mut ffi::sqlite3); +pub struct RawStatement(*mut ffi::sqlite3_stmt); impl RawStatement { - pub fn new(stmt: *mut ffi::sqlite3_stmt, db: *mut ffi::sqlite3) -> RawStatement { - RawStatement(stmt, db) + pub fn new(stmt: *mut ffi::sqlite3_stmt) -> RawStatement { + RawStatement(stmt) } pub unsafe fn ptr(&self) -> *mut ffi::sqlite3_stmt { @@ -31,13 +31,14 @@ impl RawStatement { pub fn step(&self) -> c_int { if cfg!(feature = "unlock_notify") { + let db = unsafe { ffi::sqlite3_db_handle(self.0) }; let mut rc; loop { rc = unsafe { ffi::sqlite3_step(self.0) }; - if !unlock_notify::is_locked(self.1, rc) { + if !unlock_notify::is_locked(db, rc) { break; } - rc = unlock_notify::wait_for_unlock_notify(self.1); + rc = unlock_notify::wait_for_unlock_notify(db); if rc != ffi::SQLITE_OK { break; } diff --git a/src/statement.rs b/src/statement.rs index 2c5227b..2674c32 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -462,7 +462,7 @@ impl<'conn> Statement<'conn> { } 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); self.conn.decode_result(stmt.finalize()) } @@ -470,7 +470,7 @@ impl<'conn> Statement<'conn> { impl<'conn> Into for Statement<'conn> { 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); stmt }