mvcc: disallow BEGIN CONCURRENT after BEGIN

This commit is contained in:
Jussi Saurio
2025-09-25 09:16:52 +03:00
parent 04f9cbfa8d
commit 1ff2e07404

View File

@@ -2281,7 +2281,17 @@ pub fn op_transaction_inner(
// In MVCC we don't have write exclusivity, therefore we just need to start a transaction if needed.
// Programs can run Transaction twice, first with read flag and then with write flag. So a single txid is enough
// for both.
if program.connection.mv_tx.get().is_none() {
let has_existing_mv_tx = program.connection.mv_tx.get().is_some();
let conn_has_executed_begin_deferred = !has_existing_mv_tx
&& !program.connection.auto_commit.load(Ordering::SeqCst);
if conn_has_executed_begin_deferred && *tx_mode == TransactionMode::Concurrent {
return Err(LimboError::TxError(
"Cannot start CONCURRENT transaction after BEGIN DEFERRED".to_string(),
));
}
if !has_existing_mv_tx {
let tx_id = match tx_mode {
TransactionMode::None
| TransactionMode::Read