~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rkey.c

  • Committer: Monty Taylor
  • Date: 2008-11-16 23:47:43 UTC
  • mto: (584.1.10 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116234743-c38gmv0pa2kdefaj
Broke out cached_item.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "heap_priv.h"
17
 
 
18
 
#include <string.h>
19
 
 
20
 
using namespace drizzled;
21
 
 
22
 
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key,
 
16
#include "heapdef.h"
 
17
 
 
18
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key, 
23
19
              key_part_map keypart_map, enum ha_rkey_function find_flag)
24
20
{
25
21
  unsigned char *pos;
28
24
 
29
25
  if ((uint) inx >= share->keys)
30
26
  {
31
 
    return(errno= HA_ERR_WRONG_INDEX);
 
27
    return(my_errno= HA_ERR_WRONG_INDEX);
32
28
  }
33
29
  info->lastinx= inx;
34
30
  info->current_record= UINT32_MAX;             /* For heap_rrnd() */
38
34
    heap_rb_param custom_arg;
39
35
 
40
36
    custom_arg.keyseg= info->s->keydef[inx].seg;
41
 
    custom_arg.key_length= info->lastkey_len=
 
37
    custom_arg.key_length= info->lastkey_len= 
42
38
      hp_rb_pack_key(keyinfo, (unsigned char*) info->lastkey,
43
39
                     (unsigned char*) key, keypart_map);
44
40
    custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
49
45
      info->last_find_flag= HA_READ_KEY_OR_PREV;
50
46
    else
51
47
      info->last_find_flag= find_flag;
52
 
    if (!(pos= (unsigned char *)tree_search_key(&keyinfo->rb_tree,
53
 
                                                info->lastkey, info->parents,
54
 
                                                &info->last_pos,
55
 
                                                find_flag, &custom_arg)))
 
48
    if (!(pos= tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents,
 
49
                               &info->last_pos, find_flag, &custom_arg)))
56
50
    {
57
51
      info->update= 0;
58
 
      return(errno= HA_ERR_KEY_NOT_FOUND);
 
52
      return(my_errno= HA_ERR_KEY_NOT_FOUND);
59
53
    }
60
54
    memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(unsigned char*));
61
55
    info->current_ptr= pos;
65
59
    if (!(pos= hp_search(info, share->keydef + inx, key, 0)))
66
60
    {
67
61
      info->update= 0;
68
 
      return(errno);
 
62
      return(my_errno);
69
63
    }
70
64
    if (!(keyinfo->flag & HA_NOSAME))
71
65
      memcpy(info->lastkey, key, (size_t) keyinfo->length);