diff --git a/core/lib.rs b/core/lib.rs index 957445bc9..6cd215bc5 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -499,7 +499,7 @@ impl Database { .map_err(|_| LimboError::SchemaLocked)? .clone(), ), - database_schemas: RefCell::new(std::collections::HashMap::new()), + database_schemas: RwLock::new(std::collections::HashMap::new()), auto_commit: Cell::new(true), transaction_state: Cell::new(TransactionState::None), last_insert_rowid: Cell::new(0), @@ -983,7 +983,7 @@ pub struct Connection { schema: RwLock>, /// Per-database schema cache (database_index -> schema) /// Loaded lazily to avoid copying all schemas on connection open - database_schemas: RefCell>>, + database_schemas: RwLock>>, /// Whether to automatically commit transaction auto_commit: Cell, transaction_state: Cell, @@ -2037,7 +2037,7 @@ impl Connection { f(&schema) } else { // Attached database - check cache first, then load from database - let mut schemas = self.database_schemas.borrow_mut(); + let mut schemas = self.database_schemas.write(); if let Some(cached_schema) = schemas.get(&database_id) { return f(cached_schema);