remove unused pager parameter

This commit is contained in:
Jussi Saurio
2025-09-14 23:36:18 +03:00
parent d598775e33
commit db3428a7a9
6 changed files with 17 additions and 42 deletions

View File

@@ -109,7 +109,6 @@ fn bench(c: &mut Criterion) {
data: record_data.clone(),
column_count: 1,
},
conn.get_pager().clone(),
)
.unwrap();
let mv_store = &db.mvcc_store;
@@ -159,7 +158,6 @@ fn bench(c: &mut Criterion) {
let db = bench_db();
let tx_id = db.mvcc_store.begin_tx(db.conn.get_pager().clone());
let conn = &db.conn;
db.mvcc_store
.insert(
tx_id,
@@ -186,7 +184,6 @@ fn bench(c: &mut Criterion) {
data: record_data.clone(),
column_count: 1,
},
conn.get_pager().clone(),
)
.unwrap();
})

View File

@@ -52,8 +52,8 @@ impl<Clock: LogicalClock> MvccLazyCursor<Clock> {
Ok(())
}
pub fn delete(&mut self, rowid: RowID, pager: Rc<Pager>) -> Result<()> {
self.db.delete(self.tx_id, rowid, pager)?;
pub fn delete(&mut self, rowid: RowID) -> Result<()> {
self.db.delete(self.tx_id, rowid)?;
Ok(())
}

View File

@@ -1042,9 +1042,9 @@ impl<Clock: LogicalClock> MvStore<Clock> {
/// # Returns
///
/// Returns `true` if the row was successfully updated, and `false` otherwise.
pub fn update(&self, tx_id: TxID, row: Row, pager: Rc<Pager>) -> Result<bool> {
pub fn update(&self, tx_id: TxID, row: Row) -> Result<bool> {
tracing::trace!("update(tx_id={}, row.id={:?})", tx_id, row.id);
if !self.delete(tx_id, row.id, pager)? {
if !self.delete(tx_id, row.id)? {
return Ok(false);
}
self.insert(tx_id, row)?;
@@ -1053,9 +1053,9 @@ impl<Clock: LogicalClock> MvStore<Clock> {
/// Inserts a row in the database with new values, previously deleting
/// any old data if it existed. Bails on a delete error, e.g. write-write conflict.
pub fn upsert(&self, tx_id: TxID, row: Row, pager: Rc<Pager>) -> Result<()> {
pub fn upsert(&self, tx_id: TxID, row: Row) -> Result<()> {
tracing::trace!("upsert(tx_id={}, row.id={:?})", tx_id, row.id);
self.delete(tx_id, row.id, pager)?;
self.delete(tx_id, row.id)?;
self.insert(tx_id, row)
}
@@ -1073,7 +1073,7 @@ impl<Clock: LogicalClock> MvStore<Clock> {
///
/// Returns `true` if the row was successfully deleted, and `false` otherwise.
///
pub fn delete(&self, tx_id: TxID, id: RowID, pager: Rc<Pager>) -> Result<bool> {
pub fn delete(&self, tx_id: TxID, id: RowID) -> Result<bool> {
tracing::trace!("delete(tx_id={}, id={:?})", tx_id, id);
let row_versions_opt = self.rows.get(&id);
if let Some(ref row_versions) = row_versions_opt {

View File

@@ -167,7 +167,6 @@ fn test_delete() {
table_id: 1,
row_id: 1,
},
db.conn.pager.borrow().clone(),
)
.unwrap();
let row = db
@@ -209,7 +208,6 @@ fn test_delete_nonexistent() {
table_id: 1,
row_id: 1
},
db.conn.pager.borrow().clone(),
)
.unwrap());
}
@@ -233,9 +231,7 @@ fn test_commit() {
.unwrap();
assert_eq!(tx1_row, row);
let tx1_updated_row = generate_simple_string_row(1, 1, "World");
db.mvcc_store
.update(tx1, tx1_updated_row.clone(), db.conn.pager.borrow().clone())
.unwrap();
db.mvcc_store.update(tx1, tx1_updated_row.clone()).unwrap();
let row = db
.mvcc_store
.read(
@@ -286,9 +282,7 @@ fn test_rollback() {
.unwrap();
assert_eq!(row1, row2);
let row3 = generate_simple_string_row(1, 1, "World");
db.mvcc_store
.update(tx1, row3.clone(), db.conn.pager.borrow().clone())
.unwrap();
db.mvcc_store.update(tx1, row3.clone()).unwrap();
let row4 = db
.mvcc_store
.read(
@@ -342,10 +336,7 @@ fn test_dirty_write() {
// T2 attempts to delete row with ID 1, but fails because T1 has not committed.
let tx2 = db.mvcc_store.begin_tx(conn2.pager.borrow().clone());
let tx2_row = generate_simple_string_row(1, 1, "World");
assert!(!db
.mvcc_store
.update(tx2, tx2_row, conn2.pager.borrow().clone())
.unwrap());
assert!(!db.mvcc_store.update(tx2, tx2_row).unwrap());
let row = db
.mvcc_store
@@ -407,7 +398,6 @@ fn test_dirty_read_deleted() {
table_id: 1,
row_id: 1
},
conn2.pager.borrow().clone(),
)
.unwrap());
@@ -470,9 +460,7 @@ fn test_fuzzy_read() {
let conn3 = db.db.connect().unwrap();
let tx3 = db.mvcc_store.begin_tx(conn3.pager.borrow().clone());
let tx3_row = generate_simple_string_row(1, 1, "Second");
db.mvcc_store
.update(tx3, tx3_row, conn3.pager.borrow().clone())
.unwrap();
db.mvcc_store.update(tx3, tx3_row).unwrap();
commit_tx(db.mvcc_store.clone(), &conn3, tx3).unwrap();
// T2 still reads the same version of the row as before.
@@ -492,9 +480,7 @@ fn test_fuzzy_read() {
// T2 tries to update the row, but fails because T3 has already committed an update to the row,
// so T2 trying to write would violate snapshot isolation if it succeeded.
let tx2_newrow = generate_simple_string_row(1, 1, "Third");
let update_result = db
.mvcc_store
.update(tx2, tx2_newrow, conn2.pager.borrow().clone());
let update_result = db.mvcc_store.update(tx2, tx2_newrow);
assert!(matches!(update_result, Err(LimboError::WriteWriteConflict)));
}
@@ -524,18 +510,14 @@ fn test_lost_update() {
let conn2 = db.db.connect().unwrap();
let tx2 = db.mvcc_store.begin_tx(conn2.pager.borrow().clone());
let tx2_row = generate_simple_string_row(1, 1, "World");
assert!(db
.mvcc_store
.update(tx2, tx2_row.clone(), conn2.pager.borrow().clone())
.unwrap());
assert!(db.mvcc_store.update(tx2, tx2_row.clone()).unwrap());
// T3 also attempts to update row ID 1 within an active transaction.
let conn3 = db.db.connect().unwrap();
let tx3 = db.mvcc_store.begin_tx(conn3.pager.borrow().clone());
let tx3_row = generate_simple_string_row(1, 1, "Hello, world!");
assert!(matches!(
db.mvcc_store
.update(tx3, tx3_row, conn3.pager.borrow().clone(),),
db.mvcc_store.update(tx3, tx3_row),
Err(LimboError::WriteWriteConflict)
));
@@ -577,10 +559,7 @@ fn test_committed_visibility() {
let conn2 = db.db.connect().unwrap();
let tx2 = db.mvcc_store.begin_tx(conn2.pager.borrow().clone());
let tx2_row = generate_simple_string_row(1, 1, "20");
assert!(db
.mvcc_store
.update(tx2, tx2_row.clone(), conn2.pager.borrow().clone())
.unwrap());
assert!(db.mvcc_store.update(tx2, tx2_row.clone()).unwrap());
let row = db
.mvcc_store
.read(

View File

@@ -134,8 +134,7 @@ mod tests {
row_id: id,
};
let row = generate_simple_string_row(1, id.row_id, &format!("{prefix} @{tx}"));
if let Err(e) = mvcc_store.upsert(tx, row.clone(), conn.pager.borrow().clone())
{
if let Err(e) = mvcc_store.upsert(tx, row.clone()) {
tracing::trace!("upsert failed: {e}");
failed_upserts += 1;
continue;

View File

@@ -4655,7 +4655,7 @@ impl BTreeCursor {
pub fn delete(&mut self) -> Result<IOResult<()>> {
if let Some(mv_cursor) = &self.mv_cursor {
let rowid = mv_cursor.borrow_mut().current_row_id().unwrap();
mv_cursor.borrow_mut().delete(rowid, self.pager.clone())?;
mv_cursor.borrow_mut().delete(rowid)?;
return Ok(IOResult::Done(()));
}