~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_rsame.c

Cleanup around SAFEMALLOC

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 "myisam_priv.h"
17
 
#include <drizzled/util/test.h>
18
 
 
19
 
using namespace drizzled;
 
16
#include "myisamdef.h"
20
17
 
21
18
        /*
22
19
        ** Find current row with read on position or read on key
28
25
        */
29
26
 
30
27
 
31
 
int mi_rsame(MI_INFO *info, unsigned char *record, int inx)
 
28
int mi_rsame(MI_INFO *info, uchar *record, int inx)
32
29
{
33
30
  if (inx != -1 && ! mi_is_key_active(info->s->state.key_map, inx))
34
31
  {
35
 
    return(errno=HA_ERR_WRONG_INDEX);
 
32
    return(my_errno=HA_ERR_WRONG_INDEX);
36
33
  }
37
34
  if (info->lastpos == HA_OFFSET_ERROR || info->update & HA_STATE_DELETED)
38
35
  {
39
 
    return(errno=HA_ERR_KEY_NOT_FOUND); /* No current record */
 
36
    return(my_errno=HA_ERR_KEY_NOT_FOUND);      /* No current record */
40
37
  }
41
38
  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
42
39
 
43
40
  /* Read row from data file */
44
41
  if (fast_mi_readinfo(info))
45
 
    return(errno);
 
42
    return(my_errno);
46
43
 
47
44
  if (inx >= 0)
48
45
  {
50
47
    info->lastkey_length=_mi_make_key(info,(uint) inx,info->lastkey,record,
51
48
                                      info->lastpos);
52
49
    if (info->s->concurrent_insert)
53
 
      pthread_rwlock_rdlock(&info->s->key_root_lock[inx]);
54
 
    _mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY,
55
 
               SEARCH_SAME,
56
 
               info->s->state.key_root[inx]);
 
50
      rw_rdlock(&info->s->key_root_lock[inx]);
 
51
    VOID(_mi_search(info,info->s->keyinfo+inx,info->lastkey, USE_WHOLE_KEY,
 
52
                    SEARCH_SAME,
 
53
                    info->s->state.key_root[inx]));
57
54
    if (info->s->concurrent_insert)
58
 
      pthread_rwlock_unlock(&info->s->key_root_lock[inx]);
 
55
      rw_unlock(&info->s->key_root_lock[inx]);
59
56
  }
60
57
 
61
58
  if (!(*info->read_record)(info,info->lastpos,record))
62
59
    return(0);
63
 
  if (errno == HA_ERR_RECORD_DELETED)
64
 
    errno=HA_ERR_KEY_NOT_FOUND;
65
 
  return(errno);
 
60
  if (my_errno == HA_ERR_RECORD_DELETED)
 
61
    my_errno=HA_ERR_KEY_NOT_FOUND;
 
62
  return(my_errno);
66
63
} /* mi_rsame */