diff --git a/core/incremental/compiler.rs b/core/incremental/compiler.rs index f375d2f95..529cc5b23 100644 --- a/core/incremental/compiler.rs +++ b/core/incremental/compiler.rs @@ -1506,7 +1506,7 @@ impl DbspCompiler { let io = Arc::new(MemoryIO::new()); let db = Database::open_file(io, ":memory:", false, false)?; let internal_conn = db.connect()?; - internal_conn.query_only.set(true); + internal_conn.set_query_only(true); internal_conn.auto_commit.store(false, Ordering::SeqCst); // Create temporary symbol table diff --git a/core/incremental/project_operator.rs b/core/incremental/project_operator.rs index 435f6d90a..b82a1a138 100644 --- a/core/incremental/project_operator.rs +++ b/core/incremental/project_operator.rs @@ -62,7 +62,7 @@ impl ProjectOperator { )?; let internal_conn = db.connect()?; // Set to read-only mode and disable auto-commit since we're only evaluating expressions - internal_conn.query_only.set(true); + internal_conn.set_query_only(true); internal_conn.auto_commit.store(false, Ordering::SeqCst); // Create ProjectColumn structs from compiled expressions diff --git a/core/lib.rs b/core/lib.rs index 58067ad72..a8983fb4f 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -513,7 +513,7 @@ impl Database { capture_data_changes: RwLock::new(CaptureDataChangesMode::Off), closed: AtomicBool::new(false), attached_databases: RefCell::new(DatabaseCatalog::new()), - query_only: Cell::new(false), + query_only: AtomicBool::new(false), mv_tx: Cell::new(None), view_transaction_states: AllViewsTxState::new(), metrics: RefCell::new(ConnectionMetrics::new()), @@ -1003,7 +1003,7 @@ pub struct Connection { closed: AtomicBool, /// Attached databases attached_databases: RefCell, - query_only: Cell, + query_only: AtomicBool, pub(crate) mv_tx: Cell>, /// Per-connection view transaction states for uncommitted changes. This represents @@ -1711,6 +1711,10 @@ impl Connection { self.closed.load(Ordering::SeqCst) } + pub fn is_query_only(&self) -> bool { + self.query_only.load(Ordering::SeqCst) + } + pub fn get_database_canonical_path(&self) -> String { if self.db.path == ":memory:" { // For in-memory databases, SQLite shows empty string @@ -2120,11 +2124,11 @@ impl Connection { } pub fn get_query_only(&self) -> bool { - self.query_only.get() + self.is_query_only() } pub fn set_query_only(&self, value: bool) { - self.query_only.set(value); + self.query_only.store(value, Ordering::SeqCst); } pub fn get_sync_mode(&self) -> SyncMode {