~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_check.c

  • Committer: Brian Aker
  • Date: 2008-12-09 17:33:02 UTC
  • mfrom: (656.1.54 devel)
  • Revision ID: brian@tangent.org-20081209173302-aptngvc7efxnatnt
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
328
328
  flush_key_blocks(info->s->key_cache,
329
329
                   info->s->kfile, FLUSH_FORCE_WRITE);
330
330
 
331
 
  size= my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
 
331
  size= lseek(info->s->kfile, 0, SEEK_END);
332
332
  if ((skr=(my_off_t) info->state->key_file_length) != size)
333
333
  {
334
334
    /* Don't give error if file generated by myisampack */
352
352
                           llstr(info->state->key_file_length,buff),
353
353
                           llstr(info->s->base.max_key_file_length-1,buff));
354
354
 
355
 
  size=my_seek(info->dfile,0L,MY_SEEK_END,MYF(0));
 
355
  size=lseek(info->dfile,0L,SEEK_END);
356
356
  skr=(my_off_t) info->state->data_file_length;
357
357
  if (info->s->options & HA_OPTION_COMPRESS_RECORD)
358
358
    skr+= MEMMAP_EXTRA_MARGIN;
584
584
  {
585
585
    /* purecov: begin tested */
586
586
    /* Give it a chance to fit in the real file size. */
587
 
    my_off_t max_length= my_seek(info->s->kfile, 0L, MY_SEEK_END,
588
 
                                 MYF(MY_THREADSAFE));
 
587
    my_off_t max_length= lseek(info->s->kfile, 0, SEEK_END);
589
588
    mi_check_print_error(param, "Invalid key block position: %s  "
590
589
                         "key block size: %u  file_length: %s",
591
590
                         llstr(page, llbuff), keyinfo->block_length,
1490
1489
  sort_param.pos=sort_param.max_pos=share->pack.header_length;
1491
1490
  sort_param.filepos=new_header_length;
1492
1491
  param->read_cache.end_of_file=sort_info.filelength=
1493
 
    my_seek(info->dfile,0L,MY_SEEK_END,MYF(0));
 
1492
    lseek(info->dfile,0L,SEEK_END);
1494
1493
  sort_info.dupp=0;
1495
1494
  sort_param.fix_datafile= (bool) (! rep_quick);
1496
1495
  sort_param.master=1;
1980
1979
  ulong buff_length;
1981
1980
 
1982
1981
  buff_length=(ulong) cmin(param->write_buffer_length,length);
1983
 
  if (!(buff=my_malloc(buff_length,MYF(0))))
 
1982
  if (!(buff=malloc(buff_length)))
1984
1983
  {
1985
1984
    buff=tmp_buff; buff_length=IO_SIZE;
1986
1985
  }
1987
1986
 
1988
 
  my_seek(from,start,MY_SEEK_SET,MYF(0));
 
1987
  lseek(from,start,SEEK_SET);
1989
1988
  while (length > buff_length)
1990
1989
  {
1991
1990
    if (my_read(from,(unsigned char*) buff,buff_length,MYF(MY_NABP)) ||
2125
2124
  sort_info.dupp=0;
2126
2125
  sort_info.buff=0;
2127
2126
  param->read_cache.end_of_file=sort_info.filelength=
2128
 
    my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
 
2127
    lseek(param->read_cache.file,0L,SEEK_END);
2129
2128
 
2130
2129
  sort_param.wordlist=NULL;
2131
2130
 
2535
2534
  sort_info.dupp=0;
2536
2535
  sort_info.buff=0;
2537
2536
  param->read_cache.end_of_file=sort_info.filelength=
2538
 
    my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
 
2537
    lseek(param->read_cache.file,0L,SEEK_END);
2539
2538
 
2540
2539
  if (share->data_file_type == DYNAMIC_RECORD)
2541
2540
    rec_length=cmax(share->base.min_pack_length+1,share->base.min_block_length);
2566
2565
  if (share->options & HA_OPTION_COMPRESS_RECORD)
2567
2566
    set_if_bigger(max_pack_reclength, share->max_pack_length);
2568
2567
  if (!(sort_param=(MI_SORT_PARAM *)
2569
 
        my_malloc((uint) share->base.keys *
2570
 
                  (sizeof(MI_SORT_PARAM) + max_pack_reclength),
2571
 
                  MYF(MY_ZEROFILL))))
 
2568
        malloc(share->base.keys *
 
2569
               (sizeof(MI_SORT_PARAM) + max_pack_reclength))))
2572
2570
  {
2573
2571
    mi_check_print_error(param,"Not enough memory for key!");
2574
2572
    goto err;
2575
2573
  }
 
2574
  memset(sort_param, 0, share->base.keys *
 
2575
                        (sizeof(MI_SORT_PARAM) + max_pack_reclength));
2576
2576
  total_key_length=0;
2577
2577
  rec_per_key_part= param->rec_per_key_part;
2578
2578
  info->state->records=info->state->del=share->state.split=0;
3326
3326
          MI_DYN_DELETE_BLOCK_HEADER;
3327
3327
        if (sort_info->buff_length < reclength)
3328
3328
        {
3329
 
          if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength,
3330
 
                                           MYF(MY_FREE_ON_ERROR |
3331
 
                                               MY_ALLOW_ZERO_PTR))))
3332
 
            return(1);
3333
 
          sort_info->buff_length=reclength;
 
3329
          void *tmpptr= NULL;
 
3330
          if (!(tmpptr= realloc(sort_info->buff, reclength)))
 
3331
            sort_info->buff_length=reclength;
3334
3332
        }
3335
3333
        from= sort_info->buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER);
3336
3334
      }
3643
3641
  register uint32_t i;
3644
3642
  SORT_KEY_BLOCKS *block;
3645
3643
 
3646
 
  if (!(block=(SORT_KEY_BLOCKS*) my_malloc((sizeof(SORT_KEY_BLOCKS)+
3647
 
                                            buffer_length+IO_SIZE)*blocks,
3648
 
                                           MYF(0))))
 
3644
  if (!(block=(SORT_KEY_BLOCKS*) malloc((sizeof(SORT_KEY_BLOCKS)+
 
3645
                                        buffer_length+IO_SIZE)*blocks)))
3649
3646
  {
3650
3647
    mi_check_print_error(param,"Not enough memory for sort-key-blocks");
3651
3648
    return(0);
3665
3662
{
3666
3663
  if (info->s->options & HA_OPTION_COMPRESS_RECORD)
3667
3664
    return 0;
3668
 
  return my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(MY_THREADSAFE)) / 10 * 9 >
 
3665
  return (my_off_t)(lseek(info->s->kfile, 0L, SEEK_END) / 10 * 9) >
3669
3666
         (my_off_t) info->s->base.max_key_file_length ||
3670
 
         my_seek(info->dfile, 0L, MY_SEEK_END, MYF(0)) / 10 * 9 >
 
3667
         (my_off_t)(lseek(info->dfile, 0L, SEEK_END) / 10 * 9) >
3671
3668
         (my_off_t) info->s->base.max_data_file_length;
3672
3669
}
3673
3670
 
3762
3759
  if (share.options & HA_OPTION_COMPRESS_RECORD)
3763
3760
    share.base.records=max_records=info.state->records;
3764
3761
  else if (share.base.min_pack_length)
3765
 
    max_records=(ha_rows) (my_seek(info.dfile,0L,MY_SEEK_END,MYF(0)) /
 
3762
    max_records=(ha_rows) (lseek(info.dfile,0L,SEEK_END) /
3766
3763
                           (ulong) share.base.min_pack_length);
3767
3764
  else
3768
3765
    max_records=0;
3770
3767
    (param->testflag & T_UNPACK);
3771
3768
  share.options&= ~HA_OPTION_TEMP_COMPRESS_RECORD;
3772
3769
 
3773
 
  file_length=(uint64_t) my_seek(info.dfile,0L,MY_SEEK_END,MYF(0));
 
3770
  file_length=(uint64_t) lseek(info.dfile,0L,SEEK_END);
3774
3771
  tmp_length= file_length+file_length/10;
3775
3772
  set_if_bigger(file_length,param->max_data_file_length);
3776
3773
  set_if_bigger(file_length,tmp_length);