~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_rkey.c

  • Committer: Monty Taylor
  • Date: 2008-08-01 22:33:44 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080801223344-vzhlflfmtijp1imv
First pass at gettexizing the error messages.

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 */
24
22
 
25
 
int mi_rkey(MI_INFO *info, unsigned char *buf, int inx, const unsigned char *key,
 
23
int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key,
26
24
            key_part_map keypart_map, enum ha_rkey_function search_flag)
27
25
{
28
 
  unsigned char *key_buff;
 
26
  uchar *key_buff;
29
27
  MYISAM_SHARE *share=info->s;
30
28
  MI_KEYDEF *keyinfo;
31
29
  HA_KEYSEG *last_used_keyseg;
32
 
  uint32_t pack_key_length, use_key_length, nextflag;
33
 
  uint32_t myisam_search_flag;
 
30
  uint pack_key_length, use_key_length, nextflag;
 
31
  uint myisam_search_flag;
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;
49
47
    */
50
48
    key_buff=info->lastkey+info->s->base.max_key_length;
51
49
    pack_key_length= keypart_map;
52
 
    memmove(key_buff, key, pack_key_length);
 
50
    memcpy(key_buff, key, pack_key_length);
53
51
    last_used_keyseg= info->s->keyinfo[inx].seg + info->last_used_keyseg;
54
52
  }
55
53
  else
57
55
    assert(keypart_map);
58
56
    /* Save the packed key for later use in the second buffer of lastkey. */
59
57
    key_buff=info->lastkey+info->s->base.max_key_length;
60
 
    pack_key_length=_mi_pack_key(info,(uint) inx, key_buff, (unsigned char*) key,
 
58
    pack_key_length=_mi_pack_key(info,(uint) inx, key_buff, (uchar*) key,
61
59
                                 keypart_map, &last_used_keyseg);
62
60
    /* Save packed_key_length for use by the MERGE engine. */
63
61
    info->pack_key_length= pack_key_length;
68
66
  if (fast_mi_readinfo(info))
69
67
    goto err;
70
68
 
 
69
  if (share->concurrent_insert)
 
70
    rw_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)))
100
101
      while ((info->lastpos >= info->state->data_file_length &&
101
102
              (search_flag != HA_READ_KEY_EXACT ||
102
103
              last_used_keyseg != keyinfo->seg + keyinfo->keysegs)) ||
103
 
             (info->index_cond_func &&
 
104
             (info->index_cond_func && 
104
105
              !(res= mi_check_index_cond(info, inx, buf))))
105
106
      {
106
 
        uint32_t not_used[2];
 
107
        uint not_used[2];
107
108
        /*
108
109
          Skip rows that are inserted by other threads since we got a lock
109
110
          Note that this can only happen if we are not searching after an
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
          rw_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
    rw_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
  {
170
175
  /* Store last used key as a base for read next */
171
176
  memcpy(info->lastkey,key_buff,pack_key_length);
172
177
  info->last_rkey_length= pack_key_length;
173
 
  memset(info->lastkey+pack_key_length, 0, info->s->base.rec_reflength);
 
178
  memset((char*) info->lastkey+pack_key_length, 0, info->s->base.rec_reflength);
174
179
  info->lastkey_length=pack_key_length+info->s->base.rec_reflength;
175
180
 
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 */