16 #include "myisam_priv.h"
18 using namespace drizzled;
28 int mi_rnext_same(
MI_INFO *info,
unsigned char *buf)
31 uint32_t inx,not_used[2];
34 if ((
int) (inx=info->lastinx) < 0 || info->lastpos == HA_OFFSET_ERROR)
35 return(errno=HA_ERR_WRONG_INDEX);
36 keyinfo=info->s->keyinfo+inx;
37 if (fast_mi_readinfo(info))
40 switch (keyinfo->key_alg)
42 case HA_KEY_ALG_BTREE:
44 if (!(info->update & HA_STATE_RNEXT_SAME))
47 memcpy(info->lastkey2,info->lastkey,info->last_rkey_length);
51 if ((error=_mi_search_next(info,keyinfo,info->lastkey,
52 info->lastkey_length,SEARCH_BIGGER,
53 info->s->state.key_root[inx])))
55 if (ha_key_cmp(keyinfo->seg, info->lastkey, info->lastkey2,
56 info->last_rkey_length, SEARCH_FIND, not_used))
59 errno=HA_ERR_END_OF_FILE;
60 info->lastpos= HA_OFFSET_ERROR;
64 if (info->lastpos < info->state->data_file_length &&
65 (!info->index_cond_func || mi_check_index_cond(info, inx, buf)))
70 info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
71 info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME;
75 if (errno == HA_ERR_KEY_NOT_FOUND)
76 errno=HA_ERR_END_OF_FILE;
80 return(info->lastpos==HA_OFFSET_ERROR ? errno : 0);
82 else if (!(*info->read_record)(info,info->lastpos,buf))
84 info->update|= HA_STATE_AKTIV;