From 8a206193e438e6ee87fadd79a17c569c17b88564 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Dec 2024 08:49:14 +0000 Subject: [PATCH 1/2] Update sqlite3-sys requirement in the dependencies group --- updated-dependencies: - dependency-name: sqlite3-sys dependency-type: direct:production dependency-group: dependencies ... Signed-off-by: dependabot[bot] --- concatsql/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concatsql/Cargo.toml b/concatsql/Cargo.toml index 156d61e..229abe8 100644 --- a/concatsql/Cargo.toml +++ b/concatsql/Cargo.toml @@ -28,7 +28,7 @@ chrono = "0.4.35" concatsql_macro = { version = "0.1.0", path = "../concatsql_macro" } [dependencies.sqlite3-sys] -version = "0.16.0" +version = "0.17.0" default-features = false optional = true From f3958d9cff5ee6944dcad1b2222c67c1a0a02535 Mon Sep 17 00:00:00 2001 From: kumavale Date: Tue, 31 Dec 2024 18:05:53 +0900 Subject: [PATCH 2/2] fix: add `SQLITE_TRANSIENT` --- concatsql/src/sqlite/connection.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/concatsql/src/sqlite/connection.rs b/concatsql/src/sqlite/connection.rs index 1cfef0c..427dfae 100644 --- a/concatsql/src/sqlite/connection.rs +++ b/concatsql/src/sqlite/connection.rs @@ -2,7 +2,7 @@ extern crate sqlite3_sys as ffi; use std::borrow::Cow; use std::cell::Cell; -use std::ffi::{c_void, CStr, CString}; +use std::ffi::{c_int, c_void, CStr, CString}; use std::path::Path; use std::ptr::{self, NonNull}; @@ -340,6 +340,9 @@ unsafe fn bind_all( params: &[Value<'_>], error_level: &ErrorLevel, ) -> Result<()> { + // https://sqlite.org/c3ref/c_static.html + const SQLITE_TRANSIENT: c_int = -1; + for (index, param) in (1i32..).zip(params.iter()) { let result = match param { Value::Null => ffi::sqlite3_bind_null(stmt, index), @@ -355,7 +358,7 @@ unsafe fn bind_all( Some(std::mem::transmute::< *const c_void, extern "C" fn(*mut c_void), - >(ffi::SQLITE_TRANSIENT as *const c_void)), + >(SQLITE_TRANSIENT as *const c_void)), ), Value::Bytes(value) => ffi::sqlite3_bind_blob( stmt, @@ -365,7 +368,7 @@ unsafe fn bind_all( Some(std::mem::transmute::< *const c_void, extern "C" fn(*mut c_void), - >(ffi::SQLITE_TRANSIENT as *const c_void)), + >(SQLITE_TRANSIENT as *const c_void)), ), Value::IpAddr(value) => { let value = value.to_string(); @@ -377,7 +380,7 @@ unsafe fn bind_all( Some(std::mem::transmute::< *const c_void, extern "C" fn(*mut c_void), - >(ffi::SQLITE_TRANSIENT as *const c_void)), + >(SQLITE_TRANSIENT as *const c_void)), ) } Value::Time(value) => { @@ -390,7 +393,7 @@ unsafe fn bind_all( Some(std::mem::transmute::< *const c_void, extern "C" fn(*mut c_void), - >(ffi::SQLITE_TRANSIENT as *const c_void)), + >(SQLITE_TRANSIENT as *const c_void)), ) } };