mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-27 13:04:20 +01:00
- When an interior index cell is replaced, it can cause the page where the replacement happens to overflow OR underflow. On `main` we did not check this case, because the interior cell replacement always moves the cursor to a leaf, and if the leaf doesn't underflow, then no further balancing happens. - The solution is to ALWAYS check whether the interior page where the replacement happens is underflowing OR overflowing, and balance that page regardless of whether the leaf page where the replacement was taken underflows or not. So summary: - InteriorCellReplacement: cell deleted from Interior page I, replacement cell taken from Leaf L and inserted back to Interior page I. - If Leaf L underflows: * balance it first * then balance I if it overflows OR underflows - If Leaf L does NOT underflow: * balance I anyway if it overflows OR underflows Closes https://github.com/tursodatabase/turso/issues/1701 Closes https://github.com/tursodatabase/turso/issues/2167 Reviewed-by: Pere Diaz Bou <pere-altea@homail.com> Closes #2168