From 6d2ca582356a5d8ffab11bec6401d2d8f582fe28 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Tue, 10 Jun 2025 14:14:52 +0300 Subject: [PATCH] get_prev_record() small fixes --- core/storage/btree.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 5388a9d48..602585e59 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -626,7 +626,7 @@ impl BTreeCursor { } if cell_idx >= cell_count as i32 { self.stack.set_cell_index(cell_count as i32 - 1); - } else { + } else if !self.stack.current_cell_index_less_than_min() { let is_index = page.is_index(); // skip retreat in case we still haven't visited this cell in index let should_visit_internal_node = is_index && self.going_upwards; // we are going upwards, this means we still need to visit divider cell in an index @@ -1142,9 +1142,9 @@ impl BTreeCursor { let is_index = mem_page_rc.get().is_index(); let should_skip_advance = is_index && self.going_upwards // we are going upwards, this means we still need to visit divider cell in an index - && self.stack.current_cell_index() < cell_count as i32; // if we weren't on a - // valid cell then it means we will have to move upwards again or move to right page, - // anyways, we won't visit this invalid cell index + && self.stack.current_cell_index() >= 0 && self.stack.current_cell_index() < cell_count as i32; // if we weren't on a + // valid cell then it means we will have to move upwards again or move to right page, + // anyways, we won't visit this invalid cell index if should_skip_advance { tracing::debug!( "next: skipping advance, going_upwards: {}, page: {}, cell_idx: {}",