~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_rnext_same.cc

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

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 "myisamdef.h"
 
16
#include "myisam_priv.h"
17
17
 
18
18
        /*
19
19
           Read next row with the same key as previous read, but abort if
23
23
           based on the position of the last used key!
24
24
        */
25
25
 
26
 
int mi_rnext_same(MI_INFO *info, uchar *buf)
 
26
int mi_rnext_same(MI_INFO *info, unsigned char *buf)
27
27
{
28
28
  int error;
29
 
  uint inx,not_used[2];
 
29
  uint32_t inx,not_used[2];
30
30
  MI_KEYDEF *keyinfo;
31
31
 
32
32
  if ((int) (inx=info->lastinx) < 0 || info->lastpos == HA_OFFSET_ERROR)
33
 
    return(my_errno=HA_ERR_WRONG_INDEX);
 
33
    return(errno=HA_ERR_WRONG_INDEX);
34
34
  keyinfo=info->s->keyinfo+inx;
35
35
  if (fast_mi_readinfo(info))
36
 
    return(my_errno);
 
36
    return(errno);
37
37
 
38
38
  if (info->s->concurrent_insert)
39
 
    rw_rdlock(&info->s->key_root_lock[inx]);
 
39
    pthread_rwlock_rdlock(&info->s->key_root_lock[inx]);
40
40
 
41
41
  switch (keyinfo->key_alg)
42
42
  {
57
57
                       info->last_rkey_length, SEARCH_FIND, not_used))
58
58
        {
59
59
          error=1;
60
 
          my_errno=HA_ERR_END_OF_FILE;
 
60
          errno=HA_ERR_END_OF_FILE;
61
61
          info->lastpos= HA_OFFSET_ERROR;
62
62
          break;
63
63
        }
64
64
        /* Skip rows that are inserted by other threads since we got a lock */
65
 
        if (info->lastpos < info->state->data_file_length && 
 
65
        if (info->lastpos < info->state->data_file_length &&
66
66
            (!info->index_cond_func || mi_check_index_cond(info, inx, buf)))
67
67
          break;
68
68
      }
69
69
  }
70
70
  if (info->s->concurrent_insert)
71
 
    rw_unlock(&info->s->key_root_lock[inx]);
 
71
    pthread_rwlock_unlock(&info->s->key_root_lock[inx]);
72
72
        /* Don't clear if database-changed */
73
73
  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
74
74
  info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME;
75
75
 
76
76
  if (error)
77
77
  {
78
 
    if (my_errno == HA_ERR_KEY_NOT_FOUND)
79
 
      my_errno=HA_ERR_END_OF_FILE;
 
78
    if (errno == HA_ERR_KEY_NOT_FOUND)
 
79
      errno=HA_ERR_END_OF_FILE;
80
80
  }
81
81
  else if (!buf)
82
82
  {
83
 
    return(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
 
83
    return(info->lastpos==HA_OFFSET_ERROR ? errno : 0);
84
84
  }
85
85
  else if (!(*info->read_record)(info,info->lastpos,buf))
86
86
  {
87
87
    info->update|= HA_STATE_AKTIV;              /* Record is read */
88
88
    return(0);
89
89
  }
90
 
  return(my_errno);
 
90
  return(errno);
91
91
} /* mi_rnext_same */