~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_rkey.c

  • Committer: Monty Taylor
  • Date: 2009-03-02 23:14:32 UTC
  • mto: This revision was merged to the branch mainline in revision 910.
  • Revision ID: mordred@inaugust.com-20090302231432-i35xehp7uzo6hjjw
Updated build system to use new version numbering. Just remember to run ./config/autorun.sh before running make distcheck for release and all should be peachy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* Read record based on a key */
17
17
 
18
 
#include "myisam_priv.h"
19
 
 
20
 
using namespace drizzled;
 
18
#include "myisamdef.h"
21
19
 
22
20
        /* Read a record using key */
23
21
        /* Ordinary search_flag is 0 ; Give error if no record with key */
34
32
  int res= 0;
35
33
 
36
34
  if ((inx = _mi_check_index(info,inx)) < 0)
37
 
    return(errno);
 
35
    return(my_errno);
38
36
 
39
37
  info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
40
38
  info->last_key_func= search_flag;
68
66
  if (fast_mi_readinfo(info))
69
67
    goto err;
70
68
 
 
69
  if (share->concurrent_insert)
 
70
    pthread_rwlock_rdlock(&share->key_root_lock[inx]);
 
71
 
71
72
  nextflag=myisam_read_vec[search_flag];
72
73
  use_key_length=pack_key_length;
73
74
  if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
124
125
            ha_key_cmp(keyinfo->seg, key_buff, info->lastkey, use_key_length,
125
126
                       SEARCH_FIND, not_used))
126
127
        {
127
 
          errno= HA_ERR_KEY_NOT_FOUND;
 
128
          my_errno= HA_ERR_KEY_NOT_FOUND;
128
129
          info->lastpos= HA_OFFSET_ERROR;
129
130
          break;
130
131
        }
132
133
      if (res == 2)
133
134
      {
134
135
        info->lastpos= HA_OFFSET_ERROR;
135
 
        return((errno= HA_ERR_KEY_NOT_FOUND));
 
136
        if (share->concurrent_insert)
 
137
          pthread_rwlock_unlock(&share->key_root_lock[inx]);
 
138
        return((my_errno= HA_ERR_KEY_NOT_FOUND));
136
139
      }
137
140
      /*
138
141
        Error if no row found within the data file. (Bug #29838)
139
 
        Do not overwrite errno if already at HA_OFFSET_ERROR.
 
142
        Do not overwrite my_errno if already at HA_OFFSET_ERROR.
140
143
      */
141
144
      if (info->lastpos != HA_OFFSET_ERROR &&
142
145
          info->lastpos >= info->state->data_file_length)
143
146
      {
144
147
        info->lastpos= HA_OFFSET_ERROR;
145
 
        errno= HA_ERR_KEY_NOT_FOUND;
 
148
        my_errno= HA_ERR_KEY_NOT_FOUND;
146
149
      }
147
150
    }
148
151
  }
 
152
  if (share->concurrent_insert)
 
153
    pthread_rwlock_unlock(&share->key_root_lock[inx]);
149
154
 
150
155
  /* Calculate length of the found key;  Used by mi_rnext_same */
151
156
  if ((keyinfo->flag & HA_VAR_LENGTH_KEY) && last_used_keyseg &&
157
162
 
158
163
  /* Check if we don't want to have record back, only error message */
159
164
  if (!buf)
160
 
    return(info->lastpos == HA_OFFSET_ERROR ? errno : 0);
 
165
    return(info->lastpos == HA_OFFSET_ERROR ? my_errno : 0);
161
166
 
162
167
  if (!(*info->read_record)(info,info->lastpos,buf))
163
168
  {
176
181
  if (search_flag == HA_READ_AFTER_KEY)
177
182
    info->update|=HA_STATE_NEXT_FOUND;          /* Previous gives last row */
178
183
err:
179
 
  return(errno);
 
184
  return(my_errno);
180
185
} /* _mi_rkey */