Skip to content

Commit 9faef2d

Browse files
sgrifalamminsalo
authored and
alamminsalo
committed
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 diesel-rs#1867
1 parent 1d60f2d commit 9faef2d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

diesel/src/sqlite/connection/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ impl SqliteConnection {
173173
self.transaction_sql(f, "BEGIN EXCLUSIVE")
174174
}
175175

176+
/// Enables the `load_extension` SQL function.
177+
///
178+
/// See the documentation for the [`enable_load_extension` C function] for
179+
/// details.
180+
///
181+
/// [`enable_load_extension` C function]: https://www.sqlite.org/c3ref/enable_load_extension.html
182+
pub fn enable_load_extension(&self) {
183+
self.raw_connection.enable_load_extension();
184+
}
185+
176186
fn transaction_sql<T, E, F>(&self, f: F, sql: &str) -> Result<T, E>
177187
where
178188
F: FnOnce() -> Result<T, E>,

diesel/src/sqlite/connection/raw.rs

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ impl RawConnection {
107107
))
108108
}
109109
}
110+
111+
pub fn enable_load_extension(&self) {
112+
unsafe { ffi::enable_load_extension(self.internal_connection.as_ptr(), true) }
113+
}
110114
}
111115

112116
impl Drop for RawConnection {

0 commit comments

Comments
 (0)