add test demonstrating that issue 3084 can be closed

This commit is contained in:
Jussi Saurio
2025-09-15 11:32:39 +03:00
parent d643bb2092
commit f2dbf1eeb0

View File

@@ -396,6 +396,30 @@ fn test_mvcc_update_same_row_twice() {
assert_eq!(value.as_str(), "third");
}
#[test]
fn test_mvcc_concurrent_conflicting_update() {
let tmp_db = TempDatabase::new_with_opts(
"test_mvcc_concurrent_conflicting_update.db",
turso_core::DatabaseOpts::new().with_mvcc(true),
);
let conn1 = tmp_db.connect_limbo();
let conn2 = tmp_db.connect_limbo();
conn1
.execute("CREATE TABLE test (id INTEGER, value TEXT)")
.unwrap();
conn1.execute("INSERT INTO test (id, value) VALUES (1, 'first')")
.unwrap();
conn1.execute("BEGIN CONCURRENT").unwrap();
conn2.execute("BEGIN CONCURRENT").unwrap();
conn1.execute("UPDATE test SET value = 'second' WHERE id = 1").unwrap();
let err = conn2.execute("UPDATE test SET value = 'third' WHERE id = 1").err().expect("expected error");
assert!(matches!(err, LimboError::WriteWriteConflict));
}
fn helper_read_all_rows(mut stmt: turso_core::Statement) -> Vec<Vec<Value>> {
let mut ret = Vec::new();
loop {