mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
WL#3700: 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.
This commit is contained in:
parent
6e1ba88418
commit
4e8b49d656
58 changed files with 483 additions and 441 deletions
|
|
@ -238,34 +238,35 @@ int ha_heap::delete_row(const byte * buf)
|
|||
return res;
|
||||
}
|
||||
|
||||
int ha_heap::index_read(byte * buf, const byte * key, uint key_len,
|
||||
int ha_heap::index_read(byte * buf, const byte * key, ulonglong keypart_map,
|
||||
enum ha_rkey_function find_flag)
|
||||
{
|
||||
DBUG_ASSERT(inited==INDEX);
|
||||
statistic_increment(table->in_use->status_var.ha_read_key_count,
|
||||
&LOCK_status);
|
||||
int error = heap_rkey(file,buf,active_index, key, key_len, find_flag);
|
||||
int error = heap_rkey(file,buf,active_index, key, keypart_map, find_flag);
|
||||
table->status = error ? STATUS_NOT_FOUND : 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
int ha_heap::index_read_last(byte *buf, const byte *key, uint key_len)
|
||||
int ha_heap::index_read_last(byte *buf, const byte *key, ulonglong keypart_map)
|
||||
{
|
||||
DBUG_ASSERT(inited==INDEX);
|
||||
statistic_increment(table->in_use->status_var.ha_read_key_count,
|
||||
&LOCK_status);
|
||||
int error= heap_rkey(file, buf, active_index, key, key_len,
|
||||
int error= heap_rkey(file, buf, active_index, key, keypart_map,
|
||||
HA_READ_PREFIX_LAST);
|
||||
table->status= error ? STATUS_NOT_FOUND : 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
int ha_heap::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)
|
||||
{
|
||||
statistic_increment(table->in_use->status_var.ha_read_key_count,
|
||||
&LOCK_status);
|
||||
int error = heap_rkey(file, buf, index, key, key_len, find_flag);
|
||||
int error = heap_rkey(file, buf, index, key, keypart_map, find_flag);
|
||||
table->status = error ? STATUS_NOT_FOUND : 0;
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ public:
|
|||
ulonglong nb_desired_values,
|
||||
ulonglong *first_value,
|
||||
ulonglong *nb_reserved_values);
|
||||
int index_read(byte * buf, const byte * key,
|
||||
uint key_len, enum ha_rkey_function find_flag);
|
||||
int index_read_idx(byte * buf, uint idx, const byte * key,
|
||||
uint key_len, enum ha_rkey_function find_flag);
|
||||
int index_read_last(byte * buf, const byte * key, uint key_len);
|
||||
int index_read(byte * buf, const byte * key, ulonglong keypart_map,
|
||||
enum ha_rkey_function find_flag);
|
||||
int index_read_last(byte *buf, const byte *key, ulonglong keypart_map);
|
||||
int index_read_idx(byte * buf, uint index, const byte * key,
|
||||
ulonglong keypart_map, enum ha_rkey_function find_flag);
|
||||
int index_next(byte * buf);
|
||||
int index_prev(byte * buf);
|
||||
int index_first(byte * buf);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ extern int hp_close(register HP_INFO *info);
|
|||
extern void hp_clear(HP_SHARE *info);
|
||||
extern void hp_clear_keys(HP_SHARE *info);
|
||||
extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
|
||||
uint k_len);
|
||||
ulonglong keypart_map);
|
||||
#ifdef THREAD
|
||||
extern pthread_mutex_t THR_LOCK_heap;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -784,30 +784,26 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key,
|
|||
|
||||
|
||||
uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
|
||||
uint k_len)
|
||||
ulonglong keypart_map)
|
||||
{
|
||||
HA_KEYSEG *seg, *endseg;
|
||||
uchar *start_key= key;
|
||||
|
||||
for (seg= keydef->seg, endseg= seg + keydef->keysegs;
|
||||
seg < endseg && (int) k_len > 0; old+= seg->length, seg++)
|
||||
seg < endseg && keypart_map; old+= seg->length, seg++)
|
||||
{
|
||||
uint char_length;
|
||||
keypart_map>>= 1;
|
||||
if (seg->null_bit)
|
||||
{
|
||||
k_len--;
|
||||
if (!(*key++= (char) 1 - *old++))
|
||||
{
|
||||
k_len-= seg->length;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (seg->flag & HA_SWAP_KEY)
|
||||
{
|
||||
uint length= seg->length;
|
||||
byte *pos= (byte*) old + length;
|
||||
|
||||
k_len-= length;
|
||||
while (length--)
|
||||
{
|
||||
*key++= *--pos;
|
||||
|
|
@ -822,7 +818,6 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
|
|||
CHARSET_INFO *cs= seg->charset;
|
||||
char_length= length/cs->mbmaxlen;
|
||||
|
||||
k_len-= 2+length;
|
||||
old+= 2;
|
||||
set_if_smaller(length,tmp_length); /* Safety */
|
||||
FIX_LENGTH(cs, old, length, char_length);
|
||||
|
|
@ -843,7 +838,6 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
|
|||
}
|
||||
memcpy(key, old, (size_t) char_length);
|
||||
key+= seg->length;
|
||||
k_len-= seg->length;
|
||||
}
|
||||
return (uint) (key - start_key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include "heapdef.h"
|
||||
|
||||
int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key,
|
||||
uint key_len, enum ha_rkey_function find_flag)
|
||||
ulonglong keypart_map, enum ha_rkey_function find_flag)
|
||||
{
|
||||
byte *pos;
|
||||
HP_SHARE *share= info->s;
|
||||
|
|
@ -38,7 +38,7 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key,
|
|||
custom_arg.keyseg= info->s->keydef[inx].seg;
|
||||
custom_arg.key_length= info->lastkey_len=
|
||||
hp_rb_pack_key(keyinfo, (uchar*) info->lastkey,
|
||||
(uchar*) key, key_len);
|
||||
(uchar*) key, keypart_map);
|
||||
custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
|
||||
/* for next rkey() after deletion */
|
||||
if (find_flag == HA_READ_AFTER_KEY)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue