diff options
Diffstat (limited to 'storage/myisam')
-rw-r--r-- | storage/myisam/ft_boolean_search.c | 2 | ||||
-rw-r--r-- | storage/myisam/ft_nlq_search.c | 3 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 6 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.h | 3 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 21 | ||||
-rw-r--r-- | storage/myisam/mi_packrec.c | 2 | ||||
-rw-r--r-- | storage/myisam/mi_preload.c | 2 | ||||
-rw-r--r-- | storage/myisam/myisamchk.c | 7 | ||||
-rw-r--r-- | storage/myisam/myisamdef.h | 2 | ||||
-rw-r--r-- | storage/myisam/sort.c | 18 |
10 files changed, 35 insertions, 31 deletions
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 56d0149a748..f419ac3d689 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 6b36891ccf6..e31075e55d1 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -1,5 +1,4 @@ -/* - Copyright (c) 2001, 2010, Oracle and/or its affiliates +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 87fccb6f449..3f99dfc2186 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -74,10 +74,10 @@ static MYSQL_THDVAR_ULONG(repair_threads, PLUGIN_VAR_RQCMDARG, "disables parallel repair", NULL, NULL, 1, 1, ULONG_MAX, 1); -static MYSQL_THDVAR_ULONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG, +static MYSQL_THDVAR_ULONGLONG(sort_buffer_size, PLUGIN_VAR_RQCMDARG, "The buffer that is allocated when sorting the index when doing " "a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", NULL, NULL, - 8192*1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), ULONG_MAX, 1); + 8192 * 1024, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), SIZE_T_MAX, 1); static MYSQL_SYSVAR_BOOL(use_mmap, opt_myisam_use_mmap, PLUGIN_VAR_NOCMDARG, "Use memory mapping for reading and writing MyISAM tables", NULL, NULL, FALSE); diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 7439ea290c6..aa00398e7e7 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,6 @@ typedef struct st_ha_create_information HA_CREATE_INFO; #define HA_RECOVER_FULL_BACKUP 16 /* Make a copy of index file too */ #define HA_RECOVER_OFF 32 /* No automatic recover */ -extern ulong myisam_sort_buffer_size; extern TYPELIB myisam_recover_typelib; extern const char *myisam_recover_names[]; extern ulonglong myisam_recover_options; diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 04d2263ab5b..7e97a751376 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2406,7 +2406,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, if (_create_index_by_sort(&sort_param, (my_bool) (!(param->testflag & T_VERBOSE)), - (uint) param->sort_buffer_length)) + param->sort_buffer_length)) { param->retry_repair= 1; if (! param->error_printed) @@ -4312,14 +4312,6 @@ int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename) u_ptr->seg=keyseg; keyseg+=u_ptr->keysegs+1; } - if (share.options & HA_OPTION_COMPRESS_RECORD) - share.base.records=max_records=info.state->records; - else if (share.base.min_pack_length) - max_records=(ha_rows) (mysql_file_seek(info.dfile, 0L, MY_SEEK_END, - MYF(0)) / - (ulong) share.base.min_pack_length); - else - max_records=0; unpack= (share.options & HA_OPTION_COMPRESS_RECORD) && (param->testflag & T_UNPACK); share.options&= ~HA_OPTION_TEMP_COMPRESS_RECORD; @@ -4329,10 +4321,17 @@ int recreate_table(HA_CHECK *param, MI_INFO **org_info, char *filename) set_if_bigger(file_length,param->max_data_file_length); set_if_bigger(file_length,tmp_length); set_if_bigger(file_length,(ulonglong) share.base.max_data_file_length); + + if (share.options & HA_OPTION_COMPRESS_RECORD) + share.base.records= max_records= info.state->records; + else if (!(share.options & HA_OPTION_PACK_RECORD)) + max_records= (ha_rows) (file_length / share.base.pack_reclength); + else + max_records= 0; (void) mi_close(*org_info); bzero((char*) &create_info,sizeof(create_info)); - create_info.max_rows=max(max_records,share.base.records); + create_info.max_rows= max_records; create_info.reloc_rows=share.base.reloc; create_info.old_options=(share.options | (unpack ? HA_OPTION_TEMP_COMPRESS_RECORD : 0)); diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index c154ec3b817..7e2403b64c9 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c index 767858a6ea0..1a2d5aac94f 100644 --- a/storage/myisam/mi_preload.c +++ b/storage/myisam/mi_preload.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 32d39e5a09d..fa8cc679997 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1,5 +1,4 @@ -/* - Copyright (c) 2000, 2011, Oracle and/or its affiliates +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -297,9 +296,9 @@ static struct my_option my_long_options[] = INT_MAX32, (long) MALLOC_OVERHEAD, (long) 1L, 0}, { "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "", &check_param.sort_buffer_length, - &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG, + &check_param.sort_buffer_length, 0, GET_ULL, REQUIRED_ARG, (long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), - ULONG_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0}, + SIZE_T_MAX, (long) MALLOC_OVERHEAD, (long) 1L, 0}, { "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "", &check_param.sort_key_blocks, &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG, diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index a72b329a4c0..e3c1647cd59 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 6da2c5c7816..2c4639b3143 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -1,5 +1,4 @@ -/* - Copyright (c) 2000, 2011, Oracle and/or its affiliates +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -100,10 +99,11 @@ my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs); */ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, - ulong sortbuff_size) + ulonglong sortbuff_size) { int error,maxbuffer,skr; - uint memavl,old_memavl,keys,sort_length; + uint sort_length, keys; + ulonglong memavl, old_memavl; DYNAMIC_ARRAY buffpek; ha_rows records; uchar **sort_keys; @@ -135,6 +135,9 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, sort_length= info->key_length; LINT_INIT(keys); + if ((memavl - sizeof(BUFFPEK)) / (sort_length + sizeof(char *)) > UINT_MAX32) + memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *)); + while (memavl >= MIN_SORT_BUFFER) { if ((records < UINT_MAX32) && @@ -311,7 +314,8 @@ pthread_handler_t thr_find_all_keys(void *arg) { MI_SORT_PARAM *sort_param= (MI_SORT_PARAM*) arg; int error; - uint memavl,old_memavl,keys,sort_length; + ulonglong memavl, old_memavl; + uint keys, sort_length; uint idx, maxbuffer; uchar **sort_keys=0; @@ -352,6 +356,10 @@ pthread_handler_t thr_find_all_keys(void *arg) sort_length= sort_param->key_length; maxbuffer= 1; + if ((memavl - sizeof(BUFFPEK)) / (sort_length + + sizeof(char *)) > UINT_MAX32) + memavl= sizeof(BUFFPEK) + UINT_MAX32 * (sort_length + sizeof(char *)); + while (memavl >= MIN_SORT_BUFFER) { if ((my_off_t) (idx+1)*(sort_length+sizeof(char*)) <= |