db_tutorial icon indicating copy to clipboard operation
db_tutorial copied to clipboard

Bug with internal_node_key()

Open zhou-zheng opened this issue 3 years ago • 0 comments

Hi, there! Great work! But I found a bug:

uint32_t *internal_node_key(void *node, uint32_t key_num)
{
    return internal_node_cell(node, key_num) + INTERNAL_NODE_CHILD_SIZE;
}

should be

uint32_t *internal_node_key(void *node, uint32_t key_num)
{
    return internal_node_cell(node, key_num) + INTERNAL_NODE_CHILD_SIZE/sizeof(uint32_t);
}

Otherwise, the position of max key would get a 12 bytes offset compared to Internal Node Header Layout because the internal_node_cell() returns a uint32_t pointer, which means, when we plus INTERNAL_NODE_CHILD_SIZE(4 bytes) to it, it would be 4*4 =16bytes.

zhou-zheng avatar Nov 22 '22 05:11 zhou-zheng