mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-22 16:35:30 +01:00
fix mvcc update
simple reason why mvcc update didn't work: it didn't try to update.
This commit is contained in:
@@ -46,9 +46,15 @@ impl<Clock: LogicalClock> MvccLazyCursor<Clock> {
|
||||
/// Sets the cursor to the inserted row.
|
||||
pub fn insert(&mut self, row: Row) -> Result<()> {
|
||||
self.current_pos = CursorPosition::Loaded(row.id);
|
||||
self.db.insert(self.tx_id, row).inspect_err(|_| {
|
||||
self.current_pos = CursorPosition::BeforeFirst;
|
||||
})?;
|
||||
if self.db.read(self.tx_id, row.id)?.is_some() {
|
||||
self.db.update(self.tx_id, row).inspect_err(|_| {
|
||||
self.current_pos = CursorPosition::BeforeFirst;
|
||||
})?;
|
||||
} else {
|
||||
self.db.insert(self.tx_id, row).inspect_err(|_| {
|
||||
self.current_pos = CursorPosition::BeforeFirst;
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -4625,7 +4625,7 @@ impl BTreeCursor {
|
||||
}
|
||||
};
|
||||
let row = crate::mvcc::database::Row::new(row_id, record_buf, num_columns);
|
||||
mv_cursor.borrow_mut().insert(row).unwrap();
|
||||
mv_cursor.borrow_mut().insert(row)?;
|
||||
}
|
||||
None => todo!("Support mvcc inserts with index btrees"),
|
||||
},
|
||||
|
||||
@@ -505,10 +505,10 @@ async fn test_multiple_connections_fuzz_mvcc() {
|
||||
weight_ddl: 0,
|
||||
weight_dml: 76,
|
||||
dml_gen_options: DmlGenOptions {
|
||||
weight_insert: 34,
|
||||
weight_delete: 33,
|
||||
weight_select: 33,
|
||||
weight_update: 0,
|
||||
weight_insert: 25,
|
||||
weight_delete: 25,
|
||||
weight_select: 25,
|
||||
weight_update: 25,
|
||||
},
|
||||
},
|
||||
..FuzzOptions::default()
|
||||
|
||||
Reference in New Issue
Block a user