~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/sort.cc

  • Committer: Monty Taylor
  • Date: 2009-03-22 00:20:27 UTC
  • mto: (960.2.17 fully-remove-queue)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: mordred@inaugust.com-20090322002027-4x9nxp8h4k21vkms
Fixed linkage issues on solaris.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
/* Functions defined in this file */
44
44
 
45
 
static ha_rows  find_all_keys(MI_SORT_PARAM *info,uint32_t keys,
 
45
extern "C" 
 
46
{
 
47
ha_rows  find_all_keys(MI_SORT_PARAM *info,uint32_t keys,
46
48
                              unsigned char **sort_keys,
47
49
                              DYNAMIC_ARRAY *buffpek,
48
50
                              size_t *maxbuffer,
49
51
                              IO_CACHE *tempfile,
50
52
                              IO_CACHE *tempfile_for_exceptions);
51
 
static int  write_keys(MI_SORT_PARAM *info,unsigned char **sort_keys,
 
53
int  write_keys(MI_SORT_PARAM *info,unsigned char **sort_keys,
52
54
                             uint32_t count, BUFFPEK *buffpek,IO_CACHE *tempfile);
53
 
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
 
55
int  write_key(MI_SORT_PARAM *info, unsigned char *key,
54
56
                            IO_CACHE *tempfile);
55
 
static int  write_index(MI_SORT_PARAM *info,unsigned char * *sort_keys,
 
57
int  write_index(MI_SORT_PARAM *info,unsigned char * *sort_keys,
56
58
                              uint32_t count);
57
 
static int  merge_many_buff(MI_SORT_PARAM *info,uint32_t keys,
 
59
int  merge_many_buff(MI_SORT_PARAM *info,uint32_t keys,
58
60
                            unsigned char * *sort_keys,
59
61
                            BUFFPEK *buffpek,size_t *maxbuffer,
60
62
                            IO_CACHE *t_file);
61
 
static uint32_t  read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
 
63
uint32_t  read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
62
64
                                  uint32_t sort_length);
63
 
static int  merge_buffers(MI_SORT_PARAM *info,uint32_t keys,
 
65
int  merge_buffers(MI_SORT_PARAM *info,uint32_t keys,
64
66
                                IO_CACHE *from_file, IO_CACHE *to_file,
65
67
                                unsigned char * *sort_keys, BUFFPEK *lastbuff,
66
68
                                BUFFPEK *Fb, BUFFPEK *Tb);
67
 
static int  merge_index(MI_SORT_PARAM *,uint,unsigned char **,BUFFPEK *, int,
 
69
int  merge_index(MI_SORT_PARAM *,uint,unsigned char **,BUFFPEK *, int,
68
70
                              IO_CACHE *);
69
 
 
70
 
static int  write_keys_varlen(MI_SORT_PARAM *info,unsigned char **sort_keys,
71
 
                                    uint32_t count, BUFFPEK *buffpek,
72
 
                                    IO_CACHE *tempfile);
73
 
static uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
74
 
                                         uint32_t sort_length);
75
 
static int  write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
76
 
                                  unsigned char *key, uint32_t sort_length, uint32_t count);
77
 
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
78
 
                                         IO_CACHE *to_file,
79
 
                                         unsigned char* key, uint32_t sort_length,
80
 
                                         uint32_t count);
81
 
static inline int
 
71
int  write_keys_varlen(MI_SORT_PARAM *info,unsigned char **sort_keys,
 
72
                       uint32_t count, BUFFPEK *buffpek,
 
73
                       IO_CACHE *tempfile);
 
74
uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
 
75
                                uint32_t sort_length);
 
76
int  write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
 
77
                     unsigned char *key, uint32_t sort_length, uint32_t count);
 
78
int  write_merge_key_varlen(MI_SORT_PARAM *info,
 
79
                            IO_CACHE *to_file,
 
80
                            unsigned char* key, uint32_t sort_length,
 
81
                            uint32_t count);
 
82
}
 
83
inline int
82
84
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, unsigned char *bufs);
83
85
 
84
86
/*
248
250
 
249
251
/* Search after all keys and place them in a temp. file */
250
252
 
251
 
static ha_rows  find_all_keys(MI_SORT_PARAM *info, uint32_t keys,
 
253
ha_rows  find_all_keys(MI_SORT_PARAM *info, uint32_t keys,
252
254
                              unsigned char **sort_keys,
253
255
                              DYNAMIC_ARRAY *buffpek,
254
256
                              size_t *maxbuffer, IO_CACHE *tempfile,
623
625
 
624
626
        /* Write all keys in memory to file for later merge */
625
627
 
626
 
static int  write_keys(MI_SORT_PARAM *info, register unsigned char **sort_keys,
 
628
int  write_keys(MI_SORT_PARAM *info, register unsigned char **sort_keys,
627
629
                             uint32_t count, BUFFPEK *buffpek, IO_CACHE *tempfile)
628
630
{
629
631
  unsigned char **end;
648
650
} /* write_keys */
649
651
 
650
652
 
651
 
static inline int
 
653
inline int
652
654
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, unsigned char *bufs)
653
655
{
654
656
  int err;
663
665
}
664
666
 
665
667
 
666
 
static int  write_keys_varlen(MI_SORT_PARAM *info,
 
668
int  write_keys_varlen(MI_SORT_PARAM *info,
667
669
                                    register unsigned char **sort_keys,
668
670
                                    uint32_t count, BUFFPEK *buffpek,
669
671
                                    IO_CACHE *tempfile)
689
691
} /* write_keys_varlen */
690
692
 
691
693
 
692
 
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
 
694
int  write_key(MI_SORT_PARAM *info, unsigned char *key,
693
695
                            IO_CACHE *tempfile)
694
696
{
695
697
  uint32_t key_length=info->real_key_length;
708
710
 
709
711
/* Write index */
710
712
 
711
 
static int  write_index(MI_SORT_PARAM *info, register unsigned char **sort_keys,
 
713
int  write_index(MI_SORT_PARAM *info, register unsigned char **sort_keys,
712
714
                              register uint32_t count)
713
715
{
714
716
  my_qsort2((unsigned char*) sort_keys,(size_t) count,sizeof(unsigned char*),
724
726
 
725
727
        /* Merge buffers to make < MERGEBUFF2 buffers */
726
728
 
727
 
static int  merge_many_buff(MI_SORT_PARAM *info, uint32_t keys,
 
729
int  merge_many_buff(MI_SORT_PARAM *info, uint32_t keys,
728
730
                            unsigned char **sort_keys, BUFFPEK *buffpek,
729
731
                            size_t *maxbuffer, IO_CACHE *t_file)
730
732
{
781
783
    -1  Error
782
784
*/
783
785
 
784
 
static uint32_t  read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
 
786
uint32_t  read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
785
787
                                  uint32_t sort_length)
786
788
{
787
789
  register uint32_t count;
800
802
  return (count*sort_length);
801
803
} /* read_to_buffer */
802
804
 
803
 
static uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
 
805
uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
804
806
                                         uint32_t sort_length)
805
807
{
806
808
  register uint32_t count;
832
834
} /* read_to_buffer_varlen */
833
835
 
834
836
 
835
 
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
 
837
int  write_merge_key_varlen(MI_SORT_PARAM *info,
836
838
                                         IO_CACHE *to_file, unsigned char* key,
837
839
                                         uint32_t sort_length, uint32_t count)
838
840
{
850
852
}
851
853
 
852
854
 
853
 
static int  write_merge_key(MI_SORT_PARAM *info,
 
855
int  write_merge_key(MI_SORT_PARAM *info,
854
856
                                  IO_CACHE *to_file, unsigned char *key,
855
857
                                  uint32_t sort_length, uint32_t count)
856
858
{
863
865
  If to_file == 0 then use info->key_write
864
866
*/
865
867
 
866
 
static int
 
868
int
867
869
merge_buffers(MI_SORT_PARAM *info, uint32_t keys, IO_CACHE *from_file,
868
870
              IO_CACHE *to_file, unsigned char **sort_keys, BUFFPEK *lastbuff,
869
871
              BUFFPEK *Fb, BUFFPEK *Tb)
1006
1008
 
1007
1009
        /* Do a merge to output-file (save only positions) */
1008
1010
 
1009
 
static int
 
1011
int
1010
1012
merge_index(MI_SORT_PARAM *info, uint32_t keys, unsigned char **sort_keys,
1011
1013
            BUFFPEK *buffpek, int maxbuffer, IO_CACHE *tempfile)
1012
1014
{