From 6b60dd06c6f69351a13f179a4137ba4ddc2295a2 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Mon, 7 Jul 2025 12:08:31 -0300 Subject: [PATCH] only rollback on write transaction --- core/lib.rs | 21 +++++++-------------- core/vdbe/mod.rs | 4 +++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/core/lib.rs b/core/lib.rs index 038d6a10f..e469a2bda 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -102,17 +102,6 @@ enum TransactionState { None, } -impl TransactionState { - fn schema_did_change(&self) -> bool { - matches!( - self, - TransactionState::Write { - schema_did_change: true - } - ) - } -} - pub(crate) type MvStore = mvcc::MvStore; pub(crate) type MvCursor = mvcc::cursor::ScanCursor; @@ -633,7 +622,9 @@ impl Connection { let res = self._db.io.run_once(); if res.is_err() { let state = self.transaction_state.get(); - self.pager.rollback(state.schema_did_change(), self)?; + if let TransactionState::Write { schema_did_change } = state { + self.pager.rollback(schema_did_change, self)? + } } res } @@ -906,8 +897,10 @@ impl Statement { let res = self.pager.io.run_once(); if res.is_err() { let state = self.program.connection.transaction_state.get(); - self.pager - .rollback(state.schema_did_change(), &self.program.connection)?; + if let TransactionState::Write { schema_did_change } = state { + self.pager + .rollback(schema_did_change, &self.program.connection)? + } } res } diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 085aa0cd0..e2195a853 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -386,7 +386,9 @@ impl Program { let res = insn_function(self, state, insn, &pager, mv_store.as_ref()); if res.is_err() { let state = self.connection.transaction_state.get(); - pager.rollback(state.schema_did_change(), &self.connection)? + if let TransactionState::Write { schema_did_change } = state { + pager.rollback(schema_did_change, &self.connection)? + } } match res? { InsnFunctionStepResult::Step => {}