Skip to content

Commit

Permalink
enable loadable extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfenjin committed Sep 30, 2023
1 parent 622e24e commit 0c37952
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 0 additions & 7 deletions libduckdb-sys/update_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,3 @@ def get_sources(extensions):
+ '/bindgen_bundled_version.rs" \;',
shell=True,
)

# Remove the extra patch file
os.remove(
os.path.join(
SCRIPT_DIR, "duckdb-sources", "extension", "httpfs", "httpfs_config.py"
)
)
14 changes: 13 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,28 @@ pub enum DefaultNullOrder {

/// duckdb configuration
/// Refer to https://github.com/duckdb/duckdb/blob/master/src/main/config.cpp
#[derive(Default)]
pub struct Config {
config: Option<ffi::duckdb_config>,
}

impl Default for Config {
fn default() -> Self {
Config { config: None }.autoloadable_extension(true).unwrap()
}
}

impl Config {
pub(crate) fn duckdb_config(&self) -> ffi::duckdb_config {
self.config.unwrap_or(std::ptr::null_mut() as ffi::duckdb_config)
}

/// enable autoload extensions
pub fn autoloadable_extension(mut self, enabled: bool) -> Result<Config> {
self.set("autoinstall_known_extensions", &(enabled as i32).to_string())?;
self.set("autoload_known_extensions", &(enabled as i32).to_string())?;
Ok(self)
}

/// Access mode of the database ([AUTOMATIC], READ_ONLY or READ_WRITE)
pub fn access_mode(mut self, mode: AccessMode) -> Result<Config> {
self.set("access_mode", &mode.to_string())?;
Expand Down

0 comments on commit 0c37952

Please sign in to comment.