fix mvcc update

simple reason why mvcc update didn't work: it didn't try to update.
This commit is contained in:
Jussi Saurio
2025-09-15 11:27:56 +03:00
parent aa7a853cd2
commit 59f18e2dc8
3 changed files with 14 additions and 8 deletions

View File

@@ -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(())
}

View File

@@ -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"),
},

View File

@@ -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()