mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 08:55:40 +01:00
only rollback on write transaction
This commit is contained in:
21
core/lib.rs
21
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<mvcc::LocalClock>;
|
||||
|
||||
pub(crate) type MvCursor = mvcc::cursor::ScanCursor<mvcc::LocalClock>;
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 => {}
|
||||
|
||||
Reference in New Issue
Block a user