summaryrefslogtreecommitdiff
path: root/storage/heap
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-01-29 10:40:26 +0100
committerunknown <serg@janus.mylan>2007-01-29 10:40:26 +0100
commit57c50bacbc8da95493960a17da0a8722152fe387 (patch)
treef14bd08181ddd81d2a41f06d9bf0f11d6edf53b5 /storage/heap
parent8272457ed299ce920a5b33433658ce84014f1814 (diff)
downloadmariadb-git-57c50bacbc8da95493960a17da0a8722152fe387.tar.gz
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.
Diffstat (limited to 'storage/heap')
-rw-r--r--storage/heap/ha_heap.cc13
-rw-r--r--storage/heap/ha_heap.h10
-rw-r--r--storage/heap/heapdef.h2
-rw-r--r--storage/heap/hp_hash.c12
-rw-r--r--storage/heap/hp_rkey.c4
5 files changed, 18 insertions, 23 deletions
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 7a2f8e20c56..c0ca0af3923 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -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;
}
diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h
index 2de80c76999..b49ded6e33d 100644
--- a/storage/heap/ha_heap.h
+++ b/storage/heap/ha_heap.h
@@ -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);
diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h
index 016c83db8e0..d9c3ff147b4 100644
--- a/storage/heap/heapdef.h
+++ b/storage/heap/heapdef.h
@@ -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
diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c
index c5a30a3ef65..326f6adea45 100644
--- a/storage/heap/hp_hash.c
+++ b/storage/heap/hp_hash.c
@@ -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);
}
diff --git a/storage/heap/hp_rkey.c b/storage/heap/hp_rkey.c
index a095336d295..98714bf875f 100644
--- a/storage/heap/hp_rkey.c
+++ b/storage/heap/hp_rkey.c
@@ -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)