~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memory/hp_rkey.cc

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 18:24:24 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212182424-kgnm9osi7qo97at2
casts

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
#include "heap_priv.h"
17
17
 
20
20
using namespace drizzled;
21
21
 
22
22
int heap_rkey(HP_INFO *info, unsigned char *record, int inx, const unsigned char *key,
23
 
              key_part_map keypart_map, enum ha_rkey_function find_flag)
 
23
              key_part_map , enum ha_rkey_function )
24
24
{
25
25
  unsigned char *pos;
26
 
  HP_SHARE *share= info->s;
 
26
  HP_SHARE *share= info->getShare();
27
27
  HP_KEYDEF *keyinfo= share->keydef + inx;
28
28
 
29
29
  if ((uint) inx >= share->keys)
32
32
  }
33
33
  info->lastinx= inx;
34
34
  info->current_record= UINT32_MAX;             /* For heap_rrnd() */
35
 
 
36
 
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
37
 
  {
38
 
    heap_rb_param custom_arg;
39
 
 
40
 
    custom_arg.keyseg= info->s->keydef[inx].seg;
41
 
    custom_arg.key_length= info->lastkey_len=
42
 
      hp_rb_pack_key(keyinfo, (unsigned char*) info->lastkey,
43
 
                     (unsigned char*) key, keypart_map);
44
 
    custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
45
 
    /* for next rkey() after deletion */
46
 
    if (find_flag == HA_READ_AFTER_KEY)
47
 
      info->last_find_flag= HA_READ_KEY_OR_NEXT;
48
 
    else if (find_flag == HA_READ_BEFORE_KEY)
49
 
      info->last_find_flag= HA_READ_KEY_OR_PREV;
50
 
    else
51
 
      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)))
56
 
    {
57
 
      info->update= 0;
58
 
      return(errno= HA_ERR_KEY_NOT_FOUND);
59
 
    }
60
 
    memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(unsigned char*));
61
 
    info->current_ptr= pos;
62
 
  }
63
 
  else
64
35
  {
65
36
    if (!(pos= hp_search(info, share->keydef + inx, key, 0)))
66
37
    {
68
39
      return(errno);
69
40
    }
70
41
    if (!(keyinfo->flag & HA_NOSAME))
71
 
      memcpy(info->lastkey, key, (size_t) keyinfo->length);
 
42
      memcpy(&info->lastkey[0], key, (size_t) keyinfo->length);
72
43
  }
73
44
  hp_extract_record(share, record, pos);
74
45
  info->update= HA_STATE_AKTIV;
80
51
 
81
52
unsigned char* heap_find(HP_INFO *info, int inx, const unsigned char *key)
82
53
{
83
 
  return hp_search(info, info->s->keydef + inx, key, 0);
 
54
  return hp_search(info, info->getShare()->keydef + inx, key, 0);
84
55
}