~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_check.c

MergedĀ fromĀ Mats.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
 
85
85
void myisamchk_init(MI_CHECK *param)
86
86
{
87
 
  memset((uchar*) param, 0, sizeof(*param));
 
87
  memset(param, 0, sizeof(*param));
88
88
  param->opt_follow_links=1;
89
89
  param->keys_in_use= ~(uint64_t) 0;
90
90
  param->search_after_block=HA_OFFSET_ERROR;
430
430
    if (! mi_is_key_active(share->state.key_map, key))
431
431
    {
432
432
      /* Remember old statistics for key */
433
 
      memcpy((char*) rec_per_key_part,
434
 
             (char*) (share->state.rec_per_key_part +
435
 
                      (uint) (rec_per_key_part - param->rec_per_key_part)),
 
433
      assert(rec_per_key_part >= param->rec_per_key_part);
 
434
      memcpy(rec_per_key_part,
 
435
             (share->state.rec_per_key_part +
 
436
              (rec_per_key_part - param->rec_per_key_part)),
436
437
             keyinfo->keysegs*sizeof(*rec_per_key_part));
437
438
      continue;
438
439
    }
440
441
 
441
442
    param->record_checksum=init_checksum;
442
443
    
443
 
    memset((char*) &param->unique_count, 0, sizeof(param->unique_count));
444
 
    memset((char*) &param->notnull_count, 0, sizeof(param->notnull_count));
 
444
    memset(&param->unique_count, 0, sizeof(param->unique_count));
 
445
    memset(&param->notnull_count, 0, sizeof(param->notnull_count));
445
446
 
446
447
    if ((!(param->testflag & T_SILENT)))
447
448
      printf ("- check data record references index: %d\n",key+1);
758
759
  {
759
760
    if (*killed_ptr(param))
760
761
      goto err;
761
 
    memcpy((char*) info->lastkey,(char*) key,key_length);
 
762
    memcpy(info->lastkey,key,key_length);
762
763
    info->lastkey_length=key_length;
763
764
    if (nod_flag)
764
765
    {
923
924
  }
924
925
 
925
926
  pos=my_b_tell(&param->read_cache);
926
 
  memset((char*) key_checksum, 0, info->s->base.keys * sizeof(key_checksum[0]));
 
927
  memset(key_checksum, 0, info->s->base.keys * sizeof(key_checksum[0]));
927
928
  while (pos < info->state->data_file_length)
928
929
  {
929
930
    if (*killed_ptr(param))
1447
1448
  SORT_INFO sort_info;
1448
1449
  MI_SORT_PARAM sort_param;
1449
1450
 
1450
 
  memset((char *)&sort_info, 0, sizeof(sort_info));
1451
 
  memset((char *)&sort_param, 0, sizeof(sort_param));
 
1451
  memset(&sort_info, 0, sizeof(sort_info));
 
1452
  memset(&sort_param, 0, sizeof(sort_param));
1452
1453
  start_records=info->state->records;
1453
1454
  new_header_length=(param->testflag & T_UNPACK) ? 0L :
1454
1455
    share->pack.header_length;
1961
1962
 
1962
1963
  /* Fill block with zero and write it to the new index file */
1963
1964
  length=mi_getint(buff);
1964
 
  memset((uchar*) buff+length, 0, keyinfo->block_length-length);
 
1965
  memset(buff+length, 0, keyinfo->block_length-length);
1965
1966
  if (my_pwrite(new_file,(uchar*) buff,(uint) keyinfo->block_length,
1966
1967
                new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL)))
1967
1968
  {
2084
2085
  if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
2085
2086
    param->testflag|=T_CALC_CHECKSUM;
2086
2087
 
2087
 
  memset((char*)&sort_info, 0, sizeof(sort_info));
2088
 
  memset((char *)&sort_param, 0, sizeof(sort_param));
 
2088
  memset(&sort_info, 0, sizeof(sort_info));
 
2089
  memset(&sort_param, 0, sizeof(sort_param));
2089
2090
  if (!(sort_info.key_block=
2090
2091
        alloc_key_blocks(param,
2091
2092
                         (uint) param->sort_key_blocks,
2196
2197
    if (! mi_is_key_active(key_map, sort_param.key))
2197
2198
    {
2198
2199
      /* Remember old statistics for key */
2199
 
      memcpy((char*) rec_per_key_part,
2200
 
             (char*) (share->state.rec_per_key_part +
2201
 
                      (uint) (rec_per_key_part - param->rec_per_key_part)),
 
2200
      assert(rec_per_key_part >= param->rec_per_key_part);
 
2201
      memcpy(rec_per_key_part,
 
2202
             (share->state.rec_per_key_part +
 
2203
              (rec_per_key_part - param->rec_per_key_part)),
2202
2204
             sort_param.keyinfo->keysegs*sizeof(*rec_per_key_part));
2203
2205
      continue;
2204
2206
    }
2207
2209
      printf ("- Fixing index %d\n",sort_param.key+1);
2208
2210
    sort_param.max_pos=sort_param.pos=share->pack.header_length;
2209
2211
    keyseg=sort_param.seg;
2210
 
    memset((char*) sort_param.unique, 0, sizeof(sort_param.unique));
 
2212
    memset(sort_param.unique, 0, sizeof(sort_param.unique));
2211
2213
    sort_param.key_length=share->rec_reflength;
2212
2214
    for (i=0 ; keyseg[i].type != HA_KEYTYPE_END; i++)
2213
2215
    {
2492
2494
      position 'new_header_length'.
2493
2495
    }
2494
2496
  */
2495
 
  memset((char*)&sort_info, 0, sizeof(sort_info));
 
2497
  memset(&sort_info, 0, sizeof(sort_info));
2496
2498
  /* Initialize pthread structures before goto err. */
2497
2499
  pthread_mutex_init(&sort_info.mutex, MY_MUTEX_INIT_FAST);
2498
2500
  pthread_cond_init(&sort_info.cond, 0);
2621
2623
    if (! mi_is_key_active(key_map, key))
2622
2624
    {
2623
2625
      /* Remember old statistics for key */
2624
 
      memcpy((char*) rec_per_key_part,
2625
 
             (char*) (share->state.rec_per_key_part+
2626
 
                      (uint) (rec_per_key_part - param->rec_per_key_part)),
 
2626
      assert(rec_per_key_part >= param->rec_per_key_part);
 
2627
      memcpy(rec_per_key_part,
 
2628
             (share->state.rec_per_key_part +
 
2629
              (rec_per_key_part - param->rec_per_key_part)),
2627
2630
             sort_param[i].keyinfo->keysegs*sizeof(*rec_per_key_part));
2628
2631
      istep=0;
2629
2632
      continue;
3621
3624
 
3622
3625
        /* Fill block with end-zero and write filled block */
3623
3626
  mi_putint(anc_buff,key_block->last_length,nod_flag);
3624
 
  memset((uchar*) anc_buff+key_block->last_length, 0,
3625
 
         keyinfo->block_length- key_block->last_length);
 
3627
  memset(anc_buff+key_block->last_length, 0,
 
3628
         keyinfo->block_length - key_block->last_length);
3626
3629
  key_file_length=info->state->key_file_length;
3627
3630
  if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR)
3628
3631
    return(1);
3724
3727
    if (nod_flag)
3725
3728
      _mi_kpointer(info,key_block->end_pos,filepos);
3726
3729
    key_file_length=info->state->key_file_length;
3727
 
    memset((uchar*) key_block->buff+length, 0, keyinfo->block_length-length);
 
3730
    memset(key_block->buff+length, 0, keyinfo->block_length-length);
3728
3731
    if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR)
3729
3732
      return(1);
3730
3733
 
3806
3809
    (param->testflag & T_UNPACK);
3807
3810
  if (!(keyinfo=(MI_KEYDEF*) my_alloca(sizeof(MI_KEYDEF)*share.base.keys)))
3808
3811
    return(0);
3809
 
  memcpy((uchar*) keyinfo,(uchar*) share.keyinfo,
3810
 
         (size_t) (sizeof(MI_KEYDEF)*share.base.keys));
 
3812
  memcpy(keyinfo,share.keyinfo,sizeof(MI_KEYDEF)*share.base.keys);
3811
3813
 
3812
3814
  key_parts= share.base.all_key_parts;
3813
3815
  if (!(keysegs=(HA_KEYSEG*) my_alloca(sizeof(HA_KEYSEG)*
3833
3835
  }
3834
3836
 
3835
3837
  /* Copy the column definitions */
3836
 
  memcpy((uchar*) recdef,(uchar*) share.rec,
3837
 
         (size_t) (sizeof(MI_COLUMNDEF)*(share.base.fields+1)));
 
3838
  memcpy(recdef, share.rec, sizeof(MI_COLUMNDEF)*(share.base.fields+1));
3838
3839
  for (rec=recdef,end=recdef+share.base.fields; rec != end ; rec++)
3839
3840
  {
3840
3841
    if (unpack && !(share.options & HA_OPTION_PACK_RECORD) &&
3845
3846
  }
3846
3847
 
3847
3848
  /* Change the new key to point at the saved key segments */
3848
 
  memcpy((uchar*) keysegs,(uchar*) share.keyparts,
3849
 
         (size_t) (sizeof(HA_KEYSEG)*(key_parts+share.base.keys+
3850
 
                                      share.state.header.uniques)));
 
3849
  memcpy(keysegs,share.keyparts,
 
3850
         sizeof(HA_KEYSEG)*(key_parts+share.base.keys+
 
3851
                            share.state.header.uniques));
3851
3852
  keyseg=keysegs;
3852
3853
  for (key=keyinfo,key_end=keyinfo+share.base.keys; key != key_end ; key++)
3853
3854
  {
3862
3863
 
3863
3864
  /* Copy the unique definitions and change them to point at the new key
3864
3865
     segments*/
3865
 
  memcpy((uchar*) uniquedef,(uchar*) share.uniqueinfo,
3866
 
         (size_t) (sizeof(MI_UNIQUEDEF)*(share.state.header.uniques)));
 
3866
  memcpy(uniquedef,share.uniqueinfo,
 
3867
         sizeof(MI_UNIQUEDEF)*(share.state.header.uniques));
3867
3868
  for (u_ptr=uniquedef,u_end=uniquedef+share.state.header.uniques;
3868
3869
       u_ptr != u_end ; u_ptr++)
3869
3870
  {
3888
3889
  set_if_bigger(file_length,(uint64_t) share.base.max_data_file_length);
3889
3890
 
3890
3891
  VOID(mi_close(*org_info));
3891
 
  memset((char*) &create_info, 0, sizeof(create_info));
 
3892
  memset(&create_info, 0, sizeof(create_info));
3892
3893
  create_info.max_rows=max(max_records,share.base.records);
3893
3894
  create_info.reloc_rows=share.base.reloc;
3894
3895
  create_info.old_options=(share.options |
4284
4285
      sort_info->new_data_file_type = STATIC_RECORD;
4285
4286
 
4286
4287
    /* Set delete_function for sort_delete_record() */
4287
 
    memcpy((char*) &tmp, share, sizeof(*share));
 
4288
    memcpy(&tmp, share, sizeof(*share));
4288
4289
    tmp.options= ~HA_OPTION_COMPRESS_RECORD;
4289
4290
    mi_setup_functions(&tmp);
4290
4291
    share->delete_record=tmp.delete_record;