From e2fc8414797c7c73c7ffad5546c5efe02392c2d7 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Thu, 13 Apr 2023 10:19:21 +0300 Subject: [PATCH] Move is_write_write_conflict() definition --- core/mvcc/database/src/database.rs | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/core/mvcc/database/src/database.rs b/core/mvcc/database/src/database.rs index b5b727e1b..5439a2a76 100644 --- a/core/mvcc/database/src/database.rs +++ b/core/mvcc/database/src/database.rs @@ -218,29 +218,6 @@ impl Database { } } -/// A write-write conflict happens when transaction T_m attempts to update a -/// row version that is currently being updated by an active transaction T_n. -fn is_write_write_conflict( - txs: &HashMap, - tx: &Transaction, - rv: &RowVersion, -) -> bool { - match rv.end { - Some(TxTimestampOrID::TxID(rv_end)) => { - let te = txs.get(&rv_end).unwrap(); - match te.state { - TransactionState::Active => tx.tx_id != te.tx_id, - TransactionState::Preparing => todo!(), - TransactionState::Committed => todo!(), - TransactionState::Aborted => todo!(), - TransactionState::Terminated => todo!(), - } - } - Some(TxTimestampOrID::Timestamp(_)) => false, - None => false, - } -} - #[derive(Debug)] pub struct DatabaseInner { rows: RefCell>>, @@ -379,6 +356,29 @@ impl DatabaseInner { } } +/// A write-write conflict happens when transaction T_m attempts to update a +/// row version that is currently being updated by an active transaction T_n. +fn is_write_write_conflict( + txs: &HashMap, + tx: &Transaction, + rv: &RowVersion, +) -> bool { + match rv.end { + Some(TxTimestampOrID::TxID(rv_end)) => { + let te = txs.get(&rv_end).unwrap(); + match te.state { + TransactionState::Active => tx.tx_id != te.tx_id, + TransactionState::Preparing => todo!(), + TransactionState::Committed => todo!(), + TransactionState::Aborted => todo!(), + TransactionState::Terminated => todo!(), + } + } + Some(TxTimestampOrID::Timestamp(_)) => false, + None => false, + } +} + fn is_version_visible(txs: &HashMap, tx: &Transaction, rv: &RowVersion) -> bool { is_begin_visible(txs, tx, rv) && is_end_visible(txs, tx, rv) }