Promote the last cell from current page to separator, un-add it, and flush.
| 1220 | |
| 1221 | // Promote the last cell from current page to separator, un-add it, and flush. |
| 1222 | static bool pb_promote_and_flush(PageBuilder *pb, uint8_t **cells, int *cell_lens, int prev_idx) { |
| 1223 | if (!pb_ensure_leaf_cap(pb)) { |
| 1224 | return false; |
| 1225 | } |
| 1226 | pb->leaves[pb->leaf_count].max_key = 0; |
| 1227 | pb->leaves[pb->leaf_count].sep_cell = (uint8_t *)malloc(cell_lens[prev_idx]); |
| 1228 | memcpy(pb->leaves[pb->leaf_count].sep_cell, cells[prev_idx], cell_lens[prev_idx]); |
| 1229 | pb->leaves[pb->leaf_count].sep_cell_len = cell_lens[prev_idx]; |
| 1230 | |
| 1231 | // Un-add the last cell — it's promoted to the interior separator. |
| 1232 | // SQLite index B-tree interior cells are counted by integrity_check, |
| 1233 | // so this cell exists in the interior page instead of the leaf. |
| 1234 | pb->cell_count--; |
| 1235 | pb->content_offset += cell_lens[prev_idx]; |
| 1236 | pb->ptr_offset -= CELL_PTR_SIZE; |
| 1237 | |
| 1238 | pb_flush_leaf(pb); |
| 1239 | return true; |
| 1240 | } |
| 1241 | |
| 1242 | // Write an empty index leaf page. |
| 1243 | static uint32_t write_empty_index_leaf(FILE *fp, uint32_t *next_page) { |
no test coverage detected