~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rkey.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "heapdef.h"
17
17
 
18
 
int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, 
 
18
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key, 
19
19
              key_part_map keypart_map, enum ha_rkey_function find_flag)
20
20
{
21
 
  uchar *pos;
 
21
  unsigned char *pos;
22
22
  HP_SHARE *share= info->s;
23
23
  HP_KEYDEF *keyinfo= share->keydef + inx;
24
 
  DBUG_ENTER("heap_rkey");
25
 
  DBUG_PRINT("enter",("info: 0x%lx  inx: %d", (long) info, inx));
26
24
 
27
25
  if ((uint) inx >= share->keys)
28
26
  {
29
 
    DBUG_RETURN(my_errno= HA_ERR_WRONG_INDEX);
 
27
    return(my_errno= HA_ERR_WRONG_INDEX);
30
28
  }
31
29
  info->lastinx= inx;
32
 
  info->current_record= (ulong) ~0L;            /* For heap_rrnd() */
 
30
  info->current_record= UINT32_MAX;             /* For heap_rrnd() */
33
31
 
34
32
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
35
33
  {
37
35
 
38
36
    custom_arg.keyseg= info->s->keydef[inx].seg;
39
37
    custom_arg.key_length= info->lastkey_len= 
40
 
      hp_rb_pack_key(keyinfo, (uchar*) info->lastkey,
41
 
                     (uchar*) key, keypart_map);
 
38
      hp_rb_pack_key(keyinfo, (unsigned char*) info->lastkey,
 
39
                     (unsigned char*) key, keypart_map);
42
40
    custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
43
41
    /* for next rkey() after deletion */
44
42
    if (find_flag == HA_READ_AFTER_KEY)
51
49
                               &info->last_pos, find_flag, &custom_arg)))
52
50
    {
53
51
      info->update= 0;
54
 
      DBUG_RETURN(my_errno= HA_ERR_KEY_NOT_FOUND);
 
52
      return(my_errno= HA_ERR_KEY_NOT_FOUND);
55
53
    }
56
 
    memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(uchar*));
 
54
    memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(unsigned char*));
57
55
    info->current_ptr= pos;
58
56
  }
59
57
  else
61
59
    if (!(pos= hp_search(info, share->keydef + inx, key, 0)))
62
60
    {
63
61
      info->update= 0;
64
 
      DBUG_RETURN(my_errno);
 
62
      return(my_errno);
65
63
    }
66
64
    if (!(keyinfo->flag & HA_NOSAME))
67
65
      memcpy(info->lastkey, key, (size_t) keyinfo->length);
68
66
  }
69
 
  memcpy(record, pos, (size_t) share->reclength);
 
67
  hp_extract_record(share, record, pos);
70
68
  info->update= HA_STATE_AKTIV;
71
 
  DBUG_RETURN(0);
 
69
  return(0);
72
70
}
73
71
 
74
72
 
75
73
        /* Quick find of record */
76
74
 
77
 
uchar* heap_find(HP_INFO *info, int inx, const uchar *key)
 
75
unsigned char* heap_find(HP_INFO *info, int inx, const unsigned char *key)
78
76
{
79
77
  return hp_search(info, info->s->keydef + inx, key, 0);
80
78
}