From f20213b7ad1d5ce0300de49874fbec02cd91138e Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 7 Oct 2018 17:26:14 -0600 Subject: [PATCH] Provide a minimal interface exposing SQLite's `enable_load_extension` This behavior is untested since we would need to add some extensions in order to test it. Fixes #1867 --- diesel/src/sqlite/connection/mod.rs | 10 ++++++++++ diesel/src/sqlite/connection/raw.rs | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/diesel/src/sqlite/connection/mod.rs b/diesel/src/sqlite/connection/mod.rs index 49c34ed7a3f3..34ee198361c0 100644 --- a/diesel/src/sqlite/connection/mod.rs +++ b/diesel/src/sqlite/connection/mod.rs @@ -167,6 +167,16 @@ impl SqliteConnection { self.transaction_sql(f, "BEGIN EXCLUSIVE") } + /// Enables the `load_extension` SQL function. + /// + /// See the documentation for the [`enable_load_extension` C function] for + /// details. + /// + /// [`enable_load_extension` C function]: https://www.sqlite.org/c3ref/enable_load_extension.html + pub fn enable_load_extension(&self) { + self.raw_connection.enable_load_extension(); + } + fn transaction_sql(&self, f: F, sql: &str) -> Result where F: FnOnce() -> Result, diff --git a/diesel/src/sqlite/connection/raw.rs b/diesel/src/sqlite/connection/raw.rs index a9cb7b621dbd..8284071a3d80 100644 --- a/diesel/src/sqlite/connection/raw.rs +++ b/diesel/src/sqlite/connection/raw.rs @@ -105,6 +105,10 @@ impl RawConnection { )) } } + + pub fn enable_load_extension(&self) { + unsafe { ffi::enable_load_extension(self.internal_connection.as_ptr(), true) } + } } impl Drop for RawConnection {