39 int myrg_rkey(
MYRG_INFO *info,uchar *
buf,
int inx,
const uchar *key,
40 key_part_map keypart_map,
enum ha_rkey_function search_flag)
42 uchar *UNINIT_VAR(key_buff);
43 uint UNINIT_VAR(pack_key_length);
44 uint16 UNINIT_VAR(last_used_keyseg);
48 DBUG_ENTER(
"myrg_rkey");
50 if (_myrg_init_queue(info,inx,search_flag))
51 DBUG_RETURN(my_errno);
53 for (table=info->open_tables ; table != info->end_table ; table++)
57 if (table == info->open_tables)
59 err=mi_rkey(mi, 0, inx, key, keypart_map, search_flag);
61 key_buff=(uchar*) mi->lastkey+mi->s->base.max_key_length;
62 pack_key_length=mi->pack_key_length;
63 last_used_keyseg= mi->last_used_keyseg;
67 mi->once_flags|= USE_PACKED_KEYS;
68 mi->last_used_keyseg= last_used_keyseg;
69 err=mi_rkey(mi, 0, inx, key_buff, pack_key_length, search_flag);
71 info->last_used_table=table+1;
75 if (err == HA_ERR_KEY_NOT_FOUND)
77 DBUG_PRINT(
"exit", (
"err: %d", err));
81 queue_insert(&(info->by_key),(uchar *)table);
85 DBUG_PRINT(
"info", (
"tables with matches: %u", info->by_key.elements));
86 if (!info->by_key.elements)
87 DBUG_RETURN(HA_ERR_KEY_NOT_FOUND);
89 mi=(info->current_table=(
MYRG_TABLE *)queue_top(&(info->by_key)))->table;
90 mi->once_flags|= RRND_PRESERVE_LASTINX;
91 DBUG_PRINT(
"info", (
"using table no: %d",
92 (
int) (info->current_table - info->open_tables + 1)));
93 DBUG_DUMP(
"result key", (uchar*) mi->lastkey, mi->lastkey_length);
94 DBUG_RETURN(_myrg_mi_read_record(mi,buf));