mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 08:55:40 +01:00
add test demonstrating that issue 3084 can be closed
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user