Skip to content

Commit

Permalink
Provide a minimal interface exposing SQLite's enable_load_extension
Browse files Browse the repository at this point in the history
This behavior is untested since we would need to add some extensions in
order to test it.

Fixes diesel-rs#1867
  • Loading branch information
sgrif authored and alamminsalo committed Oct 3, 2019
1 parent 1d60f2d commit 9faef2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions diesel/src/sqlite/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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<T, E, F>(&self, f: F, sql: &str) -> Result<T, E>
where
F: FnOnce() -> Result<T, E>,
Expand Down
4 changes: 4 additions & 0 deletions diesel/src/sqlite/connection/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ impl RawConnection {
))
}
}

pub fn enable_load_extension(&self) {
unsafe { ffi::enable_load_extension(self.internal_connection.as_ptr(), true) }
}
}

impl Drop for RawConnection {
Expand Down

0 comments on commit 9faef2d

Please sign in to comment.