mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Heap table code cleanup
This commit is contained in:
@ -20,56 +20,56 @@ 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;
|
||||
HP_SHARE *share= info->s;
|
||||
HP_KEYDEF *keyinfo= share->keydef + inx;
|
||||
DBUG_ENTER("heap_rkey");
|
||||
DBUG_PRINT("enter",("base: %lx inx: %d",info,inx));
|
||||
|
||||
if ((uint) inx >= share->keys)
|
||||
{
|
||||
DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
|
||||
DBUG_RETURN(my_errno= HA_ERR_WRONG_INDEX);
|
||||
}
|
||||
info->lastinx=inx;
|
||||
info->current_record = (ulong) ~0L; /* For heap_rrnd() */
|
||||
info->lastinx= inx;
|
||||
info->current_record= (ulong) ~0L; /* For heap_rrnd() */
|
||||
|
||||
if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
|
||||
{
|
||||
heap_rb_param custom_arg;
|
||||
|
||||
hp_rb_pack_key(info, inx, info->recbuf, key, key_len);
|
||||
hp_rb_pack_key(keyinfo, info->recbuf, key);
|
||||
|
||||
custom_arg.keyseg = info->s->keydef[inx].seg;
|
||||
custom_arg.key_length = key_len;
|
||||
custom_arg.search_flag = SEARCH_FIND | SEARCH_SAME;
|
||||
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;
|
||||
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;
|
||||
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->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);
|
||||
info->update= 0;
|
||||
DBUG_RETURN(my_errno= HA_ERR_KEY_NOT_FOUND);
|
||||
}
|
||||
memcpy(&pos, pos + hp_rb_key_length(keyinfo, pos), sizeof(byte*));
|
||||
info->current_ptr = pos;
|
||||
memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(byte*));
|
||||
info->current_ptr= pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(pos=hp_search(info,share->keydef+inx,key,0)))
|
||||
if (!(pos= hp_search(info, share->keydef + inx, key, 0)))
|
||||
{
|
||||
info->update=0;
|
||||
info->update= 0;
|
||||
DBUG_RETURN(my_errno);
|
||||
}
|
||||
if (!(keyinfo->flag & HA_NOSAME))
|
||||
memcpy(info->lastkey,key,(size_t) keyinfo->length);
|
||||
memcpy(info->lastkey, key, (size_t) keyinfo->length);
|
||||
}
|
||||
memcpy(record,pos,(size_t) share->reclength);
|
||||
info->update=HA_STATE_AKTIV;
|
||||
memcpy(record, pos, (size_t) share->reclength);
|
||||
info->update= HA_STATE_AKTIV;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user