diff options
author | bar@gw.udmsearch.izhnet.ru <> | 2002-04-25 13:36:55 +0500 |
---|---|---|
committer | bar@gw.udmsearch.izhnet.ru <> | 2002-04-25 13:36:55 +0500 |
commit | eab2893dac4f2447baf6b1b2b4f70869e974bf44 (patch) | |
tree | 5b8a058772659a40e41e2025e66f79531e604613 /heap/hp_rkey.c | |
parent | c917658988937899e0c21defd4951b51b6d9ff92 (diff) | |
download | mariadb-git-eab2893dac4f2447baf6b1b2b4f70869e974bf44.tar.gz |
RB-Tree indexes support in HEAP tables
Renamed _hp_func -> hp_func
mi_key_cmp moved to /mysys/my_handler.c
New tests for HEAP tables
Diffstat (limited to 'heap/hp_rkey.c')
-rw-r--r-- | heap/hp_rkey.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/heap/hp_rkey.c b/heap/hp_rkey.c index e7a1d81fba6..649370cf0b0 100644 --- a/heap/hp_rkey.c +++ b/heap/hp_rkey.c @@ -16,10 +16,12 @@ #include "heapdef.h" -int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key) +int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, + uint key_len, enum ha_rkey_function find_flag) { byte *pos; HP_SHARE *share=info->s; + HP_KEYDEF *keyinfo = share->keydef+inx; DBUG_ENTER("heap_rkey"); DBUG_PRINT("enter",("base: %lx inx: %d",info,inx)); @@ -30,15 +32,44 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key) info->lastinx=inx; info->current_record = (ulong) ~0L; /* For heap_rrnd() */ - if (!(pos=_hp_search(info,share->keydef+inx,key,0))) + if (keyinfo->algorithm == HA_KEY_ALG_BTREE) { - info->update=0; - DBUG_RETURN(my_errno); + heap_rb_param custom_arg; + + hp_rb_pack_key(info, inx, info->recbuf, key, key_len); + + custom_arg.keyseg = info->s->keydef[inx].seg; + custom_arg.key_length = key_len; + custom_arg.search_flag = SEARCH_FIND | SEARCH_SAME; + /* for next rkey() after deletion */ + if (find_flag == HA_READ_AFTER_KEY) + info->last_find_flag = HA_READ_KEY_OR_NEXT; + else if (find_flag == HA_READ_BEFORE_KEY) + info->last_find_flag = HA_READ_KEY_OR_PREV; + else + info->last_find_flag = find_flag; + info->lastkey_len = key_len; + if (!(pos = tree_search_key(&keyinfo->rb_tree, info->recbuf, info->parents, + &info->last_pos, find_flag, &custom_arg))) + { + info->update = 0; + DBUG_RETURN(my_errno = HA_ERR_KEY_NOT_FOUND); + } + memcpy(&pos, pos + keyinfo->ref_offs, sizeof(byte*)); + info->current_ptr = pos; + } + else + { + if (!(pos=hp_search(info,share->keydef+inx,key,0))) + { + info->update=0; + DBUG_RETURN(my_errno); + } + if (!(keyinfo->flag & HA_NOSAME)) + memcpy(info->lastkey,key,(size_t) keyinfo->length); } memcpy(record,pos,(size_t) share->reclength); info->update=HA_STATE_AKTIV; - if (!(share->keydef[inx].flag & HA_NOSAME)) - memcpy(info->lastkey,key,(size_t) share->keydef[inx].length); DBUG_RETURN(0); } @@ -47,5 +78,5 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key) gptr heap_find(HP_INFO *info, int inx, const byte *key) { - return _hp_search(info,info->s->keydef+inx,key,0); + return hp_search(info, info->s->keydef + inx, key, 0); } |