~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rnext.cc

  • Committer: Brian Aker
  • Date: 2009-04-17 01:45:33 UTC
  • Revision ID: brian@gaz-20090417014533-exdrtriab9zecqs2
Refactor get_variable to session

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "heapdef.h"
17
17
 
 
18
#include <string.h>
 
19
 
18
20
/* Read next record with the same key */
19
21
 
20
 
int heap_rnext(HP_INFO *info, uchar *record)
 
22
int heap_rnext(HP_INFO *info, unsigned char *record)
21
23
{
22
 
  uchar *pos;
 
24
  unsigned char *pos;
23
25
  HP_SHARE *share=info->s;
24
26
  HP_KEYDEF *keyinfo;
25
 
  
 
27
 
26
28
  if (info->lastinx < 0)
27
29
    return(my_errno=HA_ERR_WRONG_INDEX);
28
30
 
38
40
        or heap_rfirst(). As last key position (info->last_pos) is available,
39
41
        we only need to climb the tree using tree_search_next().
40
42
      */
41
 
      pos = tree_search_next(&keyinfo->rb_tree, &info->last_pos,
42
 
                             offsetof(TREE_ELEMENT, left),
43
 
                             offsetof(TREE_ELEMENT, right));
 
43
      pos = (unsigned char *)tree_search_next(&keyinfo->rb_tree,
 
44
                                              &info->last_pos,
 
45
                                              offsetof(TREE_ELEMENT, left),
 
46
                                              offsetof(TREE_ELEMENT, right));
44
47
    }
45
48
    else if (!info->lastkey_len)
46
49
    {
55
58
        zero. tree_search_edge() is a kind of optimisation here as it should be
56
59
        faster than tree_search_key().
57
60
      */
58
 
      pos= tree_search_edge(&keyinfo->rb_tree, info->parents,
59
 
                            &info->last_pos, offsetof(TREE_ELEMENT, left));
 
61
      pos= (unsigned char *)tree_search_edge(&keyinfo->rb_tree, info->parents,
 
62
                                             &info->last_pos,
 
63
                                             offsetof(TREE_ELEMENT, left));
60
64
    }
61
65
    else
62
66
    {
69
73
      custom_arg.keyseg = keyinfo->seg;
70
74
      custom_arg.key_length = info->lastkey_len;
71
75
      custom_arg.search_flag = SEARCH_SAME | SEARCH_FIND;
72
 
      pos = tree_search_key(&keyinfo->rb_tree, info->lastkey, info->parents, 
73
 
                           &info->last_pos, info->last_find_flag, &custom_arg);
 
76
      pos = (unsigned char *)tree_search_key(&keyinfo->rb_tree,
 
77
                                             info->lastkey, info->parents,
 
78
                                             &info->last_pos,
 
79
                                             info->last_find_flag,
 
80
                                             &custom_arg);
74
81
    }
75
82
    if (pos)
76
83
    {
77
 
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), 
78
 
             sizeof(uchar*));
 
84
      memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos),
 
85
             sizeof(unsigned char*));
79
86
      info->current_ptr = pos;
80
87
    }
81
88
    else