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 weiznich committed Feb 16, 2021
1 parent 6da017e commit 357bc62
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 @@ -164,6 +164,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 @@ -163,6 +163,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 357bc62

Please sign in to comment.