~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/hp_rnext.cc

  • Committer: Brian Aker
  • Date: 2010-01-27 18:58:12 UTC
  • Revision ID: brian@gaz-20100127185812-n62n0vwetnx8jrjy
Remove dead code.

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 "heapdef.h"
 
16
#include "heap_priv.h"
 
17
 
 
18
#include <string.h>
17
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
 
    return(my_errno=HA_ERR_WRONG_INDEX);
 
29
    return(errno=HA_ERR_WRONG_INDEX);
28
30
 
29
31
  keyinfo = share->keydef + info->lastinx;
30
32
  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
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
82
89
    {
83
 
      my_errno = HA_ERR_KEY_NOT_FOUND;
 
90
      errno = HA_ERR_KEY_NOT_FOUND;
84
91
    }
85
92
  }
86
93
  else
93
100
      if (!info->current_ptr && (info->update & HA_STATE_NEXT_FOUND))
94
101
      {
95
102
        pos=0;                                  /* Read next after last */
96
 
        my_errno=HA_ERR_KEY_NOT_FOUND;
 
103
        errno=HA_ERR_KEY_NOT_FOUND;
97
104
      }
98
105
      else if (!info->current_ptr)              /* Deleted or first call */
99
106
        pos= hp_search(info, keyinfo, info->lastkey, 0);
104
111
  if (!pos)
105
112
  {
106
113
    info->update=HA_STATE_NEXT_FOUND;           /* For heap_rprev */
107
 
    if (my_errno == HA_ERR_KEY_NOT_FOUND)
108
 
      my_errno=HA_ERR_END_OF_FILE;
109
 
    return(my_errno);
 
114
    if (errno == HA_ERR_KEY_NOT_FOUND)
 
115
      errno=HA_ERR_END_OF_FILE;
 
116
    return(errno);
110
117
  }
111
118
  hp_extract_record(share, record, pos);
112
119
  info->update=HA_STATE_AKTIV | HA_STATE_NEXT_FOUND;