]>
Commit | Line | Data |
---|---|---|
734d6226 AM |
1 | --- a/include/my_sys.h |
2 | +++ b/include/my_sys.h | |
3 | @@ -320,8 +320,8 @@ | |
4 | typedef struct st_dynamic_array | |
5 | { | |
6 | uchar *buffer; | |
7 | - uint elements,max_element; | |
8 | - uint alloc_increment; | |
9 | + ulong elements, max_element; | |
10 | + ulong alloc_increment; | |
11 | uint size_of_element; | |
12 | } DYNAMIC_ARRAY; | |
13 | ||
14 | @@ -758,21 +758,21 @@ | |
15 | #define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E) | |
16 | #define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E) | |
17 | extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, | |
18 | - void *init_buffer, uint init_alloc, | |
19 | - uint alloc_increment); | |
20 | + void *init_buffer, ulong init_alloc, | |
21 | + ulong alloc_increment); | |
22 | /* init_dynamic_array() function is deprecated */ | |
23 | extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, | |
24 | - uint init_alloc, uint alloc_increment); | |
25 | + ulong init_alloc, ulong alloc_increment); | |
26 | extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element); | |
27 | extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array); | |
28 | extern uchar *pop_dynamic(DYNAMIC_ARRAY*); | |
29 | -extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); | |
30 | -extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements); | |
31 | -extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); | |
32 | +extern my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar * element, ulong array_index); | |
33 | +extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, ulong max_elements); | |
34 | +extern void get_dynamic(DYNAMIC_ARRAY *array, uchar * element, ulong array_index); | |
35 | extern void delete_dynamic(DYNAMIC_ARRAY *array); | |
36 | -extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); | |
37 | +extern void delete_dynamic_element(DYNAMIC_ARRAY *array, ulong array_index); | |
38 | extern void freeze_size(DYNAMIC_ARRAY *array); | |
39 | -extern int get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element); | |
40 | +extern long get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element); | |
41 | #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) | |
42 | #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) | |
43 | #define push_dynamic(A,B) insert_dynamic((A),(B)) | |
44 | --- a/mysys/array.c | |
45 | +++ b/mysys/array.c | |
46 | @@ -41,8 +41,8 @@ | |
47 | */ | |
48 | ||
49 | my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, | |
50 | - void *init_buffer, uint init_alloc, | |
51 | - uint alloc_increment) | |
52 | + void *init_buffer, ulong init_alloc, | |
53 | + ulong alloc_increment) | |
54 | { | |
55 | DBUG_ENTER("init_dynamic_array"); | |
56 | if (!alloc_increment) | |
57 | @@ -73,7 +73,7 @@ | |
58 | } | |
59 | ||
60 | my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, | |
61 | - uint init_alloc, uint alloc_increment) | |
62 | + ulong init_alloc, ulong alloc_increment) | |
63 | { | |
64 | /* placeholder to preserve ABI */ | |
65 | return my_init_dynamic_array_ci(array, element_size, init_alloc, | |
66 | @@ -196,7 +196,7 @@ | |
67 | FALSE Ok | |
68 | */ | |
69 | ||
70 | -my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) | |
71 | +my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, ulong idx) | |
72 | { | |
73 | if (idx >= array->elements) | |
74 | { | |
75 | @@ -228,11 +228,11 @@ | |
76 | TRUE Allocation of new memory failed | |
77 | */ | |
78 | ||
79 | -my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements) | |
80 | +my_bool allocate_dynamic(DYNAMIC_ARRAY *array, ulong max_elements) | |
81 | { | |
82 | if (max_elements >= array->max_element) | |
83 | { | |
84 | - uint size; | |
85 | + ulong size; | |
86 | uchar *new_ptr; | |
87 | size= (max_elements + array->alloc_increment)/array->alloc_increment; | |
88 | size*= array->alloc_increment; | |
89 | @@ -273,11 +273,11 @@ | |
90 | idx Index of element wanted. | |
91 | */ | |
92 | ||
93 | -void get_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) | |
94 | +void get_dynamic(DYNAMIC_ARRAY *array, uchar* element, ulong idx) | |
95 | { | |
96 | if (idx >= array->elements) | |
97 | { | |
98 | - DBUG_PRINT("warning",("To big array idx: %d, array size is %d", | |
99 | + DBUG_PRINT("warning",("To big array idx: %lu, array size is %lu", | |
100 | idx,array->elements)); | |
101 | bzero(element,array->size_of_element); | |
102 | return; | |
103 | @@ -320,7 +320,7 @@ | |
104 | idx Index of element to be deleted | |
105 | */ | |
106 | ||
107 | -void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) | |
108 | +void delete_dynamic_element(DYNAMIC_ARRAY *array, ulong idx) | |
109 | { | |
110 | char *ptr= (char*) array->buffer+array->size_of_element*idx; | |
111 | array->elements--; | |
112 | @@ -340,7 +340,7 @@ | |
113 | ||
114 | void freeze_size(DYNAMIC_ARRAY *array) | |
115 | { | |
116 | - uint elements=max(array->elements,1); | |
117 | + ulong elements= max(array->elements, 1); | |
118 | ||
119 | /* | |
120 | Do nothing if we are using a static buffer | |
121 | @@ -368,7 +368,7 @@ | |
122 | ||
123 | */ | |
124 | ||
125 | -int get_index_dynamic(DYNAMIC_ARRAY *array, uchar* element) | |
126 | +long get_index_dynamic(DYNAMIC_ARRAY *array, uchar* element) | |
127 | { | |
128 | size_t ret; | |
129 | if (array->buffer > element) | |
130 | --- a/storage/myisam/mi_check.c | |
131 | +++ b/storage/myisam/mi_check.c | |
132 | @@ -2429,7 +2429,7 @@ | |
133 | ||
134 | if (_create_index_by_sort(&sort_param, | |
135 | (my_bool) (!(param->testflag & T_VERBOSE)), | |
136 | - (uint) param->sort_buffer_length)) | |
137 | + param->sort_buffer_length)) | |
138 | { | |
139 | param->retry_repair=1; | |
140 | goto err; | |
141 | --- a/storage/myisam/sort.c | |
142 | +++ b/storage/myisam/sort.c | |
143 | @@ -45,42 +45,42 @@ | |
144 | ||
145 | /* Functions defined in this file */ | |
146 | ||
147 | -static ha_rows find_all_keys(MI_SORT_PARAM *info,uint keys, | |
148 | +static ha_rows find_all_keys(MI_SORT_PARAM *info, ulong keys, | |
149 | uchar **sort_keys, | |
150 | - DYNAMIC_ARRAY *buffpek,int *maxbuffer, | |
151 | + DYNAMIC_ARRAY *buffpek, long *maxbuffer, | |
152 | IO_CACHE *tempfile, | |
153 | IO_CACHE *tempfile_for_exceptions); | |
154 | static int write_keys(MI_SORT_PARAM *info,uchar **sort_keys, | |
155 | - uint count, BUFFPEK *buffpek,IO_CACHE *tempfile); | |
156 | + ulong count, BUFFPEK *buffpek,IO_CACHE *tempfile); | |
157 | static int write_key(MI_SORT_PARAM *info, uchar *key, | |
158 | IO_CACHE *tempfile); | |
159 | static int write_index(MI_SORT_PARAM *info,uchar * *sort_keys, | |
160 | - uint count); | |
161 | -static int merge_many_buff(MI_SORT_PARAM *info,uint keys, | |
162 | + ulong count); | |
163 | +static int merge_many_buff(MI_SORT_PARAM *info, ulong keys, | |
164 | uchar * *sort_keys, | |
165 | - BUFFPEK *buffpek,int *maxbuffer, | |
166 | + BUFFPEK *buffpek, long *maxbuffer, | |
167 | IO_CACHE *t_file); | |
168 | -static uint read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek, | |
169 | +static ulong read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek, | |
170 | uint sort_length); | |
171 | -static int merge_buffers(MI_SORT_PARAM *info,uint keys, | |
172 | +static int merge_buffers(MI_SORT_PARAM *info, ulong keys, | |
173 | IO_CACHE *from_file, IO_CACHE *to_file, | |
174 | uchar * *sort_keys, BUFFPEK *lastbuff, | |
175 | BUFFPEK *Fb, BUFFPEK *Tb); | |
176 | -static int merge_index(MI_SORT_PARAM *,uint,uchar **,BUFFPEK *, int, | |
177 | +static int merge_index(MI_SORT_PARAM *, ulong, uchar **, BUFFPEK *, long, | |
178 | IO_CACHE *); | |
179 | static int flush_ft_buf(MI_SORT_PARAM *info); | |
180 | ||
181 | static int write_keys_varlen(MI_SORT_PARAM *info,uchar **sort_keys, | |
182 | - uint count, BUFFPEK *buffpek, | |
183 | + ulong count, BUFFPEK *buffpek, | |
184 | IO_CACHE *tempfile); | |
185 | -static uint read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek, | |
186 | - uint sort_length); | |
187 | +static ulong read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek, | |
188 | + uint sort_length); | |
189 | static int write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file, | |
190 | - uchar *key, uint sort_length, uint count); | |
191 | + uchar *key, uint sort_length, ulong count); | |
192 | static int write_merge_key_varlen(MI_SORT_PARAM *info, | |
193 | IO_CACHE *to_file, | |
194 | uchar* key, uint sort_length, | |
195 | - uint count); | |
196 | + ulong count); | |
197 | static inline int | |
198 | my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs); | |
199 | ||
200 | @@ -101,8 +101,9 @@ | |
201 | int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, | |
202 | ulong sortbuff_size) | |
203 | { | |
204 | - int error,maxbuffer,skr; | |
205 | - uint memavl,old_memavl,keys,sort_length; | |
206 | + int error; | |
207 | + long maxbuffer, skr; | |
208 | + ulong memavl, old_memavl, keys, sort_length; | |
209 | DYNAMIC_ARRAY buffpek; | |
210 | ha_rows records; | |
211 | uchar **sort_keys; | |
212 | @@ -136,25 +137,25 @@ | |
213 | ||
214 | while (memavl >= MIN_SORT_BUFFER) | |
215 | { | |
216 | - if ((records < UINT_MAX32) && | |
217 | + if ((records < ULONG_MAX) && | |
218 | ((my_off_t) (records + 1) * | |
219 | (sort_length + sizeof(char*)) <= (my_off_t) memavl)) | |
220 | - keys= (uint)records+1; | |
221 | + keys= (ulong) records + 1; | |
222 | else | |
223 | do | |
224 | { | |
225 | skr=maxbuffer; | |
226 | - if (memavl < sizeof(BUFFPEK)*(uint) maxbuffer || | |
227 | - (keys=(memavl-sizeof(BUFFPEK)*(uint) maxbuffer)/ | |
228 | + if (memavl < sizeof(BUFFPEK) * (ulong) maxbuffer || | |
229 | + (keys = (memavl - sizeof(BUFFPEK) * (ulong) maxbuffer) / | |
230 | (sort_length+sizeof(char*))) <= 1 || | |
231 | - keys < (uint) maxbuffer) | |
232 | + keys < (ulong) maxbuffer) | |
233 | { | |
234 | mi_check_print_error(info->sort_info->param, | |
235 | "myisam_sort_buffer_size is too small"); | |
236 | goto err; | |
237 | } | |
238 | } | |
239 | - while ((maxbuffer= (int) (records/(keys-1)+1)) != skr); | |
240 | + while ((maxbuffer= (long) (records / (keys - 1) + 1)) != skr); | |
241 | ||
242 | if ((sort_keys=(uchar **)my_malloc(keys*(sort_length+sizeof(char*))+ | |
243 | HA_FT_MAXBYTELEN, MYF(0)))) | |
244 | @@ -180,7 +181,7 @@ | |
245 | (*info->lock_in_memory)(info->sort_info->param);/* Everything is allocated */ | |
246 | ||
247 | if (!no_messages) | |
248 | - printf(" - Searching for keys, allocating buffer for %d keys\n",keys); | |
249 | + printf(" - Searching for keys, allocating buffer for %lu keys\n", keys); | |
250 | ||
251 | if ((records=find_all_keys(info,keys,sort_keys,&buffpek,&maxbuffer, | |
252 | &tempfile,&tempfile_for_exceptions)) | |
253 | @@ -190,7 +191,7 @@ | |
254 | { | |
255 | if (!no_messages) | |
256 | printf(" - Dumping %lu keys\n", (ulong) records); | |
257 | - if (write_index(info,sort_keys, (uint) records)) | |
258 | + if (write_index(info,sort_keys, (ulong) records)) | |
259 | goto err; /* purecov: inspected */ | |
260 | } | |
261 | else | |
262 | @@ -253,13 +254,13 @@ | |
263 | ||
264 | /* Search after all keys and place them in a temp. file */ | |
265 | ||
266 | -static ha_rows find_all_keys(MI_SORT_PARAM *info, uint keys, | |
267 | +static ha_rows find_all_keys(MI_SORT_PARAM *info, ulong keys, | |
268 | uchar **sort_keys, DYNAMIC_ARRAY *buffpek, | |
269 | - int *maxbuffer, IO_CACHE *tempfile, | |
270 | + long *maxbuffer, IO_CACHE *tempfile, | |
271 | IO_CACHE *tempfile_for_exceptions) | |
272 | { | |
273 | int error; | |
274 | - uint idx; | |
275 | + ulong idx; | |
276 | DBUG_ENTER("find_all_keys"); | |
277 | ||
278 | idx=error=0; | |
279 | @@ -308,8 +309,8 @@ | |
280 | { | |
281 | MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg; | |
282 | int error; | |
283 | - uint memavl,old_memavl,keys,sort_length; | |
284 | - uint idx, maxbuffer; | |
285 | + ulong memavl,old_memavl,keys,sort_length; | |
286 | + ulong idx, maxbuffer; | |
287 | uchar **sort_keys=0; | |
288 | ||
289 | LINT_INIT(keys); | |
290 | @@ -345,7 +346,7 @@ | |
291 | sort_keys= (uchar **) NULL; | |
292 | ||
293 | memavl= max(sort_param->sortbuff_size, MIN_SORT_BUFFER); | |
294 | - idx= (uint)sort_param->sort_info->max_records; | |
295 | + idx= (ulong) sort_param->sort_info->max_records; | |
296 | sort_length= sort_param->key_length; | |
297 | maxbuffer= 1; | |
298 | ||
299 | @@ -356,21 +357,21 @@ | |
300 | keys= idx+1; | |
301 | else | |
302 | { | |
303 | - uint skr; | |
304 | + ulong skr; | |
305 | do | |
306 | { | |
307 | skr= maxbuffer; | |
308 | if (memavl < sizeof(BUFFPEK)*maxbuffer || | |
309 | (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/ | |
310 | (sort_length+sizeof(char*))) <= 1 || | |
311 | - keys < (uint) maxbuffer) | |
312 | + keys < maxbuffer) | |
313 | { | |
314 | mi_check_print_error(sort_param->sort_info->param, | |
315 | "myisam_sort_buffer_size is too small"); | |
316 | goto err; | |
317 | } | |
318 | } | |
319 | - while ((maxbuffer= (int) (idx/(keys-1)+1)) != skr); | |
320 | + while ((maxbuffer= (idx/(keys-1)+1)) != skr); | |
321 | } | |
322 | if ((sort_keys= (uchar**) | |
323 | my_malloc(keys*(sort_length+sizeof(char*))+ | |
324 | @@ -399,7 +400,7 @@ | |
325 | } | |
326 | ||
327 | if (sort_param->sort_info->param->testflag & T_VERBOSE) | |
328 | - printf("Key %d - Allocating buffer for %d keys\n", | |
329 | + printf("Key %d - Allocating buffer for %lu keys\n", | |
330 | sort_param->key + 1, keys); | |
331 | sort_param->sort_keys= sort_keys; | |
332 | ||
333 | @@ -553,7 +554,7 @@ | |
334 | } | |
335 | if (sinfo->buffpek.elements) | |
336 | { | |
337 | - uint maxbuffer=sinfo->buffpek.elements-1; | |
338 | + ulong maxbuffer=sinfo->buffpek.elements-1; | |
339 | if (!mergebuf) | |
340 | { | |
341 | length=param->sort_buffer_length; | |
342 | @@ -576,7 +577,7 @@ | |
343 | printf("Key %d - Merging %u keys\n",sinfo->key+1, sinfo->keys); | |
344 | if (merge_many_buff(sinfo, keys, (uchar **)mergebuf, | |
345 | dynamic_element(&sinfo->buffpek, 0, BUFFPEK *), | |
346 | - (int*) &maxbuffer, &sinfo->tempfile)) | |
347 | + (long *) &maxbuffer, &sinfo->tempfile)) | |
348 | { | |
349 | got_error=1; | |
350 | continue; | |
351 | @@ -640,7 +641,7 @@ | |
352 | /* Write all keys in memory to file for later merge */ | |
353 | ||
354 | static int write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, | |
355 | - uint count, BUFFPEK *buffpek, IO_CACHE *tempfile) | |
356 | + ulong count, BUFFPEK *buffpek, IO_CACHE *tempfile) | |
357 | { | |
358 | uchar **end; | |
359 | uint sort_length=info->key_length; | |
360 | @@ -682,7 +683,7 @@ | |
361 | ||
362 | static int write_keys_varlen(MI_SORT_PARAM *info, | |
363 | register uchar **sort_keys, | |
364 | - uint count, BUFFPEK *buffpek, | |
365 | + ulong count, BUFFPEK *buffpek, | |
366 | IO_CACHE *tempfile) | |
367 | { | |
368 | uchar **end; | |
369 | @@ -727,7 +728,7 @@ | |
370 | /* Write index */ | |
371 | ||
372 | static int write_index(MI_SORT_PARAM *info, register uchar **sort_keys, | |
373 | - register uint count) | |
374 | + register ulong count) | |
375 | { | |
376 | DBUG_ENTER("write_index"); | |
377 | ||
378 | @@ -744,11 +745,11 @@ | |
379 | ||
380 | /* Merge buffers to make < MERGEBUFF2 buffers */ | |
381 | ||
382 | -static int merge_many_buff(MI_SORT_PARAM *info, uint keys, | |
383 | +static int merge_many_buff(MI_SORT_PARAM *info, ulong keys, | |
384 | uchar **sort_keys, BUFFPEK *buffpek, | |
385 | - int *maxbuffer, IO_CACHE *t_file) | |
386 | + long *maxbuffer, IO_CACHE *t_file) | |
387 | { | |
388 | - register int i; | |
389 | + register long i; | |
390 | IO_CACHE t_file2, *from_file, *to_file, *temp; | |
391 | BUFFPEK *lastbuff; | |
392 | DBUG_ENTER("merge_many_buff"); | |
393 | @@ -778,7 +779,7 @@ | |
394 | if (flush_io_cache(to_file)) | |
395 | break; /* purecov: inspected */ | |
396 | temp=from_file; from_file=to_file; to_file=temp; | |
397 | - *maxbuffer= (int) (lastbuff-buffpek)-1; | |
398 | + *maxbuffer= (long) (lastbuff-buffpek)-1; | |
399 | } | |
400 | cleanup: | |
401 | close_cached_file(to_file); /* This holds old result */ | |
402 | @@ -807,18 +808,18 @@ | |
403 | -1 Error | |
404 | */ | |
405 | ||
406 | -static uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek, | |
407 | - uint sort_length) | |
408 | +static ulong read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek, | |
409 | + uint sort_length) | |
410 | { | |
411 | - register uint count; | |
412 | - uint length; | |
413 | + register ulong count; | |
414 | + ulong length; | |
415 | ||
416 | - if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) | |
417 | + if ((count=(ulong) min((ha_rows) buffpek->max_keys,buffpek->count))) | |
418 | { | |
419 | if (mysql_file_pread(fromfile->file, (uchar*) buffpek->base, | |
420 | (length= sort_length*count), | |
421 | buffpek->file_pos, MYF_RW)) | |
422 | - return((uint) -1); /* purecov: inspected */ | |
423 | + return((ulong) -1); /* purecov: inspected */ | |
424 | buffpek->key=buffpek->base; | |
425 | buffpek->file_pos+= length; /* New filepos */ | |
426 | buffpek->count-= count; | |
427 | @@ -827,15 +828,15 @@ | |
428 | return (count*sort_length); | |
429 | } /* read_to_buffer */ | |
430 | ||
431 | -static uint read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, | |
432 | +static ulong read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, | |
433 | uint sort_length) | |
434 | { | |
435 | - register uint count; | |
436 | + register ulong count; | |
437 | uint16 length_of_key = 0; | |
438 | - uint idx; | |
439 | + ulong idx; | |
440 | uchar *buffp; | |
441 | ||
442 | - if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) | |
443 | + if ((count=(ulong) min((ha_rows) buffpek->max_keys,buffpek->count))) | |
444 | { | |
445 | buffp = buffpek->base; | |
446 | ||
447 | @@ -843,11 +844,11 @@ | |
448 | { | |
449 | if (mysql_file_pread(fromfile->file, (uchar*)&length_of_key, | |
450 | sizeof(length_of_key), buffpek->file_pos, MYF_RW)) | |
451 | - return((uint) -1); | |
452 | + return((ulong) -1); | |
453 | buffpek->file_pos+=sizeof(length_of_key); | |
454 | if (mysql_file_pread(fromfile->file, (uchar*) buffp, | |
455 | length_of_key, buffpek->file_pos, MYF_RW)) | |
456 | - return((uint) -1); | |
457 | + return((ulong) -1); | |
458 | buffpek->file_pos+=length_of_key; | |
459 | buffp = buffp + sort_length; | |
460 | } | |
461 | @@ -861,9 +862,9 @@ | |
462 | ||
463 | static int write_merge_key_varlen(MI_SORT_PARAM *info, | |
464 | IO_CACHE *to_file, uchar* key, | |
465 | - uint sort_length, uint count) | |
466 | + uint sort_length, ulong count) | |
467 | { | |
468 | - uint idx; | |
469 | + ulong idx; | |
470 | uchar *bufs = key; | |
471 | ||
472 | for (idx=1;idx<=count;idx++) | |
473 | @@ -879,7 +880,7 @@ | |
474 | ||
475 | static int write_merge_key(MI_SORT_PARAM *info __attribute__((unused)), | |
476 | IO_CACHE *to_file, uchar *key, | |
477 | - uint sort_length, uint count) | |
478 | + uint sort_length, ulong count) | |
479 | { | |
480 | return my_b_write(to_file, key, (size_t) sort_length*count); | |
481 | } | |
482 | @@ -890,12 +891,13 @@ | |
483 | */ | |
484 | ||
485 | static int | |
486 | -merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, | |
487 | +merge_buffers(MI_SORT_PARAM *info, ulong keys, IO_CACHE *from_file, | |
488 | IO_CACHE *to_file, uchar **sort_keys, BUFFPEK *lastbuff, | |
489 | BUFFPEK *Fb, BUFFPEK *Tb) | |
490 | { | |
491 | - int error; | |
492 | - uint sort_length,maxcount; | |
493 | + ulong error; | |
494 | + uint sort_length; | |
495 | + ulong maxcount; | |
496 | ha_rows count; | |
497 | my_off_t UNINIT_VAR(to_start_filepos); | |
498 | uchar *strpos; | |
499 | @@ -905,7 +907,7 @@ | |
500 | DBUG_ENTER("merge_buffers"); | |
501 | ||
502 | count=error=0; | |
503 | - maxcount=keys/((uint) (Tb-Fb) +1); | |
504 | + maxcount= keys / ((ulong) (Tb-Fb) + 1); | |
505 | DBUG_ASSERT(maxcount > 0); | |
506 | LINT_INIT(to_start_filepos); | |
507 | if (to_file) | |
508 | @@ -913,7 +915,7 @@ | |
509 | strpos=(uchar*) sort_keys; | |
510 | sort_length=info->key_length; | |
511 | ||
512 | - if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0, | |
513 | + if (init_queue(&queue, (uint) (Tb-Fb)+1, offsetof(BUFFPEK,key), 0, | |
514 | (int (*)(void*, uchar *,uchar*)) info->key_cmp, | |
515 | (void*) info)) | |
516 | DBUG_RETURN(1); /* purecov: inspected */ | |
517 | @@ -923,9 +925,8 @@ | |
518 | count+= buffpek->count; | |
519 | buffpek->base= strpos; | |
520 | buffpek->max_keys=maxcount; | |
521 | - strpos+= (uint) (error=(int) info->read_to_buffer(from_file,buffpek, | |
522 | - sort_length)); | |
523 | - if (error == -1) | |
524 | + strpos+= (error= info->read_to_buffer(from_file,buffpek, sort_length)); | |
525 | + if (error == (ulong) -1) | |
526 | goto err; /* purecov: inspected */ | |
527 | queue_insert(&queue,(uchar*) buffpek); | |
528 | } | |
529 | @@ -957,10 +958,10 @@ | |
530 | buffpek->key+=sort_length; | |
531 | if (! --buffpek->mem_count) | |
532 | { | |
533 | - if (!(error=(int) info->read_to_buffer(from_file,buffpek,sort_length))) | |
534 | + if (!(error= info->read_to_buffer(from_file,buffpek,sort_length))) | |
535 | { | |
536 | uchar *base=buffpek->base; | |
537 | - uint max_keys=buffpek->max_keys; | |
538 | + ulong max_keys=buffpek->max_keys; | |
539 | ||
540 | (void) queue_remove(&queue,0); | |
541 | ||
542 | @@ -985,7 +986,7 @@ | |
543 | break; /* One buffer have been removed */ | |
544 | } | |
545 | } | |
546 | - else if (error == -1) | |
547 | + else if (error == (ulong) -1) | |
548 | goto err; /* purecov: inspected */ | |
549 | queue_replaced(&queue); /* Top element has been replaced */ | |
550 | } | |
551 | @@ -1018,23 +1019,23 @@ | |
552 | } | |
553 | } | |
554 | } | |
555 | - while ((error=(int) info->read_to_buffer(from_file,buffpek,sort_length)) != -1 && | |
556 | - error != 0); | |
557 | + while ((error= info->read_to_buffer(from_file,buffpek,sort_length)) | |
558 | + != (ulong) -1 && error != 0); | |
559 | ||
560 | lastbuff->count=count; | |
561 | if (to_file) | |
562 | lastbuff->file_pos=to_start_filepos; | |
563 | err: | |
564 | delete_queue(&queue); | |
565 | - DBUG_RETURN(error); | |
566 | + DBUG_RETURN(error != 0); | |
567 | } /* merge_buffers */ | |
568 | ||
569 | ||
570 | /* Do a merge to output-file (save only positions) */ | |
571 | ||
572 | static int | |
573 | -merge_index(MI_SORT_PARAM *info, uint keys, uchar **sort_keys, | |
574 | - BUFFPEK *buffpek, int maxbuffer, IO_CACHE *tempfile) | |
575 | +merge_index(MI_SORT_PARAM *info, ulong keys, uchar **sort_keys, | |
576 | + BUFFPEK *buffpek, long maxbuffer, IO_CACHE *tempfile) | |
577 | { | |
578 | DBUG_ENTER("merge_index"); | |
579 | if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek, | |
580 | --- /dev/null | |
581 | +++ b/mysql-test/r/percona_bug45702.result | |
582 | @@ -0,0 +1,21 @@ | |
583 | +CREATE TABLE t1 (a BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MyISAM; | |
584 | +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (); | |
585 | +INSERT INTO t1 SELECT NULL FROM t1; | |
586 | +INSERT INTO t1 SELECT NULL FROM t1; | |
587 | +INSERT INTO t1 SELECT NULL FROM t1; | |
588 | +INSERT INTO t1 SELECT NULL FROM t1; | |
589 | +INSERT INTO t1 SELECT NULL FROM t1; | |
590 | +INSERT INTO t1 SELECT NULL FROM t1; | |
591 | +INSERT INTO t1 SELECT NULL FROM t1; | |
592 | +INSERT INTO t1 SELECT NULL FROM t1; | |
593 | +INSERT INTO t1 SELECT NULL FROM t1; | |
594 | +SET @old_myisam_sort_buffer_size = @@myisam_sort_buffer_size; | |
595 | +SET @@myisam_sort_buffer_size = 4 * 1024 * 1024 * 1024; | |
596 | +REPAIR TABLE t1; | |
597 | +Table Op Msg_type Msg_text | |
598 | +test.t1 repair status OK | |
599 | +- recovering (with sort) MyISAM-table 'MYSQLD_DATADIR/test/t1' | |
600 | +Data records: 4096 | |
601 | +- Fixing index 1 | |
602 | +SET @@myisam_sort_buffer_size = @old_myisam_sort_buffer_size; | |
603 | +DROP TABLE t1; | |
604 | --- /dev/null | |
605 | +++ b/mysql-test/t/percona_bug45702.test | |
606 | @@ -0,0 +1,34 @@ | |
607 | +############################################################################### | |
608 | +# Bug #45702: Impossible to specify myisam_sort_buffer > 4GB on 64 bit machines | |
609 | +############################################################################### | |
610 | + | |
611 | +--source include/have_64bit.inc | |
612 | + | |
613 | +# Check that having data larger than MIN_SORT_BUFFER bytes can be handled by | |
614 | +# _create_index_by_sort() with myisam_sort_buffer_size = 4 GB without errors. | |
615 | +# The full test with large data volumes can not be a part of the test suite. | |
616 | + | |
617 | +CREATE TABLE t1 (a BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MyISAM; | |
618 | +INSERT INTO t1 VALUES (), (), (), (), (), (), (), (); | |
619 | +INSERT INTO t1 SELECT NULL FROM t1; | |
620 | +INSERT INTO t1 SELECT NULL FROM t1; | |
621 | +INSERT INTO t1 SELECT NULL FROM t1; | |
622 | +INSERT INTO t1 SELECT NULL FROM t1; | |
623 | +INSERT INTO t1 SELECT NULL FROM t1; | |
624 | +INSERT INTO t1 SELECT NULL FROM t1; | |
625 | +INSERT INTO t1 SELECT NULL FROM t1; | |
626 | +INSERT INTO t1 SELECT NULL FROM t1; | |
627 | +INSERT INTO t1 SELECT NULL FROM t1; | |
628 | + | |
629 | +SET @old_myisam_sort_buffer_size = @@myisam_sort_buffer_size; | |
630 | +SET @@myisam_sort_buffer_size = 4 * 1024 * 1024 * 1024; | |
631 | + | |
632 | +REPAIR TABLE t1; | |
633 | + | |
634 | +--let $MYSQLD_DATADIR= `select @@datadir` | |
635 | +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR | |
636 | +--exec $MYISAMCHK -r --sort_buffer_size=4G $MYSQLD_DATADIR/test/t1 | |
637 | + | |
638 | +SET @@myisam_sort_buffer_size = @old_myisam_sort_buffer_size; | |
639 | + | |
640 | +DROP TABLE t1; | |
641 | --- a/sql/opt_range.cc | |
642 | +++ b/sql/opt_range.cc | |
13ceb006 | 643 | @@ -11728,7 +11728,7 @@ |
734d6226 AM |
644 | } |
645 | if (min_max_ranges.elements > 0) | |
646 | { | |
647 | - fprintf(DBUG_FILE, "%*susing %d quick_ranges for MIN/MAX:\n", | |
648 | + fprintf(DBUG_FILE, "%*susing %lu quick_ranges for MIN/MAX:\n", | |
649 | indent, "", min_max_ranges.elements); | |
650 | } | |
651 | } | |
652 | --- a/mysys/my_pread.c | |
653 | +++ b/mysys/my_pread.c | |
654 | @@ -49,6 +49,7 @@ | |
655 | myf MyFlags) | |
656 | { | |
657 | size_t readbytes; | |
658 | + size_t total_readbytes= 0; | |
659 | int error= 0; | |
660 | #if !defined (HAVE_PREAD) && !defined (_WIN32) | |
661 | int save_errno; | |
662 | @@ -76,8 +77,30 @@ | |
663 | #endif | |
664 | error= (readbytes != Count); | |
665 | #endif | |
666 | + if (readbytes > 0) | |
667 | + total_readbytes+= readbytes; | |
668 | + | |
669 | if(error) | |
670 | { | |
671 | + if (readbytes > 0 && readbytes < Count && errno == 0) | |
672 | + { | |
673 | + /* | |
674 | + pread() may return less bytes than requested even if enough bytes are | |
675 | + available according to the Linux man page. | |
676 | + This makes determining the end-of-file condition a bit harder. | |
677 | + We just do another pread() call to see if more bytes can be read, | |
678 | + since all my_pread() users expect it to always return all available | |
679 | + bytes. For end-of-file 0 bytes is returned. This can never be the case | |
680 | + for a partial read, since according to the man page, -1 is returned | |
681 | + with errno set to EINTR if no data has been read. | |
682 | + */ | |
683 | + Buffer+= readbytes; | |
684 | + offset+= readbytes; | |
685 | + Count-= readbytes; | |
686 | + | |
687 | + continue; | |
688 | + } | |
689 | + | |
690 | my_errno= errno ? errno : -1; | |
691 | if (errno == 0 || (readbytes != (size_t) -1 && | |
692 | (MyFlags & (MY_NABP | MY_FNABP)))) | |
693 | @@ -107,7 +130,7 @@ | |
694 | } | |
695 | if (MyFlags & (MY_NABP | MY_FNABP)) | |
696 | DBUG_RETURN(0); /* Read went ok; Return 0 */ | |
697 | - DBUG_RETURN(readbytes); /* purecov: inspected */ | |
698 | + DBUG_RETURN(total_readbytes); /* purecov: inspected */ | |
699 | } | |
700 | } /* my_pread */ | |
701 | ||
702 | --- a/storage/myisam/myisamdef.h | |
703 | +++ b/storage/myisam/myisamdef.h | |
704 | @@ -340,10 +340,10 @@ | |
705 | int (*key_write)(struct st_mi_sort_param *, const void *); | |
706 | void (*lock_in_memory)(MI_CHECK *); | |
707 | int (*write_keys)(struct st_mi_sort_param *, register uchar **, | |
708 | - uint , struct st_buffpek *, IO_CACHE *); | |
709 | - uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); | |
710 | + ulong , struct st_buffpek *, IO_CACHE *); | |
711 | + ulong (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint); | |
712 | int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *, | |
713 | - uint, uint); | |
714 | + uint, ulong); | |
715 | } MI_SORT_PARAM; | |
716 | ||
717 | /* Some defines used by isam-funktions */ | |
718 | --- a/sql/rpl_mi.cc | |
719 | +++ b/sql/rpl_mi.cc | |
720 | @@ -491,7 +491,7 @@ | |
721 | (1 + mi->ignore_server_ids.elements), MYF(MY_WME)); | |
722 | if (!ignore_server_ids_buf) | |
723 | DBUG_RETURN(1); | |
724 | - ulong cur_len= sprintf(ignore_server_ids_buf, "%u", | |
725 | + ulong cur_len= sprintf(ignore_server_ids_buf, "%lu", | |
726 | mi->ignore_server_ids.elements); | |
727 | for (ulong i= 0; i < mi->ignore_server_ids.elements; i++) | |
728 | { |