Add a flag to DatabaseOpts, only for cli_only feature to enable rt extension loading

This commit is contained in:
PThorpe92
2025-09-22 09:42:07 -04:00
parent cfa89c9ddb
commit 4ac4aff30c

View File

@@ -106,6 +106,7 @@ pub struct DatabaseOpts {
pub enable_indexes: bool,
pub enable_views: bool,
pub enable_strict: bool,
enable_load_extension: bool,
}
impl Default for DatabaseOpts {
@@ -115,6 +116,7 @@ impl Default for DatabaseOpts {
enable_indexes: true,
enable_views: false,
enable_strict: false,
enable_load_extension: false,
}
}
}
@@ -124,6 +126,12 @@ impl DatabaseOpts {
Self::default()
}
#[cfg(feature = "cli_only")]
pub fn turso_cli(mut self) -> Self {
self.enable_load_extension = true;
self
}
pub fn with_mvcc(mut self, enable: bool) -> Self {
self.enable_mvcc = enable;
self
@@ -755,6 +763,10 @@ impl Database {
Ok((io, db))
}
pub(crate) fn can_load_extensions(&self) -> bool {
self.opts.enable_load_extension
}
#[inline]
pub(crate) fn with_schema_mut<T>(&self, f: impl FnOnce(&mut Schema) -> Result<T>) -> Result<T> {
let mut schema_ref = self.schema.lock().map_err(|_| LimboError::SchemaLocked)?;