diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 7e2b2b566..6869cf298 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -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) -> 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 diff --git a/core/storage/pager.rs b/core/storage/pager.rs index 9d7affa95..47dc5451c 100644 --- a/core/storage/pager.rs +++ b/core/storage/pager.rs @@ -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 {