mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Loadable extension
This commit is contained in:
		| @@ -4,7 +4,7 @@ use std::os::raw::{c_char, c_int}; | ||||
| use std::path::Path; | ||||
| use std::ptr; | ||||
| use std::str; | ||||
| use std::sync::atomic::{AtomicBool, Ordering}; | ||||
| use std::sync::atomic::AtomicBool; | ||||
| use std::sync::{Arc, Mutex}; | ||||
|  | ||||
| use super::ffi; | ||||
| @@ -390,7 +390,7 @@ impl Drop for InnerConnection { | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(not(any(target_arch = "wasm32")))] | ||||
| #[cfg(not(any(target_arch = "wasm32", feature = "loadable_extension")))] | ||||
| static SQLITE_INIT: std::sync::Once = std::sync::Once::new(); | ||||
|  | ||||
| pub static BYPASS_SQLITE_INIT: AtomicBool = AtomicBool::new(false); | ||||
| @@ -440,7 +440,9 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> { | ||||
|             Ok(()) | ||||
|         } | ||||
|     } else { | ||||
|         #[cfg(not(feature = "loadable_extension"))] | ||||
|         SQLITE_INIT.call_once(|| { | ||||
|             use std::sync::atomic::Ordering; | ||||
|             if BYPASS_SQLITE_INIT.load(Ordering::Relaxed) { | ||||
|                 return; | ||||
|             } | ||||
|   | ||||
| @@ -8,8 +8,7 @@ use std::ptr; | ||||
| use std::time::Duration; | ||||
|  | ||||
| use super::ffi; | ||||
| use crate::error::error_from_sqlite_code; | ||||
| use crate::{Connection, Result}; | ||||
| use crate::Connection; | ||||
|  | ||||
| /// Set up the process-wide SQLite error logging callback. | ||||
| /// | ||||
| @@ -25,7 +24,8 @@ use crate::{Connection, Result}; | ||||
| ///     * It must be threadsafe if SQLite is used in a multithreaded way. | ||||
| /// | ||||
| /// cf [The Error And Warning Log](http://sqlite.org/errlog.html). | ||||
| pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> { | ||||
| #[cfg(not(feature = "loadable_extension"))] | ||||
| pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> crate::Result<()> { | ||||
|     extern "C" fn log_callback(p_arg: *mut c_void, err: c_int, msg: *const c_char) { | ||||
|         let c_slice = unsafe { CStr::from_ptr(msg).to_bytes() }; | ||||
|         let callback: fn(c_int, &str) = unsafe { mem::transmute(p_arg) }; | ||||
| @@ -48,7 +48,7 @@ pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> { | ||||
|     if rc == ffi::SQLITE_OK { | ||||
|         Ok(()) | ||||
|     } else { | ||||
|         Err(error_from_sqlite_code(rc, None)) | ||||
|         Err(crate::error::error_from_sqlite_code(rc, None)) | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user