Merge lp:~akopytov/percona-server/bug878404-5.1 into lp:percona-server/5.1

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 329
Proposed branch: lp:~akopytov/percona-server/bug878404-5.1
Merge into: lp:percona-server/5.1
Diff against target: 738 lines (+726/-0)
2 files modified
patches/bug45702.patch (+725/-0)
patches/series (+1/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug878404-5.1
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+80495@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

LGTM

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches