Skip to content

Commit ebaff31

Browse files
sgrifweiznich
authored andcommitted
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 f307a4b commit ebaff31

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
@@ -164,6 +164,16 @@ impl SqliteConnection {
164164
self.transaction_sql(f, "BEGIN EXCLUSIVE")
165165
}
166166

167+
/// Enables the `load_extension` SQL function.
168+
///
169+
/// See the documentation for the [`enable_load_extension` C function] for
170+
/// details.
171+
///
172+
/// [`enable_load_extension` C function]: https://www.sqlite.org/c3ref/enable_load_extension.html
173+
pub fn enable_load_extension(&self) {
174+
self.raw_connection.enable_load_extension();
175+
}
176+
167177
fn transaction_sql<T, E, F>(&self, f: F, sql: &str) -> Result<T, E>
168178
where
169179
F: FnOnce() -> Result<T, E>,

diesel/src/sqlite/connection/raw.rs

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ impl RawConnection {
163163
))
164164
}
165165
}
166+
167+
pub fn enable_load_extension(&self) {
168+
unsafe { ffi::enable_load_extension(self.internal_connection.as_ptr(), true) }
169+
}
166170
}
167171

168172
impl Drop for RawConnection {

0 commit comments

Comments
 (0)