Documentation Home
MySQL Internals Manual

MySQL Internals Manual  /  ...  /  Parsing Key Information

23.16.4 Parsing Key Information

Many of the index methods pass a byte array named *key that identifies the index entry to be read in a standard format. Your storage engine will need to extract the information stored in the key and translate it into its internal index format to identify the row associated with the index.

The information in the key is obtained by iterating through the key, which is formatted the same as the definition in table->key_info[index]->key_part[part_num].

Along with the key, handler methods pass a keypart_map parameter to indicate which parts of the key are present in the key parameter. keypart_map is a ulonglong bitmap with one bit per key part: 1 for keypart[0], 2 for keypart[1], 4 for keypart[2], and so forth. If a bit in keypart_map is set, the value for this key part is present in the key buffer. Bits following the bit for the last key part don't matter,so ~0 can be used for all keyparts. Currently, only key prefixes are supported. That is, assert((keypart_map + 1) & keypart_map == 0).

A keypart_map is part of the key_range structure used by records_in_range(), and a keypart_map value is passed directly to the index_read(), index_read_idx(), and index_read_last() methods.

Older handlers have a key_len parameter instead of keypart_map. The key_len value is a uint that indicates the prefix length when matching by prefix.

User Comments
Sign Up Login You must be logged in to post a comment.