Visitar URL original
Bug with internal_node_key() · Issue #91 · cstack/db_tutorial · GitHub
Skip to content

Bug with internal_node_key() #91

Description

@zhou-zheng

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions