~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rfirst.c

  • Committer: brian
  • Date: 2008-07-03 12:39:14 UTC
  • Revision ID: brian@localhost.localdomain-20080703123914-lry82qf74f6cbyzs
Disabling myisam tools until incomming link patch from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
/* Read first record with the current key */
19
19
 
20
 
int heap_rfirst(HP_INFO *info, unsigned char *record, int inx)
 
20
int heap_rfirst(HP_INFO *info, uchar *record, int inx)
21
21
{
22
22
  HP_SHARE *share = info->s;
23
23
  HP_KEYDEF *keyinfo = share->keydef + inx;
24
24
  
 
25
  DBUG_ENTER("heap_rfirst");
25
26
  info->lastinx= inx;
26
27
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
27
28
  {
28
 
    unsigned char *pos;
 
29
    uchar *pos;
29
30
 
30
31
    if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents,
31
32
                                &info->last_pos, offsetof(TREE_ELEMENT, left))))
32
33
    {
33
34
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 
34
 
             sizeof(unsigned char*));
 
35
             sizeof(uchar*));
35
36
      info->current_ptr = pos;
36
 
      hp_extract_record(share, record, pos);
 
37
      memcpy(record, pos, (size_t)share->reclength);
37
38
      /*
38
39
        If we're performing index_first on a table that was taken from
39
40
        table cache, info->lastkey_len is initialized to previous query.
50
51
    else
51
52
    {
52
53
      my_errno = HA_ERR_END_OF_FILE;
53
 
      return(my_errno);
 
54
      DBUG_RETURN(my_errno);
54
55
    }
55
 
    return(0);
 
56
    DBUG_RETURN(0);
56
57
  }
57
58
  else
58
59
  {
59
60
    if (!(info->s->records))
60
61
    {
61
62
      my_errno=HA_ERR_END_OF_FILE;
62
 
      return(my_errno);
 
63
      DBUG_RETURN(my_errno);
63
64
    }
64
 
    assert(0); /* TODO fix it */
 
65
    DBUG_ASSERT(0); /* TODO fix it */
65
66
    info->current_record=0;
66
67
    info->current_hash_ptr=0;
67
68
    info->update=HA_STATE_PREV_FOUND;
68
 
    return(heap_rnext(info,record));
 
69
    DBUG_RETURN(heap_rnext(info,record));
69
70
  }
70
71
}