~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_check.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-19 09:09:12 UTC
  • mto: This revision was merged to the branch mainline in revision 2408.
  • Revision ID: olafvdspek@gmail.com-20110819090912-99xtr8q1zpo6p3gi
cppcheck

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
 
145
145
int chk_del(MI_CHECK *param, register MI_INFO *info, uint32_t test_flag)
146
146
{
147
 
  register ha_rows i;
148
147
  uint32_t delete_link_length;
149
148
  my_off_t empty, next_link, old_link= 0;
150
149
  char buff[22],buff2[22];
151
150
 
152
151
  param->record_checksum=0;
153
 
  delete_link_length=((info->s->options & HA_OPTION_PACK_RECORD) ? 20 :
154
 
                      info->s->rec_reflength+1);
 
152
  delete_link_length=((info->s->options & HA_OPTION_PACK_RECORD) ? 20 : info->s->rec_reflength+1);
155
153
 
156
154
  if (!(test_flag & T_SILENT))
157
155
    puts("- check record delete-chain");
169
167
    if (test_flag & T_VERBOSE)
170
168
      printf("Recordlinks:    ");
171
169
    empty=0;
172
 
    for (i= info->state->del ; i > 0L && next_link != HA_OFFSET_ERROR ; i--)
 
170
    ha_rows i= info->state->del;
 
171
    for (; i > 0 && next_link != HA_OFFSET_ERROR; i--)
173
172
    {
174
173
      if (*killed_ptr(param))
175
174
        return(1);
176
175
      if (test_flag & T_VERBOSE)
177
 
        printf(" %9s",llstr(next_link,buff));
 
176
        printf(" %9s",llstr(next_link,buff));
178
177
      if (next_link >= info->state->data_file_length)
179
 
        goto wrong;
180
 
      if (my_pread(info->dfile, (unsigned char*) buff,delete_link_length,
181
 
                   next_link,MYF(MY_NABP)))
 
178
        goto wrong;
 
179
      if (my_pread(info->dfile, (unsigned char*) buff,delete_link_length, next_link,MYF(MY_NABP)))
182
180
      {
183
 
        if (test_flag & T_VERBOSE) puts("");
184
 
        mi_check_print_error(param,"Can't read delete-link at filepos: %s",
185
 
                    llstr(next_link,buff));
186
 
        return(1);
 
181
        if (test_flag & T_VERBOSE) puts("");
 
182
        mi_check_print_error(param,"Can't read delete-link at filepos: %s",
 
183
          llstr(next_link,buff));
 
184
        return(1);
187
185
      }
188
186
      if (*buff != '\0')
189
187
      {
190
 
        if (test_flag & T_VERBOSE) puts("");
191
 
        mi_check_print_error(param,"Record at pos: %s is not remove-marked",
192
 
                    llstr(next_link,buff));
193
 
        goto wrong;
 
188
        if (test_flag & T_VERBOSE) puts("");
 
189
        mi_check_print_error(param,"Record at pos: %s is not remove-marked",
 
190
          llstr(next_link,buff));
 
191
        goto wrong;
194
192
      }
195
193
      if (info->s->options & HA_OPTION_PACK_RECORD)
196
194
      {
197
 
        my_off_t prev_link=mi_sizekorr(buff+12);
198
 
        if (empty && prev_link != old_link)
199
 
        {
200
 
          if (test_flag & T_VERBOSE) puts("");
201
 
          mi_check_print_error(param,"Deleted block at %s doesn't point back at previous delete link",llstr(next_link,buff2));
202
 
          goto wrong;
203
 
        }
204
 
        old_link=next_link;
205
 
        next_link=mi_sizekorr(buff+4);
206
 
        empty+=mi_uint3korr(buff+1);
 
195
        my_off_t prev_link=mi_sizekorr(buff+12);
 
196
        if (empty && prev_link != old_link)
 
197
        {
 
198
          if (test_flag & T_VERBOSE) puts("");
 
199
          mi_check_print_error(param,"Deleted block at %s doesn't point back at previous delete link",llstr(next_link,buff2));
 
200
          goto wrong;
 
201
        }
 
202
        old_link=next_link;
 
203
        next_link=mi_sizekorr(buff+4);
 
204
        empty+=mi_uint3korr(buff+1);
207
205
      }
208
206
      else
209
207
      {
210
 
        param->record_checksum+=(ha_checksum) next_link;
211
 
        next_link=_mi_rec_pos(info->s,(unsigned char*) buff+1);
212
 
        empty+=info->s->base.pack_reclength;
 
208
        param->record_checksum+=(ha_checksum) next_link;
 
209
        next_link=_mi_rec_pos(info->s,(unsigned char*) buff+1);
 
210
        empty+=info->s->base.pack_reclength;
213
211
      }
214
212
    }
215
213
    if (test_flag & T_VERBOSE)
217
215
    if (empty != info->state->empty)
218
216
    {
219
217
      mi_check_print_warning(param,
220
 
                             "Found %s deleted space in delete link chain. Should be %s",
221
 
                             llstr(empty,buff2),
222
 
                             llstr(info->state->empty,buff));
 
218
        "Found %s deleted space in delete link chain. Should be %s",
 
219
        llstr(empty,buff2),
 
220
        llstr(info->state->empty,buff));
223
221
    }
224
222
    if (next_link != HA_OFFSET_ERROR)
225
223
    {
226
224
      mi_check_print_error(param,
227
 
                           "Found more than the expected %s deleted rows in delete link chain",
228
 
                           llstr(info->state->del, buff));
 
225
        "Found more than the expected %s deleted rows in delete link chain",
 
226
        llstr(info->state->del, buff));
229
227
      goto wrong;
230
228
    }
231
229
    if (i != 0)
232
230
    {
233
 
      mi_check_print_error(param,
234
 
                           "Found %s deleted rows in delete link chain. Should be %s",
235
 
                           llstr(info->state->del - i, buff2),
236
 
                           llstr(info->state->del, buff));
 
231
      mi_check_print_error(param, "Found %s deleted rows in delete link chain. Should be %s", llstr(info->state->del - i, buff2), llstr(info->state->del, buff));
237
232
      goto wrong;
238
233
    }
239
234
  }
240
 
  return(0);
 
235
  return 0;
241
236
 
242
237
wrong:
243
238
  param->testflag|=T_RETRY_WITHOUT_QUICK;
244
239
  if (test_flag & T_VERBOSE) puts("");
245
240
  mi_check_print_error(param,"record delete-link-chain corrupted");
246
 
  return(1);
 
241
  return 1;
247
242
} /* chk_del */
248
243
 
249
244