16 #include "myisamdef.h"
27 int mi_rnext(
MI_INFO *info, uchar *
buf,
int inx)
32 uint update_mask= HA_STATE_NEXT_FOUND;
33 DBUG_ENTER(
"mi_rnext");
35 if ((inx = _mi_check_index(info,inx)) < 0)
36 DBUG_RETURN(my_errno);
38 if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_PREV_FOUND)
41 if (fast_mi_readinfo(info))
42 DBUG_RETURN(my_errno);
43 if (info->s->concurrent_insert)
45 changed=_mi_test_if_changed(info);
48 switch(info->s->keyinfo[inx].key_alg){
49 #ifdef HAVE_RTREE_KEYS
50 case HA_KEY_ALG_RTREE:
51 error=rtree_get_first(info,inx,info->lastkey_length);
54 case HA_KEY_ALG_BTREE:
56 error=_mi_search_first(info,info->s->keyinfo+inx,
57 info->s->state.key_root[inx]);
73 update_mask|= HA_STATE_PREV_FOUND;
77 switch (info->s->keyinfo[inx].key_alg) {
78 #ifdef HAVE_RTREE_KEYS
79 case HA_KEY_ALG_RTREE:
85 error= rtree_get_next(info,inx,info->lastkey_length);
88 case HA_KEY_ALG_BTREE:
91 error= _mi_search_next(info,info->s->keyinfo+inx,info->lastkey,
92 info->lastkey_length,flag,
93 info->s->state.key_root[inx]);
95 error= _mi_search(info,info->s->keyinfo+inx,info->lastkey,
96 USE_WHOLE_KEY,flag, info->s->state.key_root[inx]);
102 while ((info->s->concurrent_insert &&
103 info->lastpos >= info->state->data_file_length) ||
104 (info->index_cond_func &&
105 !(res= mi_check_index_cond(info, inx, buf))))
111 if ((error=_mi_search_next(info,info->s->keyinfo+inx,
113 info->lastkey_length,
115 info->s->state.key_root[inx])))
118 if (!error && res == 2)
120 if (info->s->concurrent_insert)
122 info->lastpos= HA_OFFSET_ERROR;
123 DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
127 if (info->s->concurrent_insert)
131 while (info->lastpos >= info->state->data_file_length)
134 if ((error=_mi_search_next(info,info->s->keyinfo+inx,
136 info->lastkey_length,
138 info->s->state.key_root[inx])))
145 info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
146 info->update|= update_mask;
150 if (my_errno == HA_ERR_KEY_NOT_FOUND)
151 my_errno=HA_ERR_END_OF_FILE;
155 DBUG_RETURN(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
157 else if (!(*info->read_record)(info,info->lastpos,buf))
159 info->update|= HA_STATE_AKTIV;
162 DBUG_PRINT(
"error",(
"Got error: %d, errno: %d",error, my_errno));
163 DBUG_RETURN(my_errno);