mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-07 09:14:26 +01:00
fix Minimum cell size must not be less than 4
This commit is contained in:
@@ -6364,7 +6364,11 @@ fn compute_free_space(page: &PageContent, usable_space: u16) -> u16 {
|
||||
|
||||
/// Allocate space for a cell on a page.
|
||||
fn allocate_cell_space(page_ref: &PageContent, amount: u16, usable_space: u16) -> Result<u16> {
|
||||
let amount = amount as usize;
|
||||
let mut amount = amount as usize;
|
||||
// the minimum cell size is 4 bytes, so we need to ensure that we allocate at least that much space.
|
||||
if amount < 4 {
|
||||
amount = 4;
|
||||
}
|
||||
|
||||
let (cell_offset, _) = page_ref.cell_pointer_array_offset_and_size();
|
||||
let gap = cell_offset + 2 * page_ref.cell_count();
|
||||
|
||||
@@ -668,7 +668,11 @@ impl PageContent {
|
||||
if overflows {
|
||||
to_read + n_payload
|
||||
} else {
|
||||
len_payload as usize + n_payload
|
||||
let mut size = len_payload as usize + n_payload;
|
||||
if size < 4 {
|
||||
size = 4;
|
||||
}
|
||||
size
|
||||
}
|
||||
}
|
||||
PageType::TableLeaf => {
|
||||
@@ -683,7 +687,11 @@ impl PageContent {
|
||||
if overflows {
|
||||
to_read + n_payload + n_rowid
|
||||
} else {
|
||||
len_payload as usize + n_payload + n_rowid
|
||||
let mut size = len_payload as usize + n_payload + n_rowid;
|
||||
if size < 4 {
|
||||
size = 4;
|
||||
}
|
||||
size
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user