Promote the last cell from current page to separator, un-add it, and flush.
| 1241 | |
| 1242 | // Promote the last cell from current page to separator, un-add it, and flush. |
| 1243 | static bool pb_promote_and_flush(PageBuilder *pb, uint8_t **cells, int *cell_lens, int prev_idx) { |
| 1244 | if (!pb_ensure_leaf_cap(pb)) { |
| 1245 | return false; |
| 1246 | } |
| 1247 | pb->leaves[pb->leaf_count].max_key = 0; |
| 1248 | pb->leaves[pb->leaf_count].sep_cell = (uint8_t *)malloc(cell_lens[prev_idx]); |
| 1249 | memcpy(pb->leaves[pb->leaf_count].sep_cell, cells[prev_idx], cell_lens[prev_idx]); |
| 1250 | pb->leaves[pb->leaf_count].sep_cell_len = cell_lens[prev_idx]; |
| 1251 | |
| 1252 | // Un-add the last cell — it's promoted to the interior separator. |
| 1253 | // SQLite index B-tree interior cells are counted by integrity_check, |
| 1254 | // so this cell exists in the interior page instead of the leaf. |
| 1255 | pb->cell_count--; |
| 1256 | pb->content_offset += cell_lens[prev_idx]; |
| 1257 | pb->ptr_offset -= CELL_PTR_SIZE; |
| 1258 | |
| 1259 | pb_flush_leaf(pb); |
| 1260 | return true; |
| 1261 | } |
| 1262 | |
| 1263 | // Write an empty index leaf page. |
| 1264 | static uint32_t write_empty_index_leaf(FILE *fp, uint32_t *next_page) { |
no test coverage detected