WL#3700: Handler change: keypart_map instead of key_len

Affects: Server-5.1   —   Status: Complete   —   Priority: Low

Pass a bitmap of used keyparts instead of key length to index lookup methods in
the handler class

Resons for doing this change:

- Enables engines to use new index methods:
  - Bitmap indexes
  - Indexes where you can use any key part for searches
- Enables optimzer enhancements like loose scan

- Brian and Monty agreed that this should be done in 5.1 so that we can keep the
interface stable in 5.2

This worklog item is loosely depening on the change where we change the key
storage so that we have a length before CHAR key parts. (Otherwise we loose the
possibility to add support to partial keys, ie 'char_key like "AB%")

Handler API change: all index search methods - that is, index_read(),
index_read_idx(), index_read_last(), and records_in_range() -
instead of 'uint keylen' argument take 'ulonglong keypart_map',
a bitmap showing which keyparts are present in the key value.
Fallback method is provided for handlers that are lagging behind.
keypart_map is a bitmap, one bit per keypart, 1 for keypart[0], 2 for
keypart[1], 4 for keypart[2], and so on. If a bit in keypart_map is set, the
value for this keypart is present in the key buffer. Bits after the last keypart
don't matter - that is ~0 can be used for "all keyparts". So far only key
prefixes are supported - that is assert((keypart_map + 1) & keypart_map == 0)

Interface change:
^^^^^^^^^^^^^^^^^

-  virtual int index_read(byte * buf, const byte * key,
-                        uint key_len, enum ha_rkey_function find_flag)
+  virtual int index_read(byte * buf, const byte * key, ulonglong keypart_map,
+                         enum ha_rkey_function find_flag)


   virtual int index_read_idx(byte * buf, uint index, const byte * key,
-                            uint key_len, enum ha_rkey_function find_flag);
+                             ulonglong keypart_map,
+                             enum ha_rkey_function find_flag);


-  virtual int index_read_last(byte * buf, const byte * key, uint key_len)
+  virtual int index_read_last(byte * buf, const byte * key,
+                              ulonglong keypart_map)

 typedef struct st_key_range
 {
   const byte *key;
   uint length;
+  ulonglong keypart_map;
   enum ha_rkey_function flag;
 } key_range;


Fallback methods:
^^^^^^^^^^^^^^^^^

  private:
  virtual int index_read(byte * buf, const byte * key, uint key_len,
                         enum ha_rkey_function find_flag)
    { return  HA_ERR_WRONG_COMMAND; }
  public:
  virtual int index_read(byte * buf, const byte * key, ulonglong keypart_map,
                         enum ha_rkey_function find_flag)
   {
     uint key_len= calculate_key_len(table, active_index, key, keypart_map);
     return  index_read(buf, key, key_len, find_flag);
   }

and the same for index_read_last().