btree: move allocate_overflow_page to Pager impl

This commit is contained in:
Jussi Saurio
2025-04-14 15:25:15 +03:00
parent bf26e62465
commit 5628cc27a6
2 changed files with 15 additions and 15 deletions

View File

@@ -4567,7 +4567,7 @@ fn fill_cell_payload(
}
// we still have bytes to add, we will need to allocate new overflow page
let overflow_page = allocate_overflow_page(pager.clone());
let overflow_page = pager.allocate_overflow_page();
overflow_pages.push(overflow_page.clone());
{
let id = overflow_page.get().id as u32;
@@ -4590,20 +4590,6 @@ fn fill_cell_payload(
assert_eq!(cell_size, cell_payload.len());
}
/// Allocate a new overflow page.
/// This is done when a cell overflows and new space is needed.
fn allocate_overflow_page(pager: Rc<Pager>) -> PageRef {
let page = pager.allocate_page().unwrap();
tracing::debug!("allocate_overflow_page(id={})", page.get().id);
// setup overflow page
let contents = page.get().contents.as_mut().unwrap();
let buf = contents.as_ptr();
buf.fill(0);
page
}
/// Returns the maximum payload size (X) that can be stored directly on a b-tree page without spilling to overflow pages.
///
/// For table leaf pages: X = usable_size - 35

View File

@@ -217,6 +217,20 @@ impl Pager {
id as u32
}
/// Allocate a new overflow page.
/// This is done when a cell overflows and new space is needed.
pub fn allocate_overflow_page(&self) -> PageRef {
let page = self.allocate_page().unwrap();
tracing::debug!("Pager::allocate_overflow_page(id={})", page.get().id);
// setup overflow page
let contents = page.get().contents.as_mut().unwrap();
let buf = contents.as_ptr();
buf.fill(0);
page
}
/// Allocate a new page to the btree via the pager.
/// This marks the page as dirty and writes the page header.
pub fn do_allocate_page(&self, page_type: PageType, offset: usize) -> PageRef {