~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_check.cc

  • Committer: Mark Atwood
  • Date: 2011-09-14 03:30:42 UTC
  • mfrom: (2409.2.6 refactor7)
  • Revision ID: me@mark.atwood.name-20110914033042-2u0s8foaigvf62g2
mergeĀ lp:~olafvdspek/drizzle/refactor7

Show diffs side-by-side

added added

removed removed

Lines of Context:
288
288
      If the key cache block size is smaller than block_size, we can so
289
289
      avoid unecessary eviction of cache block.
290
290
    */
291
 
    if (!(buff=key_cache_read(info->s->getKeyCache(),
292
 
                              info->s->kfile, next_link, DFLT_INIT_HITS,
293
 
                              (unsigned char*) info->buff, MI_MIN_KEY_BLOCK_LENGTH,
294
 
                              MI_MIN_KEY_BLOCK_LENGTH, 1)))
 
291
 
 
292
    if (not pread(info->s->kfile, info->buff, MI_MIN_KEY_BLOCK_LENGTH, next_link))
295
293
    {
296
 
      mi_check_print_error(param, "key cache read error for block: %s",
297
 
                           llstr(next_link,llbuff));
 
294
      mi_check_print_error(param, "key cache read error for block: %s", llstr(next_link,llbuff));
298
295
      return(1);
299
296
    }
 
297
    buff= info->buff;
300
298
    next_link=mi_sizekorr(buff);
301
299
    records--;
302
300
    param->key_file_blocks+=block_size;
322
320
 
323
321
  if (!(param->testflag & T_SILENT)) puts("- check file-size");
324
322
 
325
 
  /* The following is needed if called externally (not from myisamchk) */
326
 
  flush_key_blocks(info->s->getKeyCache(),
327
 
                   info->s->kfile, FLUSH_FORCE_WRITE);
328
 
 
329
323
  size= lseek(info->s->kfile, 0, SEEK_END);
330
324
  if ((skr=(my_off_t) info->state->key_file_length) != size)
331
325
  {
1303
1297
    then recrate all indexes.
1304
1298
*/
1305
1299
 
1306
 
static int mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, bool force)
 
1300
static void mi_drop_all_indexes(MI_CHECK *param, MI_INFO *info, bool force)
1307
1301
{
1308
1302
  MYISAM_SHARE *share= info->s;
1309
1303
  MI_STATE_INFO *state= &share->state;
1310
1304
  uint32_t i;
1311
 
  int error;
1312
1305
 
1313
1306
  /*
1314
1307
    If any of the disabled indexes has a key block assigned, we must
1339
1332
        Flush dirty blocks of this index file from key cache and remove
1340
1333
        all blocks of this index file from key cache.
1341
1334
      */
1342
 
      error= flush_key_blocks(share->getKeyCache(), share->kfile,
1343
 
                              FLUSH_FORCE_WRITE);
1344
 
      goto end;
 
1335
      return;
1345
1336
    }
1346
1337
    /*
1347
1338
      We do now drop all indexes and declare them disabled. With the
1351
1342
    mi_clear_all_keys_active(state->key_map);
1352
1343
  }
1353
1344
 
1354
 
  /* Remove all key blocks of this index file from key cache. */
1355
 
  if ((error= flush_key_blocks(share->getKeyCache(), share->kfile,
1356
 
                               FLUSH_IGNORE_CHANGED)))
1357
 
    goto end;
1358
 
 
1359
1345
  /* Clear index root block pointers. */
1360
1346
  for (i= 0; i < share->base.keys; i++)
1361
1347
    state->key_root[i]= HA_OFFSET_ERROR;
1366
1352
 
1367
1353
  /* Reset index file length to end of index file header. */
1368
1354
  info->state->key_file_length= share->base.keystart;
1369
 
 
1370
 
  /* error= 0; set by last (error= flush_key_bocks()). */
1371
 
 
1372
 
 end:
1373
 
  return(error);
1374
1355
}
1375
1356
 
1376
1357
 
1618
1599
  param->read_cache.end_io_cache();
1619
1600
  info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
1620
1601
  info->rec_cache.end_io_cache();
1621
 
  got_error|= flush_blocks(param, share->getKeyCache(), share->kfile);
1622
1602
  if (not got_error && param->testflag & T_UNPACK)
1623
1603
  {
1624
1604
    share->state.header.options[0]&= (unsigned char) ~HA_OPTION_COMPRESS_RECORD;
1730
1710
} /* lock_memory */
1731
1711
 
1732
1712
 
1733
 
        /* Flush all changed blocks to disk */
1734
 
 
1735
 
int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, int file)
1736
 
{
1737
 
  if (flush_key_blocks(key_cache, file, FLUSH_RELEASE))
1738
 
  {
1739
 
    mi_check_print_error(param,"%d when trying to write bufferts",errno);
1740
 
    return(1);
1741
 
  }
1742
 
  if (!param->using_global_keycache)
1743
 
    end_key_cache(key_cache,1);
1744
 
  return 0;
1745
 
} /* flush_blocks */
1746
 
 
1747
 
 
1748
 
        /* Sort index for more efficent reads */
 
1713
/* Sort index for more efficent reads */
1749
1714
 
1750
1715
int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name)
1751
1716
{
1797
1762
      index_pos[key]= HA_OFFSET_ERROR;          /* No blocks */
1798
1763
  }
1799
1764
 
1800
 
  /* Flush key cache for this file if we are calling this outside myisamchk */
1801
 
  flush_key_blocks(share->getKeyCache(), share->kfile, FLUSH_IGNORE_CHANGED);
1802
 
 
1803
 
  share->state.version=(ulong) time((time_t*) 0);
 
1765
  share->state.version=(ulong) time(NULL);
1804
1766
  old_state= share->state;                      /* save state if not stored */
1805
1767
  r_locks=   share->r_locks;
1806
1768
  w_locks=   share->w_locks;
2259
2221
    memcpy( &share->state.state, info->state, sizeof(*info->state));
2260
2222
 
2261
2223
err:
2262
 
  got_error|= flush_blocks(param, share->getKeyCache(), share->kfile);
2263
2224
  info->rec_cache.end_io_cache();
2264
2225
  if (!got_error)
2265
2226
  {