mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-03 08:24:19 +01:00
Add a flag to DatabaseOpts, only for cli_only feature to enable rt extension loading
This commit is contained in:
12
core/lib.rs
12
core/lib.rs
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user