~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/sort.c

  • Committer: Brian Aker
  • Date: 2008-10-06 05:57:49 UTC
  • Revision ID: brian@tangent.org-20081006055749-svg700gciuqi0zu1
Remove all of uchar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
/* Functions defined in this file */
45
45
 
46
46
static ha_rows  find_all_keys(MI_SORT_PARAM *info,uint keys,
47
 
                                    uchar **sort_keys,
 
47
                                    unsigned char **sort_keys,
48
48
                                    DYNAMIC_ARRAY *buffpek,int *maxbuffer,
49
49
                                    IO_CACHE *tempfile,
50
50
                                    IO_CACHE *tempfile_for_exceptions);
51
 
static int  write_keys(MI_SORT_PARAM *info,uchar **sort_keys,
 
51
static int  write_keys(MI_SORT_PARAM *info,unsigned char **sort_keys,
52
52
                             uint count, BUFFPEK *buffpek,IO_CACHE *tempfile);
53
 
static int  write_key(MI_SORT_PARAM *info, uchar *key,
 
53
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
54
54
                            IO_CACHE *tempfile);
55
 
static int  write_index(MI_SORT_PARAM *info,uchar * *sort_keys,
 
55
static int  write_index(MI_SORT_PARAM *info,unsigned char * *sort_keys,
56
56
                              uint count);
57
57
static int  merge_many_buff(MI_SORT_PARAM *info,uint keys,
58
 
                                  uchar * *sort_keys,
 
58
                                  unsigned char * *sort_keys,
59
59
                                  BUFFPEK *buffpek,int *maxbuffer,
60
60
                                  IO_CACHE *t_file);
61
61
static uint  read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
62
62
                                  uint sort_length);
63
63
static int  merge_buffers(MI_SORT_PARAM *info,uint keys,
64
64
                                IO_CACHE *from_file, IO_CACHE *to_file,
65
 
                                uchar * *sort_keys, BUFFPEK *lastbuff,
 
65
                                unsigned char * *sort_keys, BUFFPEK *lastbuff,
66
66
                                BUFFPEK *Fb, BUFFPEK *Tb);
67
 
static int  merge_index(MI_SORT_PARAM *,uint,uchar **,BUFFPEK *, int,
 
67
static int  merge_index(MI_SORT_PARAM *,uint,unsigned char **,BUFFPEK *, int,
68
68
                              IO_CACHE *);
69
69
 
70
 
static int  write_keys_varlen(MI_SORT_PARAM *info,uchar **sort_keys,
 
70
static int  write_keys_varlen(MI_SORT_PARAM *info,unsigned char **sort_keys,
71
71
                                    uint count, BUFFPEK *buffpek,
72
72
                                    IO_CACHE *tempfile);
73
73
static uint  read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
74
74
                                         uint sort_length);
75
75
static int  write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
76
 
                                  uchar *key, uint sort_length, uint count);
 
76
                                  unsigned char *key, uint sort_length, uint count);
77
77
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
78
78
                                         IO_CACHE *to_file,
79
 
                                         uchar* key, uint sort_length,
 
79
                                         unsigned char* key, uint sort_length,
80
80
                                         uint count);
81
81
static inline int
82
 
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs);
 
82
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, unsigned char *bufs);
83
83
 
84
84
/*
85
85
  Creates a index of sorted keys
102
102
  uint memavl,old_memavl,keys,sort_length;
103
103
  DYNAMIC_ARRAY buffpek;
104
104
  ha_rows records;
105
 
  uchar **sort_keys;
 
105
  unsigned char **sort_keys;
106
106
  IO_CACHE tempfile, tempfile_for_exceptions;
107
107
 
108
108
  if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
121
121
  my_b_clear(&tempfile);
122
122
  my_b_clear(&tempfile_for_exceptions);
123
123
  memset(&buffpek, 0, sizeof(buffpek));
124
 
  sort_keys= (uchar **) NULL; error= 1;
 
124
  sort_keys= (unsigned char **) NULL; error= 1;
125
125
  maxbuffer=1;
126
126
 
127
127
  memavl=cmax(sortbuff_size,MIN_SORT_MEMORY);
150
150
      }
151
151
      while ((maxbuffer= (int) (records/(keys-1)+1)) != skr);
152
152
 
153
 
    if ((sort_keys=(uchar **)my_malloc(keys*(sort_length+sizeof(char*)), MYF(0))))
 
153
    if ((sort_keys=(unsigned char **)my_malloc(keys*(sort_length+sizeof(char*)), MYF(0))))
154
154
    {
155
155
      if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer,
156
156
                             maxbuffer/2))
157
157
      {
158
 
        free((uchar*) sort_keys);
 
158
        free((unsigned char*) sort_keys);
159
159
        sort_keys= 0;
160
160
      }
161
161
      else
222
222
        reinit_io_cache(&tempfile_for_exceptions,READ_CACHE,0L,0,0))
223
223
      goto err;
224
224
 
225
 
    while (!my_b_read(&tempfile_for_exceptions,(uchar*)&key_length,
 
225
    while (!my_b_read(&tempfile_for_exceptions,(unsigned char*)&key_length,
226
226
                      sizeof(key_length))
227
 
        && !my_b_read(&tempfile_for_exceptions,(uchar*)sort_keys,
 
227
        && !my_b_read(&tempfile_for_exceptions,(unsigned char*)sort_keys,
228
228
                      (uint) key_length))
229
229
    {
230
 
        if (_mi_ck_write(idx,keyno,(uchar*) sort_keys,key_length-ref_length))
 
230
        if (_mi_ck_write(idx,keyno,(unsigned char*) sort_keys,key_length-ref_length))
231
231
          goto err;
232
232
    }
233
233
  }
236
236
 
237
237
err:
238
238
  if (sort_keys)
239
 
    free((uchar*) sort_keys);
 
239
    free((unsigned char*) sort_keys);
240
240
  delete_dynamic(&buffpek);
241
241
  close_cached_file(&tempfile);
242
242
  close_cached_file(&tempfile_for_exceptions);
248
248
/* Search after all keys and place them in a temp. file */
249
249
 
250
250
static ha_rows  find_all_keys(MI_SORT_PARAM *info, uint keys,
251
 
                                    uchar **sort_keys, DYNAMIC_ARRAY *buffpek,
 
251
                                    unsigned char **sort_keys, DYNAMIC_ARRAY *buffpek,
252
252
                                    int *maxbuffer, IO_CACHE *tempfile,
253
253
                                    IO_CACHE *tempfile_for_exceptions)
254
254
{
256
256
  uint idx;
257
257
 
258
258
  idx=error=0;
259
 
  sort_keys[0]=(uchar*) (sort_keys+keys);
 
259
  sort_keys[0]=(unsigned char*) (sort_keys+keys);
260
260
 
261
261
  while (!(error=(*info->key_read)(info,sort_keys[idx])))
262
262
  {
273
273
                     tempfile))
274
274
      return(HA_POS_ERROR);             /* purecov: inspected */
275
275
 
276
 
      sort_keys[0]=(uchar*) (sort_keys+keys);
 
276
      sort_keys[0]=(unsigned char*) (sort_keys+keys);
277
277
      memcpy(sort_keys[0],sort_keys[idx-1],(size_t) info->key_length);
278
278
      idx=1;
279
279
    }
303
303
  int error;
304
304
  uint memavl,old_memavl,keys,sort_length;
305
305
  uint idx, maxbuffer;
306
 
  uchar **sort_keys=0;
 
306
  unsigned char **sort_keys=0;
307
307
 
308
308
  error=1;
309
309
 
331
331
    my_b_clear(&sort_param->tempfile_for_exceptions);
332
332
    memset(&sort_param->buffpek, 0, sizeof(sort_param->buffpek));
333
333
    memset(&sort_param->unique, 0,  sizeof(sort_param->unique));
334
 
    sort_keys= (uchar **) NULL;
 
334
    sort_keys= (unsigned char **) NULL;
335
335
 
336
336
    memavl=       cmax(sort_param->sortbuff_size, MIN_SORT_MEMORY);
337
337
    idx=          (uint)sort_param->sort_info->max_records;
361
361
        }
362
362
        while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr);
363
363
      }
364
 
      if ((sort_keys= (uchar**)
 
364
      if ((sort_keys= (unsigned char**)
365
365
           my_malloc(keys*(sort_length+sizeof(char*)), MYF(0))))
366
366
      {
367
367
        if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK),
368
368
                                  maxbuffer, maxbuffer/2))
369
369
        {
370
 
          free((uchar*) sort_keys);
371
 
          sort_keys= (uchar **) NULL; /* for err: label */
 
370
          free((unsigned char*) sort_keys);
 
371
          sort_keys= (unsigned char **) NULL; /* for err: label */
372
372
        }
373
373
        else
374
374
          break;
391
391
    sort_param->sort_keys= sort_keys;
392
392
 
393
393
    idx= error= 0;
394
 
    sort_keys[0]= (uchar*) (sort_keys+keys);
 
394
    sort_keys[0]= (unsigned char*) (sort_keys+keys);
395
395
 
396
396
    while (!(error= sort_param->sort_info->got_error) &&
397
397
           !(error= (*sort_param->key_read)(sort_param, sort_keys[idx])))
410
410
                                   (BUFFPEK*) alloc_dynamic(&sort_param->buffpek),
411
411
                                   &sort_param->tempfile))
412
412
          goto err;
413
 
        sort_keys[0]= (uchar*) (sort_keys+keys);
 
413
        sort_keys[0]= (unsigned char*) (sort_keys+keys);
414
414
        memcpy(sort_keys[0], sort_keys[idx - 1], (size_t) sort_param->key_length);
415
415
        idx= 1;
416
416
      }
435
435
err:
436
436
    sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */
437
437
    if (sort_keys)
438
 
      free((uchar*) sort_keys);
 
438
      free((unsigned char*) sort_keys);
439
439
    sort_param->sort_keys= 0;
440
440
    delete_dynamic(& sort_param->buffpek);
441
441
    close_cached_file(&sort_param->tempfile);
476
476
  MI_INFO *info=sort_info->info;
477
477
  MYISAM_SHARE *share=info->s;
478
478
  MI_SORT_PARAM *sinfo;
479
 
  uchar *mergebuf=0;
 
479
  unsigned char *mergebuf=0;
480
480
 
481
481
  for (i= 0, sinfo= sort_param ;
482
482
       i < sort_info->total_keys ;
509
509
                         sinfo->notnull: NULL,
510
510
                         (uint64_t) info->state->records);
511
511
    }
512
 
    free((uchar*) sinfo->sort_keys);
 
512
    free((unsigned char*) sinfo->sort_keys);
513
513
    void * rec_buff_ptr= mi_get_rec_buff_ptr(info, sinfo->rec_buff);
514
514
    if (rec_buff_ptr != NULL)
515
515
      free(rec_buff_ptr);
561
561
      {
562
562
        if (param->testflag & T_VERBOSE)
563
563
          printf("Key %d  - Merging %u keys\n",sinfo->key+1, sinfo->keys);
564
 
        if (merge_many_buff(sinfo, keys, (uchar **)mergebuf,
 
564
        if (merge_many_buff(sinfo, keys, (unsigned char **)mergebuf,
565
565
                            dynamic_element(&sinfo->buffpek, 0, BUFFPEK *),
566
566
                            (int*) &maxbuffer, &sinfo->tempfile))
567
567
        {
577
577
      }
578
578
      if (param->testflag & T_VERBOSE)
579
579
        printf("Key %d  - Last merge and dumping keys\n", sinfo->key+1);
580
 
      if (merge_index(sinfo, keys, (uchar **)mergebuf,
 
580
      if (merge_index(sinfo, keys, (unsigned char **)mergebuf,
581
581
                      dynamic_element(&sinfo->buffpek,0,BUFFPEK *),
582
582
                      maxbuffer,&sinfo->tempfile) ||
583
583
          flush_pending_blocks(sinfo))
601
601
      }
602
602
 
603
603
      while (!got_error &&
604
 
             !my_b_read(&sinfo->tempfile_for_exceptions,(uchar*)&key_length,
 
604
             !my_b_read(&sinfo->tempfile_for_exceptions,(unsigned char*)&key_length,
605
605
                        sizeof(key_length)))
606
606
      {
607
 
        uchar ft_buf[10];
 
607
        unsigned char ft_buf[10];
608
608
        if (key_length > sizeof(ft_buf) ||
609
 
            my_b_read(&sinfo->tempfile_for_exceptions, (uchar*)ft_buf,
 
609
            my_b_read(&sinfo->tempfile_for_exceptions, (unsigned char*)ft_buf,
610
610
                      (uint)key_length) ||
611
 
            _mi_ck_write(info, sinfo->key, (uchar*)ft_buf,
 
611
            _mi_ck_write(info, sinfo->key, (unsigned char*)ft_buf,
612
612
                         key_length - info->s->rec_reflength))
613
613
          got_error=1;
614
614
      }
615
615
    }
616
616
  }
617
 
  free((uchar*) mergebuf);
 
617
  free((unsigned char*) mergebuf);
618
618
  return(got_error);
619
619
}
620
620
 
621
621
        /* Write all keys in memory to file for later merge */
622
622
 
623
 
static int  write_keys(MI_SORT_PARAM *info, register uchar **sort_keys,
 
623
static int  write_keys(MI_SORT_PARAM *info, register unsigned char **sort_keys,
624
624
                             uint count, BUFFPEK *buffpek, IO_CACHE *tempfile)
625
625
{
626
 
  uchar **end;
 
626
  unsigned char **end;
627
627
  uint sort_length=info->key_length;
628
628
 
629
 
  my_qsort2((uchar*) sort_keys,count,sizeof(uchar*),(qsort2_cmp) info->key_cmp,
 
629
  my_qsort2((unsigned char*) sort_keys,count,sizeof(unsigned char*),(qsort2_cmp) info->key_cmp,
630
630
            info);
631
631
  if (!my_b_inited(tempfile) &&
632
632
      open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
638
638
 
639
639
  for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
640
640
  {
641
 
    if (my_b_write(tempfile,(uchar*) *sort_keys,(uint) sort_length))
 
641
    if (my_b_write(tempfile,(unsigned char*) *sort_keys,(uint) sort_length))
642
642
      return(1); /* purecov: inspected */
643
643
  }
644
644
  return(0);
646
646
 
647
647
 
648
648
static inline int
649
 
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs)
 
649
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, unsigned char *bufs)
650
650
{
651
651
  int err;
652
 
  uint16_t len = _mi_keylength(info->keyinfo, (uchar*) bufs);
 
652
  uint16_t len = _mi_keylength(info->keyinfo, (unsigned char*) bufs);
653
653
 
654
654
  /* The following is safe as this is a local file */
655
 
  if ((err= my_b_write(to_file, (uchar*)&len, sizeof(len))))
 
655
  if ((err= my_b_write(to_file, (unsigned char*)&len, sizeof(len))))
656
656
    return (err);
657
657
  if ((err= my_b_write(to_file,bufs, (uint) len)))
658
658
    return (err);
661
661
 
662
662
 
663
663
static int  write_keys_varlen(MI_SORT_PARAM *info,
664
 
                                    register uchar **sort_keys,
 
664
                                    register unsigned char **sort_keys,
665
665
                                    uint count, BUFFPEK *buffpek,
666
666
                                    IO_CACHE *tempfile)
667
667
{
668
 
  uchar **end;
 
668
  unsigned char **end;
669
669
  int err;
670
670
 
671
 
  my_qsort2((uchar*) sort_keys,count,sizeof(uchar*),(qsort2_cmp) info->key_cmp,
 
671
  my_qsort2((unsigned char*) sort_keys,count,sizeof(unsigned char*),(qsort2_cmp) info->key_cmp,
672
672
            info);
673
673
  if (!my_b_inited(tempfile) &&
674
674
      open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
679
679
  buffpek->count=count;
680
680
  for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
681
681
  {
682
 
    if ((err= my_var_write(info,tempfile, (uchar*) *sort_keys)))
 
682
    if ((err= my_var_write(info,tempfile, (unsigned char*) *sort_keys)))
683
683
      return(err);
684
684
  }
685
685
  return(0);
686
686
} /* write_keys_varlen */
687
687
 
688
688
 
689
 
static int  write_key(MI_SORT_PARAM *info, uchar *key,
 
689
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
690
690
                            IO_CACHE *tempfile)
691
691
{
692
692
  uint key_length=info->real_key_length;
696
696
                       DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
697
697
    return(1);
698
698
 
699
 
  if (my_b_write(tempfile,(uchar*)&key_length,sizeof(key_length)) ||
700
 
      my_b_write(tempfile,(uchar*)key,(uint) key_length))
 
699
  if (my_b_write(tempfile,(unsigned char*)&key_length,sizeof(key_length)) ||
 
700
      my_b_write(tempfile,(unsigned char*)key,(uint) key_length))
701
701
    return(1);
702
702
  return(0);
703
703
} /* write_key */
705
705
 
706
706
/* Write index */
707
707
 
708
 
static int  write_index(MI_SORT_PARAM *info, register uchar **sort_keys,
 
708
static int  write_index(MI_SORT_PARAM *info, register unsigned char **sort_keys,
709
709
                              register uint count)
710
710
{
711
 
  my_qsort2((uchar*) sort_keys,(size_t) count,sizeof(uchar*),
 
711
  my_qsort2((unsigned char*) sort_keys,(size_t) count,sizeof(unsigned char*),
712
712
           (qsort2_cmp) info->key_cmp,info);
713
713
  while (count--)
714
714
  {
722
722
        /* Merge buffers to make < MERGEBUFF2 buffers */
723
723
 
724
724
static int  merge_many_buff(MI_SORT_PARAM *info, uint keys,
725
 
                                  uchar **sort_keys, BUFFPEK *buffpek,
 
725
                                  unsigned char **sort_keys, BUFFPEK *buffpek,
726
726
                                  int *maxbuffer, IO_CACHE *t_file)
727
727
{
728
728
  register int i;
786
786
 
787
787
  if ((count=(uint) cmin((ha_rows) buffpek->max_keys,buffpek->count)))
788
788
  {
789
 
    if (my_pread(fromfile->file,(uchar*) buffpek->base,
 
789
    if (my_pread(fromfile->file,(unsigned char*) buffpek->base,
790
790
                 (length= sort_length*count),buffpek->file_pos,MYF_RW))
791
791
      return((uint) -1);                        /* purecov: inspected */
792
792
    buffpek->key=buffpek->base;
803
803
  register uint count;
804
804
  uint16_t length_of_key = 0;
805
805
  uint idx;
806
 
  uchar *buffp;
 
806
  unsigned char *buffp;
807
807
 
808
808
  if ((count=(uint) cmin((ha_rows) buffpek->max_keys,buffpek->count)))
809
809
  {
811
811
 
812
812
    for (idx=1;idx<=count;idx++)
813
813
    {
814
 
      if (my_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key),
 
814
      if (my_pread(fromfile->file,(unsigned char*)&length_of_key,sizeof(length_of_key),
815
815
                   buffpek->file_pos,MYF_RW))
816
816
        return((uint) -1);
817
817
      buffpek->file_pos+=sizeof(length_of_key);
818
 
      if (my_pread(fromfile->file,(uchar*) buffp,length_of_key,
 
818
      if (my_pread(fromfile->file,(unsigned char*) buffp,length_of_key,
819
819
                   buffpek->file_pos,MYF_RW))
820
820
        return((uint) -1);
821
821
      buffpek->file_pos+=length_of_key;
830
830
 
831
831
 
832
832
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
833
 
                                         IO_CACHE *to_file, uchar* key,
 
833
                                         IO_CACHE *to_file, unsigned char* key,
834
834
                                         uint sort_length, uint count)
835
835
{
836
836
  uint idx;
837
 
  uchar *bufs = key;
 
837
  unsigned char *bufs = key;
838
838
 
839
839
  for (idx=1;idx<=count;idx++)
840
840
  {
848
848
 
849
849
 
850
850
static int  write_merge_key(MI_SORT_PARAM *info __attribute__((unused)),
851
 
                                  IO_CACHE *to_file, uchar *key,
 
851
                                  IO_CACHE *to_file, unsigned char *key,
852
852
                                  uint sort_length, uint count)
853
853
{
854
854
  return my_b_write(to_file, key, (size_t) sort_length*count);
861
861
 
862
862
static int
863
863
merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
864
 
              IO_CACHE *to_file, uchar **sort_keys, BUFFPEK *lastbuff,
 
864
              IO_CACHE *to_file, unsigned char **sort_keys, BUFFPEK *lastbuff,
865
865
              BUFFPEK *Fb, BUFFPEK *Tb)
866
866
{
867
867
  int error;
868
868
  uint sort_length,maxcount;
869
869
  ha_rows count;
870
870
  my_off_t to_start_filepos= 0;
871
 
  uchar *strpos;
 
871
  unsigned char *strpos;
872
872
  BUFFPEK *buffpek,**refpek;
873
873
  QUEUE queue;
874
874
  volatile int *killed= killed_ptr(info->sort_info->param);
878
878
  assert(maxcount > 0);
879
879
  if (to_file)
880
880
    to_start_filepos=my_b_tell(to_file);
881
 
  strpos=(uchar*) sort_keys;
 
881
  strpos=(unsigned char*) sort_keys;
882
882
  sort_length=info->key_length;
883
883
 
884
884
  if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0,
885
 
                 (int (*)(void*, uchar *,uchar*)) info->key_cmp,
 
885
                 (int (*)(void*, unsigned char *,unsigned char*)) info->key_cmp,
886
886
                 (void*) info))
887
887
    return(1); /* purecov: inspected */
888
888
 
895
895
                                                      sort_length));
896
896
    if (error == -1)
897
897
      goto err; /* purecov: inspected */
898
 
    queue_insert(&queue,(uchar*) buffpek);
 
898
    queue_insert(&queue,(unsigned char*) buffpek);
899
899
  }
900
900
 
901
901
  while (queue.elements > 1)
909
909
      buffpek=(BUFFPEK*) queue_top(&queue);
910
910
      if (to_file)
911
911
      {
912
 
        if (info->write_key(info,to_file,(uchar*) buffpek->key,
 
912
        if (info->write_key(info,to_file,(unsigned char*) buffpek->key,
913
913
                            (uint) sort_length,1))
914
914
        {
915
915
          error=1; goto err; /* purecov: inspected */
927
927
      {
928
928
        if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length)))
929
929
        {
930
 
          uchar *base=buffpek->base;
 
930
          unsigned char *base=buffpek->base;
931
931
          uint max_keys=buffpek->max_keys;
932
932
 
933
933
          queue_remove(&queue,0);
959
959
    }
960
960
  }
961
961
  buffpek=(BUFFPEK*) queue_top(&queue);
962
 
  buffpek->base=(uchar *) sort_keys;
 
962
  buffpek->base=(unsigned char *) sort_keys;
963
963
  buffpek->max_keys=keys;
964
964
  do
965
965
  {
966
966
    if (to_file)
967
967
    {
968
 
      if (info->write_key(info,to_file,(uchar*) buffpek->key,
 
968
      if (info->write_key(info,to_file,(unsigned char*) buffpek->key,
969
969
                         sort_length,buffpek->mem_count))
970
970
      {
971
971
        error=1; goto err; /* purecov: inspected */
973
973
    }
974
974
    else
975
975
    {
976
 
      register uchar *end;
 
976
      register unsigned char *end;
977
977
      strpos= buffpek->key;
978
978
      for (end=strpos+buffpek->mem_count*sort_length;
979
979
           strpos != end ;
1001
1001
        /* Do a merge to output-file (save only positions) */
1002
1002
 
1003
1003
static int
1004
 
merge_index(MI_SORT_PARAM *info, uint keys, uchar **sort_keys,
 
1004
merge_index(MI_SORT_PARAM *info, uint keys, unsigned char **sort_keys,
1005
1005
            BUFFPEK *buffpek, int maxbuffer, IO_CACHE *tempfile)
1006
1006
{
1007
1007
  if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek,