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