From 9cdf80f3caaf2cf67f20d273794b33481ac7d0fc Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 13 Jun 2021 10:39:36 +0200 Subject: [PATCH 1/4] Fix InnerConnection decode_result / changes Fix #931 --- src/blob/mod.rs | 2 +- src/busy.rs | 2 +- src/inner_connection.rs | 4 ++-- src/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blob/mod.rs b/src/blob/mod.rs index cd9ad31..dee1f73 100644 --- a/src/blob/mod.rs +++ b/src/blob/mod.rs @@ -223,7 +223,7 @@ impl Connection { row_id: i64, read_only: bool, ) -> Result> { - let mut c = self.db.borrow_mut(); + let c = self.db.borrow_mut(); let mut blob = ptr::null_mut(); let db = db.as_cstring()?; let table = super::str_to_cstring(table)?; diff --git a/src/busy.rs b/src/busy.rs index e51fb08..b394d01 100644 --- a/src/busy.rs +++ b/src/busy.rs @@ -64,7 +64,7 @@ impl Connection { 0 } } - let mut c = self.db.borrow_mut(); + let c = self.db.borrow_mut(); let r = match callback { Some(f) => unsafe { ffi::sqlite3_busy_handler(c.db(), Some(busy_handler_callback), f as *mut c_void) diff --git a/src/inner_connection.rs b/src/inner_connection.rs index 11dc524..1bd641c 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -136,7 +136,7 @@ impl InnerConnection { } #[inline] - pub fn decode_result(&mut self, code: c_int) -> Result<()> { + pub fn decode_result(&self, code: c_int) -> Result<()> { unsafe { InnerConnection::decode_result_raw(self.db(), code) } } @@ -278,7 +278,7 @@ impl InnerConnection { } #[inline] - pub fn changes(&mut self) -> usize { + pub fn changes(&self) -> usize { unsafe { ffi::sqlite3_changes(self.db()) as usize } } diff --git a/src/lib.rs b/src/lib.rs index d16ffa8..71a4759 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -832,7 +832,7 @@ impl Connection { #[inline] fn decode_result(&self, code: c_int) -> Result<()> { - self.db.borrow_mut().decode_result(code) + self.db.borrow().decode_result(code) } /// Return the number of rows modified, inserted or deleted by the most @@ -840,7 +840,7 @@ impl Connection { /// connection. #[inline] fn changes(&self) -> usize { - self.db.borrow_mut().changes() + self.db.borrow().changes() } /// Test for auto-commit mode. From a2756ffbb007ea46f01a5edc28c126988f53eecb Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 13 Jun 2021 10:46:00 +0200 Subject: [PATCH 2/4] Fix AuthContext / Authorization visibility Fix #972 Breaking change: Action is not visible from root anymore --- src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d16ffa8..ff30cb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,8 +73,6 @@ pub use crate::cache::CachedStatement; pub use crate::column::Column; pub use crate::error::Error; pub use crate::ffi::ErrorCode; -#[cfg(feature = "hooks")] -pub use crate::hooks::Action; #[cfg(feature = "load_extension")] pub use crate::load_extension_guard::LoadExtensionGuard; pub use crate::params::{params_from_iter, Params, ParamsFromIter}; @@ -102,7 +100,7 @@ mod context; #[cfg(feature = "functions")] pub mod functions; #[cfg(feature = "hooks")] -mod hooks; +pub mod hooks; mod inner_connection; #[cfg(feature = "limits")] pub mod limits; From 73fd16958eafa6dc192de8ceb2c31e91a82cf836 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 13 Jun 2021 10:57:01 +0200 Subject: [PATCH 3/4] Fix missing docs --- src/hooks.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hooks.rs b/src/hooks.rs index e7d2670..5540e9a 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -42,14 +42,14 @@ impl From for Action { /// See for more info. #[derive(Clone, Copy, Debug, PartialEq)] pub struct AuthContext<'c> { - // The action to be authorized. + /// The action to be authorized. pub action: AuthAction<'c>, /// The database name, if applicable. pub database_name: Option<&'c str>, - // The inner-most trigger or view responsible for the access attempt. - // `None` if the access attempt was made by top-level SQL code. + /// The inner-most trigger or view responsible for the access attempt. + /// `None` if the access attempt was made by top-level SQL code. pub accessor: Option<&'c str>, } @@ -254,7 +254,7 @@ impl<'c> AuthAction<'c> { table_name, column_name, }, - (ffi::SQLITE_SELECT, _, _) => Self::Select, + (ffi::SQLITE_SELECT, ..) => Self::Select, (ffi::SQLITE_TRANSACTION, Some(operation_str), _) => Self::Transaction { operation: TransactionOperation::from_str(operation_str), }, @@ -286,7 +286,7 @@ impl<'c> AuthAction<'c> { savepoint_name, }, #[cfg(feature = "modern_sqlite")] - (ffi::SQLITE_RECURSIVE, _, _) => Self::Recursive, + (ffi::SQLITE_RECURSIVE, ..) => Self::Recursive, (code, arg1, arg2) => Self::Unknown { code, arg1, arg2 }, } } @@ -298,6 +298,7 @@ pub(crate) type BoxedAuthorizer = /// `feature = "hooks"` A transaction operation. #[derive(Clone, Copy, Debug, PartialEq)] #[non_exhaustive] +#[allow(missing_docs)] pub enum TransactionOperation { Unknown, Begin, @@ -316,6 +317,7 @@ impl TransactionOperation { } } +/// [`authorizer`](Connection::authorizer) return code #[derive(Clone, Copy, Debug, PartialEq)] #[non_exhaustive] pub enum Authorization { From 83e8c96ae918f563242e08eb48f4086a5d9c3034 Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 14 Jun 2021 19:26:09 +0200 Subject: [PATCH 4/4] Fix InnerConnection::authorizer visibility --- src/hooks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks.rs b/src/hooks.rs index 5540e9a..0366b5f 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -599,7 +599,7 @@ impl InnerConnection { }; } - pub fn authorizer<'c, F>(&'c mut self, authorizer: Option) + fn authorizer<'c, F>(&'c mut self, authorizer: Option) where F: for<'r> FnMut(AuthContext<'r>) -> Authorization + Send + RefUnwindSafe + 'static, {