mvcc: remove conn.mv_transactions

afaict this isn't needed for anything since there is already
conn.mv_tx_id
This commit is contained in:
Jussi Saurio
2025-09-14 21:24:59 +03:00
parent 5feb9ea2f0
commit 7fe25a1d0e
3 changed files with 3 additions and 14 deletions

View File

@@ -464,7 +464,6 @@ impl Database {
),
database_schemas: RefCell::new(std::collections::HashMap::new()),
auto_commit: Cell::new(true),
mv_transactions: RefCell::new(Vec::new()),
transaction_state: Cell::new(TransactionState::None),
last_insert_rowid: Cell::new(0),
last_change: Cell::new(0),
@@ -944,8 +943,6 @@ pub struct Connection {
database_schemas: RefCell<std::collections::HashMap<usize, Arc<Schema>>>,
/// Whether to automatically commit transaction
auto_commit: Cell<bool>,
/// Transactions that are in progress.
mv_transactions: RefCell<Vec<crate::mvcc::database::TxID>>,
transaction_state: Cell<TransactionState>,
last_insert_rowid: Cell<i64>,
last_change: Cell<i64>,

View File

@@ -2174,7 +2174,6 @@ pub fn op_transaction(
return_if_io!(mv_store.begin_exclusive_tx(pager.clone(), None))
}
};
conn.mv_transactions.borrow_mut().push(tx_id);
program.connection.mv_tx_id.set(Some(tx_id));
} else if updated
&& matches!(new_transaction_state, TransactionState::Write { .. })

View File

@@ -820,17 +820,11 @@ impl Program {
let auto_commit = conn.auto_commit.get();
if auto_commit {
// FIXME: we don't want to commit stuff from other programs.
let mut mv_transactions = conn.mv_transactions.borrow_mut();
if matches!(program_state.commit_state, CommitState::Ready) {
assert!(
mv_transactions.len() <= 1,
"for now we only support one mv transaction in single connection, {mv_transactions:?}",
);
if mv_transactions.is_empty() {
let Some(tx_id) = conn.mv_tx_id.get() else {
return Ok(IOResult::Done(()));
}
let tx_id = mv_transactions.first().unwrap();
let state_machine = mv_store.commit_tx(*tx_id, pager.clone(), &conn).unwrap();
};
let state_machine = mv_store.commit_tx(tx_id, pager.clone(), &conn).unwrap();
program_state.commit_state = CommitState::CommitingMvcc { state_machine };
}
let CommitState::CommitingMvcc { state_machine } = &mut program_state.commit_state
@@ -843,7 +837,6 @@ impl Program {
conn.mv_tx_id.set(None);
conn.transaction_state.replace(TransactionState::None);
program_state.commit_state = CommitState::Ready;
mv_transactions.clear();
return Ok(IOResult::Done(()));
}
IOResult::IO(io) => {