mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 00:45:37 +01:00
Move resolution of tableid/rootpage inside MvCursor constructor
This commit is contained in:
@@ -28,9 +28,10 @@ impl<Clock: LogicalClock> MvccLazyCursor<Clock> {
|
||||
pub fn new(
|
||||
db: Arc<MvStore<Clock>>,
|
||||
tx_id: u64,
|
||||
table_id: MVTableId,
|
||||
root_page_or_table_id: i64,
|
||||
pager: Arc<Pager>,
|
||||
) -> Result<MvccLazyCursor<Clock>> {
|
||||
let table_id = db.get_table_id_from_root_page(root_page_or_table_id);
|
||||
db.maybe_initialize_table(table_id, pager)?;
|
||||
let cursor = Self {
|
||||
db,
|
||||
|
||||
@@ -759,7 +759,7 @@ fn setup_lazy_db(initial_keys: &[i64]) -> (MvccTestDb, u64) {
|
||||
.begin_tx(db.conn.pager.read().clone())
|
||||
.unwrap();
|
||||
|
||||
let table_id = MvTableId::new(-1);
|
||||
let table_id = -1;
|
||||
for i in initial_keys {
|
||||
let id = RowID::new(table_id, *i);
|
||||
let data = format!("row{i}");
|
||||
@@ -821,7 +821,7 @@ pub(crate) fn commit_tx_no_conn(
|
||||
#[test]
|
||||
fn test_lazy_scan_cursor_basic() {
|
||||
let (db, tx_id) = setup_lazy_db(&[1, 2, 3, 4, 5]);
|
||||
let table_id = MvTableId::new(-1);
|
||||
let table_id = -1;
|
||||
|
||||
let mut cursor = MvccLazyCursor::new(
|
||||
db.mvcc_store.clone(),
|
||||
@@ -856,7 +856,7 @@ fn test_lazy_scan_cursor_basic() {
|
||||
#[test]
|
||||
fn test_lazy_scan_cursor_with_gaps() {
|
||||
let (db, tx_id) = setup_test_db();
|
||||
let table_id = MvTableId::new(-1);
|
||||
let table_id = -1;
|
||||
|
||||
let mut cursor = MvccLazyCursor::new(
|
||||
db.mvcc_store.clone(),
|
||||
@@ -892,7 +892,7 @@ fn test_lazy_scan_cursor_with_gaps() {
|
||||
#[test]
|
||||
fn test_cursor_basic() {
|
||||
let (db, tx_id) = setup_lazy_db(&[1, 2, 3, 4, 5]);
|
||||
let table_id = MvTableId::new(-1);
|
||||
let table_id = -1;
|
||||
|
||||
let mut cursor = MvccLazyCursor::new(
|
||||
db.mvcc_store.clone(),
|
||||
@@ -938,7 +938,7 @@ fn test_cursor_with_empty_table() {
|
||||
.mvcc_store
|
||||
.begin_tx(db.conn.pager.read().clone())
|
||||
.unwrap();
|
||||
let table_id = MvTableId::new(-1); // Empty table
|
||||
let table_id = -1; // Empty table
|
||||
|
||||
// Test LazyScanCursor with empty table
|
||||
let mut cursor = MvccLazyCursor::new(
|
||||
@@ -955,7 +955,7 @@ fn test_cursor_with_empty_table() {
|
||||
#[test]
|
||||
fn test_cursor_modification_during_scan() {
|
||||
let (db, tx_id) = setup_lazy_db(&[1, 2, 4, 5]);
|
||||
let table_id = MvTableId::new(-1);
|
||||
let table_id = -1;
|
||||
|
||||
let mut cursor = MvccLazyCursor::new(
|
||||
db.mvcc_store.clone(),
|
||||
|
||||
@@ -1038,9 +1038,8 @@ pub fn op_open_read(
|
||||
let (_, cursor_type) = program.cursor_ref.get(*cursor_id).unwrap();
|
||||
let mv_cursor = if let Some(tx_id) = program.connection.get_mv_tx_id() {
|
||||
let mv_store = mv_store.unwrap().clone();
|
||||
let table_id = mv_store.get_table_id_from_root_page(*root_page);
|
||||
let mv_cursor = Arc::new(RwLock::new(
|
||||
MvCursor::new(mv_store, tx_id, table_id, pager.clone()).unwrap(),
|
||||
MvCursor::new(mv_store, tx_id, *root_page, pager.clone()).unwrap(),
|
||||
));
|
||||
Some(mv_cursor)
|
||||
} else {
|
||||
@@ -6649,9 +6648,8 @@ pub fn op_open_write(
|
||||
};
|
||||
let mv_cursor = if let Some(tx_id) = program.connection.get_mv_tx_id() {
|
||||
let mv_store = mv_store.unwrap().clone();
|
||||
let table_id = mv_store.get_table_id_from_root_page(root_page);
|
||||
let mv_cursor = Arc::new(RwLock::new(
|
||||
MvCursor::new(mv_store.clone(), tx_id, table_id, pager.clone()).unwrap(),
|
||||
MvCursor::new(mv_store.clone(), tx_id, root_page, pager.clone()).unwrap(),
|
||||
));
|
||||
Some(mv_cursor)
|
||||
} else {
|
||||
@@ -7421,9 +7419,8 @@ pub fn op_open_ephemeral(
|
||||
let (_, cursor_type) = program.cursor_ref.get(cursor_id).unwrap();
|
||||
let mv_cursor = if let Some(tx_id) = program.connection.get_mv_tx_id() {
|
||||
let mv_store = mv_store.unwrap().clone();
|
||||
let table_id = mv_store.get_table_id_from_root_page(root_page);
|
||||
let mv_cursor = Arc::new(RwLock::new(
|
||||
MvCursor::new(mv_store.clone(), tx_id, table_id, pager.clone()).unwrap(),
|
||||
MvCursor::new(mv_store.clone(), tx_id, root_page, pager.clone()).unwrap(),
|
||||
));
|
||||
Some(mv_cursor)
|
||||
} else {
|
||||
@@ -7520,11 +7517,10 @@ pub fn op_open_dup(
|
||||
|
||||
let mv_cursor = if let Some(tx_id) = program.connection.get_mv_tx_id() {
|
||||
let mv_store = mv_store.unwrap().clone();
|
||||
let table_id = mv_store.get_table_id_from_root_page(root_page);
|
||||
let mv_cursor = Arc::new(RwLock::new(MvCursor::new(
|
||||
mv_store,
|
||||
tx_id,
|
||||
table_id,
|
||||
root_page,
|
||||
pager.clone(),
|
||||
)?));
|
||||
Some(mv_cursor)
|
||||
|
||||
Reference in New Issue
Block a user