summaryrefslogtreecommitdiff
path: root/storage/myisam/sort.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/myisam/sort.c')
-rw-r--r--storage/myisam/sort.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c
index fe0c0f8f02e..198e669bbb4 100644
--- a/storage/myisam/sort.c
+++ b/storage/myisam/sort.c
@@ -47,7 +47,7 @@ extern void print_error(const char *fmt,...);
static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys,
- DYNAMIC_ARRAY *buffpek,uint *maxbuffer,
+ DYNAMIC_ARRAY *buffpek, size_t *maxbuffer,
IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions);
static int write_keys(MI_SORT_PARAM *info,uchar **sort_keys,
@@ -58,7 +58,7 @@ static int write_index(MI_SORT_PARAM *info,uchar * *sort_keys,
ha_keys count);
static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys,
uchar * *sort_keys,
- BUFFPEK *buffpek, uint *maxbuffer,
+ BUFFPEK *buffpek, size_t *maxbuffer,
IO_CACHE *t_file);
static my_off_t read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length);
@@ -66,7 +66,7 @@ static int merge_buffers(MI_SORT_PARAM *info, ha_keys keys,
IO_CACHE *from_file, IO_CACHE *to_file,
uchar * *sort_keys, BUFFPEK *lastbuff,
BUFFPEK *Fb, BUFFPEK *Tb);
-static int merge_index(MI_SORT_PARAM *,ha_keys,uchar **,BUFFPEK *, uint,
+static int merge_index(MI_SORT_PARAM *,ha_keys,uchar **,BUFFPEK *, size_t,
IO_CACHE *);
static int flush_ft_buf(MI_SORT_PARAM *info);
@@ -124,7 +124,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
ulonglong sortbuff_size)
{
int error;
- uint sort_length, maxbuffer;
+ uint sort_length;
+ size_t maxbuffer;
ulonglong memavl, old_memavl;
DYNAMIC_ARRAY buffpek;
ha_rows records, UNINIT_VAR(keys);
@@ -161,7 +162,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
will be allocated when needed.
*/
keys= memavl / (sort_length+sizeof(char*));
- maxbuffer= (uint) MY_MIN((ulonglong) 1000, (records / keys)+1);
+ maxbuffer= (size_t) MY_MIN((ulonglong) 1000, (records / keys)+1);
}
else
{
@@ -169,7 +170,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
All keys can't fit in memory.
Calculate how many keys + buffers we can keep in memory
*/
- uint maxbuffer_org;
+ size_t maxbuffer_org;
do
{
maxbuffer_org= maxbuffer;
@@ -186,7 +187,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
goto err;
}
}
- while ((maxbuffer= (uint) (records/(keys-1)+1)) != maxbuffer_org);
+ while ((maxbuffer= (size_t) (records/(keys-1)+1)) != maxbuffer_org);
}
if ((sort_keys= ((uchar **)
@@ -298,7 +299,7 @@ err:
static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_rows keys,
uchar **sort_keys, DYNAMIC_ARRAY *buffpek,
- uint *maxbuffer, IO_CACHE *tempfile,
+ size_t *maxbuffer, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions)
{
int error;
@@ -349,7 +350,7 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
ulonglong memavl, old_memavl, sortbuff_size;
ha_keys UNINIT_VAR(keys), idx;
uint sort_length;
- uint maxbuffer;
+ size_t maxbuffer;
uchar **sort_keys= NULL;
int error= 0;
DBUG_ENTER("thr_find_all_keys");
@@ -386,18 +387,18 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
will be allocated when needed.
*/
keys= memavl / (sort_length+sizeof(char*));
- maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1);
+ maxbuffer= (size_t) MY_MIN((ulonglong) 1000, (idx / keys)+1);
}
else
{
- uint maxbuffer_org;
+ size_t maxbuffer_org;
do
{
maxbuffer_org= maxbuffer;
if (memavl < sizeof(BUFFPEK)*maxbuffer ||
(keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
(sort_length+sizeof(char*))) <= 1 ||
- keys < (uint) maxbuffer)
+ keys < maxbuffer)
{
mi_check_print_error(sort_param->sort_info->param,
"myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u",
@@ -405,7 +406,7 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
DBUG_RETURN(TRUE);
}
}
- while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org);
+ while ((maxbuffer= (size_t) (idx/(keys-1)+1)) != maxbuffer_org);
}
if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME,
(size_t)(keys * (sort_length + sizeof(char*)) +
@@ -604,7 +605,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
if (sinfo->buffpek.elements)
{
- uint maxbuffer=sinfo->buffpek.elements-1;
+ size_t maxbuffer=sinfo->buffpek.elements-1;
if (!mergebuf)
{
length=param->sort_buffer_length;
@@ -806,9 +807,9 @@ static int write_index(MI_SORT_PARAM *info, register uchar **sort_keys,
static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys, BUFFPEK *buffpek,
- uint *maxbuffer, IO_CACHE *t_file)
+ size_t *maxbuffer, IO_CACHE *t_file)
{
- register uint i;
+ register size_t i;
IO_CACHE t_file2, *from_file, *to_file, *temp;
BUFFPEK *lastbuff;
DBUG_ENTER("merge_many_buff");
@@ -838,7 +839,7 @@ static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys,
if (flush_io_cache(to_file))
break; /* purecov: inspected */
temp=from_file; from_file=to_file; to_file=temp;
- *maxbuffer= (uint) (lastbuff-buffpek)-1;
+ *maxbuffer= (size_t) (lastbuff-buffpek)-1;
}
cleanup:
close_cached_file(to_file); /* This holds old result */
@@ -1099,7 +1100,7 @@ err:
static int
merge_index(MI_SORT_PARAM *info, ha_keys keys, uchar **sort_keys,
- BUFFPEK *buffpek, uint maxbuffer, IO_CACHE *tempfile)
+ BUFFPEK *buffpek, size_t maxbuffer, IO_CACHE *tempfile)
{
DBUG_ENTER("merge_index");
if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek,