~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/sort.cc

merge innobase 1.0.9 build fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
        goto err;
205
205
    }
206
206
    if (internal::flush_io_cache(&tempfile) ||
207
 
        internal::reinit_io_cache(&tempfile,internal::READ_CACHE,0L,0,0))
 
207
        tempfile.reinit_io_cache(internal::READ_CACHE,0L,0,0))
208
208
      goto err;
209
209
    if (!no_messages)
210
210
      printf("  - Last merge and dumping keys\n");
222
222
    uint32_t     keyno=info->key;
223
223
    uint32_t     key_length, ref_length=idx->s->rec_reflength;
224
224
 
225
 
    if (!no_messages)
 
225
    if (not no_messages)
226
226
      printf("  - Adding exceptions\n");
227
 
    if (flush_io_cache(&tempfile_for_exceptions) ||
228
 
        reinit_io_cache(&tempfile_for_exceptions,internal::READ_CACHE,0L,0,0))
 
227
 
 
228
    if (flush_io_cache(&tempfile_for_exceptions) || tempfile_for_exceptions.reinit_io_cache(internal::READ_CACHE,0L,0,0))
 
229
    {
229
230
      goto err;
 
231
    }
230
232
 
231
233
    while (!my_b_read(&tempfile_for_exceptions,(unsigned char*)&key_length,
232
234
                      sizeof(key_length))
244
246
  if (sort_keys)
245
247
    free((unsigned char*) sort_keys);
246
248
  delete_dynamic(&buffpek);
247
 
  close_cached_file(&tempfile);
248
 
  close_cached_file(&tempfile_for_exceptions);
 
249
  tempfile.close_cached_file();
 
250
  tempfile_for_exceptions.close_cached_file();
249
251
 
250
252
  return(error ? -1 : 0);
251
253
} /* _create_index_by_sort */
357
359
       i < sort_info->total_keys ;
358
360
       i++,
359
361
         delete_dynamic(&sinfo->buffpek),
360
 
         close_cached_file(&sinfo->tempfile),
361
 
         close_cached_file(&sinfo->tempfile_for_exceptions),
 
362
         sinfo->tempfile.close_cached_file(),
 
363
         sinfo->tempfile_for_exceptions.close_cached_file(),
362
364
         sinfo++)
363
365
  {
364
366
    if (got_error)
406
408
          continue;
407
409
        }
408
410
      }
409
 
      if (flush_io_cache(&sinfo->tempfile) ||
410
 
          reinit_io_cache(&sinfo->tempfile,internal::READ_CACHE,0L,0,0))
 
411
      if (flush_io_cache(&sinfo->tempfile) || sinfo->tempfile.reinit_io_cache(internal::READ_CACHE,0L,0,0))
411
412
      {
412
413
        got_error=1;
413
414
        continue;
430
431
      if (param->testflag & T_VERBOSE)
431
432
        printf("Key %d  - Dumping 'long' keys\n", sinfo->key+1);
432
433
 
433
 
      if (flush_io_cache(&sinfo->tempfile_for_exceptions) ||
434
 
          reinit_io_cache(&sinfo->tempfile_for_exceptions,internal::READ_CACHE,0L,0,0))
 
434
      if (flush_io_cache(&sinfo->tempfile_for_exceptions) || sinfo->tempfile_for_exceptions.reinit_io_cache(internal::READ_CACHE,0L,0,0))
435
435
      {
436
436
        got_error=1;
437
437
        continue;
465
465
 
466
466
  internal::my_qsort2((unsigned char*) sort_keys,count,sizeof(unsigned char*),(qsort2_cmp) info->key_cmp,
467
467
            info);
468
 
  if (!my_b_inited(tempfile) &&
469
 
      open_cached_file(tempfile, P_tmpdir, "ST",
470
 
                       DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
 
468
  if (!my_b_inited(tempfile) && tempfile->open_cached_file(P_tmpdir, "ST", DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
471
469
    return(1);
472
470
 
473
471
  buffpek->file_pos=my_b_tell(tempfile);
507
505
 
508
506
  internal::my_qsort2((unsigned char*) sort_keys,count,sizeof(unsigned char*),(qsort2_cmp) info->key_cmp,
509
507
            info);
510
 
  if (!my_b_inited(tempfile) &&
511
 
      open_cached_file(tempfile, P_tmpdir, "ST",
512
 
                       DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
 
508
  if (!my_b_inited(tempfile) && tempfile->open_cached_file(P_tmpdir, "ST", DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
513
509
    return(1);
514
510
 
515
511
  buffpek->file_pos=my_b_tell(tempfile);
528
524
{
529
525
  uint32_t key_length=info->real_key_length;
530
526
 
531
 
  if (!my_b_inited(tempfile) &&
532
 
      open_cached_file(tempfile, P_tmpdir, "ST",
533
 
                       DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
 
527
  if (!my_b_inited(tempfile) && tempfile->open_cached_file(P_tmpdir, "ST", DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
534
528
    return(1);
535
529
 
536
530
  if (my_b_write(tempfile,(unsigned char*)&key_length,sizeof(key_length)) ||
568
562
 
569
563
  if (*maxbuffer < MERGEBUFF2)
570
564
    return(0);
571
 
  if (flush_io_cache(t_file) ||
572
 
      open_cached_file(&t_file2, P_tmpdir, "ST",
 
565
  if (flush_io_cache(t_file) || t_file2.open_cached_file(P_tmpdir, "ST",
573
566
                       DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
574
567
    return(1);
575
568
 
576
569
  from_file= t_file ; to_file= &t_file2;
577
570
  while (*maxbuffer >= MERGEBUFF2)
578
571
  {
579
 
    reinit_io_cache(from_file,internal::READ_CACHE,0L,0,0);
580
 
    reinit_io_cache(to_file,internal::WRITE_CACHE,0L,0,0);
 
572
    from_file->reinit_io_cache(internal::READ_CACHE,0L,0,0);
 
573
    to_file->reinit_io_cache(internal::WRITE_CACHE,0L,0,0);
581
574
    lastbuff=buffpek;
582
575
    for (i=0 ; i <= *maxbuffer-MERGEBUFF*3/2 ; i+=MERGEBUFF)
583
576
    {
594
587
    *maxbuffer= (int) (lastbuff-buffpek)-1;
595
588
  }
596
589
cleanup:
597
 
  close_cached_file(to_file);                   /* This holds old result */
 
590
  to_file->close_cached_file();                   /* This holds old result */
598
591
  if (to_file == t_file)
599
592
    *t_file=t_file2;                            /* Copy result file */
600
593