~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_statrec.c

  • Committer: Monty Taylor
  • Date: 2008-07-16 19:10:24 UTC
  • mfrom: (51.1.127 remove-dbug)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: monty@inaugust.com-20080716191024-prjgoh7fbri7rx26
MergedĀ fromĀ remove-dbug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "myisamdef.h"
19
19
 
20
 
 
21
20
int _mi_write_static_record(MI_INFO *info, const uchar *record)
22
21
{
23
22
  uchar temp[8];                                /* max pointer length */
112
111
 
113
112
int _mi_cmp_static_record(register MI_INFO *info, register const uchar *old)
114
113
{
115
 
  DBUG_ENTER("_mi_cmp_static_record");
116
 
 
117
114
  if (info->opt_flag & WRITE_CACHE_USED)
118
115
  {
119
116
    if (flush_io_cache(&info->rec_cache))
120
117
    {
121
 
      DBUG_RETURN(-1);
 
118
      return(-1);
122
119
    }
123
120
    info->rec_cache.seek_not_done=1;            /* We have done a seek */
124
121
  }
129
126
    if (info->s->file_read(info, info->rec_buff, info->s->base.reclength,
130
127
                 info->lastpos,
131
128
                 MYF(MY_NABP)))
132
 
      DBUG_RETURN(-1);
 
129
      return(-1);
133
130
    if (memcmp(info->rec_buff, old,
134
131
               (uint) info->s->base.reclength))
135
132
    {
136
 
      DBUG_DUMP("read",old,info->s->base.reclength);
137
 
      DBUG_DUMP("disk",info->rec_buff,info->s->base.reclength);
138
133
      my_errno=HA_ERR_RECORD_CHANGED;           /* Record have changed */
139
 
      DBUG_RETURN(1);
 
134
      return(1);
140
135
    }
141
136
  }
142
 
  DBUG_RETURN(0);
 
137
  return(0);
143
138
}
144
139
 
145
140
 
146
141
int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def,
147
142
                          const uchar *record, my_off_t pos)
148
143
{
149
 
  DBUG_ENTER("_mi_cmp_static_unique");
150
 
 
151
144
  info->rec_cache.seek_not_done=1;              /* We have done a seek */
152
145
  if (info->s->file_read(info, info->rec_buff, info->s->base.reclength,
153
146
               pos, MYF(MY_NABP)))
154
 
    DBUG_RETURN(-1);
155
 
  DBUG_RETURN(mi_unique_comp(def, record, info->rec_buff,
 
147
    return(-1);
 
148
  return(mi_unique_comp(def, record, info->rec_buff,
156
149
                             def->null_are_equal));
157
150
}
158
151
 
203
196
  int locked,error,cache_read;
204
197
  uint cache_length;
205
198
  MYISAM_SHARE *share=info->s;
206
 
  DBUG_ENTER("_mi_read_rnd_static_record");
207
199
 
208
200
  cache_read=0;
209
201
  cache_length=0;
210
202
  if (info->opt_flag & WRITE_CACHE_USED &&
211
203
      (info->rec_cache.pos_in_file <= filepos || skip_deleted_blocks) &&
212
204
      flush_io_cache(&info->rec_cache))
213
 
    DBUG_RETURN(my_errno);
 
205
    return(my_errno);
214
206
  if (info->opt_flag & READ_CACHE_USED)
215
207
  {                                             /* Cache in use */
216
208
    if (filepos == my_b_tell(&info->rec_cache) &&
228
220
    if (filepos >= info->state->data_file_length)
229
221
    {                                           /* Test if new records */
230
222
      if (_mi_readinfo(info,F_RDLCK,0))
231
 
        DBUG_RETURN(my_errno);
 
223
        return(my_errno);
232
224
      locked=1;
233
225
    }
234
226
    else
242
234
  }
243
235
  if (filepos >= info->state->data_file_length)
244
236
  {
245
 
    DBUG_PRINT("test",("filepos: %ld (%ld)  records: %ld  del: %ld",
246
 
                       (long) filepos/share->base.reclength, (long) filepos,
247
 
                       (long) info->state->records, (long) info->state->del));
248
237
    fast_mi_writeinfo(info);
249
 
    DBUG_RETURN(my_errno=HA_ERR_END_OF_FILE);
 
238
    return(my_errno=HA_ERR_END_OF_FILE);
250
239
  }
251
240
  info->lastpos= filepos;
252
241
  info->nextpos= filepos+share->base.pack_reclength;
260
249
      else
261
250
        error=my_errno;
262
251
    }
263
 
    DBUG_RETURN(error);
 
252
    return(error);
264
253
  }
265
254
 
266
255
        /* Read record with cacheing */
277
266
  {
278
267
    if (!buf[0])
279
268
    {                                           /* Record is removed */
280
 
      DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED);
 
269
      return(my_errno=HA_ERR_RECORD_DELETED);
281
270
    }
282
271
                                                /* Found and may be updated */
283
272
    info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
284
 
    DBUG_RETURN(0);
 
273
    return(0);
285
274
  }
286
275
  /* my_errno should be set if rec_cache.error == -1 */
287
276
  if (info->rec_cache.error != -1 || my_errno == 0)
288
277
    my_errno=HA_ERR_WRONG_IN_RECORD;
289
 
  DBUG_RETURN(my_errno);                        /* Something wrong (EOF?) */
 
278
  return(my_errno);                     /* Something wrong (EOF?) */
290
279
}