From 1b6050338d2d744a0a4652f26680a36b95fa19e5 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 22 Sep 2025 11:37:17 +0300 Subject: [PATCH] core: Wrap Connection::database_schemas in RwLock --- core/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);