~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_rnext.c

  • Committer: Monty Taylor
  • Date: 2008-07-05 22:08:52 UTC
  • mto: This revision was merged to the branch mainline in revision 77.
  • Revision ID: monty@inaugust.com-20080705220852-cqd9t6tfkhvlcf73
Removed HAVE_LONG_LONG, as this is now assumed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "myisamdef.h"
17
17
 
 
18
#include "rt_index.h"
 
19
 
18
20
        /*
19
21
           Read next row with the same key as previous read
20
22
           One may have done a write, update or delete of the previous row.
22
24
           based on the position of the last used key!
23
25
        */
24
26
 
25
 
int mi_rnext(MI_INFO *info, unsigned char *buf, int inx)
 
27
int mi_rnext(MI_INFO *info, uchar *buf, int inx)
26
28
{
27
29
  int error,changed;
28
 
  uint32_t flag;
 
30
  uint flag;
29
31
  int res= 0;
 
32
  DBUG_ENTER("mi_rnext");
30
33
 
31
34
  if ((inx = _mi_check_index(info,inx)) < 0)
32
 
    return(my_errno);
 
35
    DBUG_RETURN(my_errno);
33
36
  flag=SEARCH_BIGGER;                           /* Read next */
34
37
  if (info->lastpos == HA_OFFSET_ERROR && info->update & HA_STATE_PREV_FOUND)
35
38
    flag=0;                                     /* Read first */
36
39
 
37
40
  if (fast_mi_readinfo(info))
38
 
    return(my_errno);
 
41
    DBUG_RETURN(my_errno);
39
42
  if (info->s->concurrent_insert)
40
43
    rw_rdlock(&info->s->key_root_lock[inx]);
41
44
  changed=_mi_test_if_changed(info);
42
45
  if (!flag)
43
46
  {
44
47
    switch(info->s->keyinfo[inx].key_alg){
 
48
#ifdef HAVE_RTREE_KEYS
 
49
    case HA_KEY_ALG_RTREE:
 
50
      error=rtree_get_first(info,inx,info->lastkey_length);
 
51
      break;
 
52
#endif
45
53
    case HA_KEY_ALG_BTREE:
46
54
    default:
47
55
      error=_mi_search_first(info,info->s->keyinfo+inx,
52
60
  else
53
61
  {
54
62
    switch (info->s->keyinfo[inx].key_alg) {
 
63
#ifdef HAVE_RTREE_KEYS
 
64
    case HA_KEY_ALG_RTREE:
 
65
      /*
 
66
        Note that rtree doesn't support that the table
 
67
        may be changed since last call, so we do need
 
68
        to skip rows inserted by other threads like in btree
 
69
      */
 
70
      error= rtree_get_next(info,inx,info->lastkey_length);
 
71
      break;
 
72
#endif
55
73
    case HA_KEY_ALG_BTREE:
56
74
    default:
57
75
      if (!changed)
84
102
      if (info->s->concurrent_insert)
85
103
        rw_unlock(&info->s->key_root_lock[inx]);
86
104
      info->lastpos= HA_OFFSET_ERROR;
87
 
      return(my_errno= HA_ERR_END_OF_FILE);
 
105
      DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
88
106
    }
89
107
  }
90
108
  
102
120
  }
103
121
  else if (!buf)
104
122
  {
105
 
    return(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
 
123
    DBUG_RETURN(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
106
124
  }
107
125
  else if (!(*info->read_record)(info,info->lastpos,buf))
108
126
  {
109
127
    info->update|= HA_STATE_AKTIV;              /* Record is read */
110
 
    return(0);
 
128
    DBUG_RETURN(0);
111
129
  }
112
 
  return(my_errno);
 
130
  DBUG_PRINT("error",("Got error: %d,  errno: %d",error, my_errno));
 
131
  DBUG_RETURN(my_errno);
113
132
} /* mi_rnext */