diff options
author | Michael Widenius <monty@askmonty.org> | 2013-06-06 15:14:23 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-06-06 15:14:23 +0300 |
commit | 5730786041237db73e330ca388c98561ade8c43c (patch) | |
tree | 4f94b267ab6fd3c6133f9e1d78232ced0f49af83 | |
parent | bef95a4bbea0a3a42ad26798d3c3aa326dc282bf (diff) | |
download | mariadb-git-5730786041237db73e330ca388c98561ade8c43c.tar.gz |
Fixed some cache variables that could be set to higher value than what the code supported (size_t)
Fixed some cases that didn't work with > 4G buffers.
Fixed compiler warnings
include/mysql_com.h:
Avoid compiler warning with strncmp()
sql-common/client.c:
Fixed long comment; Added ()
sql/filesort.cc:
Fix code to get filesort to work with big buffers
sql/sys_vars.cc:
Fixed some cache variables that could be set to higher value than the size_t
Limit query cache to ULONG_MAX as the query cache buffer variables are ulong
storage/federatedx/ha_federatedx.cc:
Remove not used variable
storage/maria/ha_maria.cc:
Fix that bulk_insert() works with big buffers
storage/maria/ma_write.c:
Fix that bulk_insert() works with big buffers
storage/myisam/ha_myisam.cc:
Fix that bulk_insert() works with big buffers
storage/myisam/mi_write.c:
Fix that bulk_insert() works with big buffers
storage/sphinx/snippets_udf.cc:
Fixed compiler warnings
-rw-r--r-- | include/mysql_com.h | 4 | ||||
-rw-r--r-- | sql-common/client.c | 7 | ||||
-rw-r--r-- | sql/filesort.cc | 18 | ||||
-rw-r--r-- | sql/sys_vars.cc | 22 | ||||
-rw-r--r-- | storage/federatedx/ha_federatedx.cc | 1 | ||||
-rw-r--r-- | storage/maria/ha_maria.cc | 4 | ||||
-rw-r--r-- | storage/maria/ma_write.c | 8 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 3 | ||||
-rw-r--r-- | storage/myisam/mi_write.c | 8 | ||||
-rw-r--r-- | storage/sphinx/snippets_udf.cc | 10 |
10 files changed, 43 insertions, 42 deletions
diff --git a/include/mysql_com.h b/include/mysql_com.h index fdd75556033..bb89cd09efe 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -52,12 +52,8 @@ pluggable authentication, so any version starting from "5.5.5-" and claiming to support pluggable auth, must be using this fake prefix. */ -#ifdef EMBEDDED_LIBRARY -#define RPL_VERSION_HACK "" -#else /* this version must be the one that *does not* support pluggable auth */ #define RPL_VERSION_HACK "5.5.5-" -#endif #define SERVER_VERSION_LENGTH 60 #define SQLSTATE_LENGTH 5 diff --git a/sql-common/client.c b/sql-common/client.c index c81fe6a8a69..e77df80e146 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -3414,8 +3414,11 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, strmov(mysql->server_version,(char*) net->read_pos+1); mysql->port=port; - /* remove the rpl hack from the version string, see RPL_VERSION_HACK comment */ - if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH && + /* + remove the rpl hack from the version string, + see RPL_VERSION_HACK comment + */ + if ((mysql->server_capabilities & CLIENT_PLUGIN_AUTH) && strncmp(mysql->server_version, RPL_VERSION_HACK, sizeof(RPL_VERSION_HACK) - 1) == 0) mysql->server_version+= sizeof(RPL_VERSION_HACK) - 1; diff --git a/sql/filesort.cc b/sql/filesort.cc index ef5ef5357de..21b2f213a99 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -49,8 +49,8 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffer_file, uint count, static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select, uchar * *sort_keys, uchar *sort_keys_buf, IO_CACHE *buffer_file, IO_CACHE *tempfile); -static int write_keys(SORTPARAM *param,uchar * *sort_keys, - uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile); +static bool write_keys(SORTPARAM *param,uchar * *sort_keys, + uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile); static void make_sortkey(SORTPARAM *param,uchar *to, uchar *ref_pos); static void register_used_fields(SORTPARAM *param); static bool save_index(SORTPARAM *param,uchar **sort_keys, uint count, @@ -101,9 +101,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, bool sort_positions, ha_rows *examined_rows) { int error; - ulong memory_available= thd->variables.sortbuff_size; - ulong min_sort_memory; - ulong sort_buff_sz; + size_t memory_available= thd->variables.sortbuff_size; + size_t min_sort_memory; + size_t sort_buff_sz; uint maxbuffer; BUFFPEK *buffpek; ha_rows num_rows= HA_POS_ERROR; @@ -200,7 +200,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, { while (memory_available >= min_sort_memory) { - ulong keys= memory_available / (param.rec_length + sizeof(char*)); + ulonglong keys= memory_available / (param.rec_length + sizeof(char*)); table_sort.keys= (uint) min(num_rows, keys); sort_buff_sz= table_sort.keys*(param.rec_length+sizeof(char*)); set_if_bigger(sort_buff_sz, param.rec_length * MERGEBUFF2); @@ -211,7 +211,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, if ((table_sort.sort_keys= (uchar**) my_malloc(sort_buff_sz, MYF(0)))) break; - ulong old_memory_available= memory_available; + size_t old_memory_available= memory_available; memory_available= memory_available/4*3; if (memory_available < min_sort_memory && old_memory_available > min_sort_memory) @@ -391,7 +391,7 @@ void filesort_free_buffers(TABLE *table, bool full) static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, uchar *buf) { - ulong length= sizeof(BUFFPEK)*count; + size_t length= sizeof(BUFFPEK)*count; uchar *tmp= buf; DBUG_ENTER("read_buffpek_from_file"); if (count > UINT_MAX/sizeof(BUFFPEK)) @@ -711,7 +711,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, 1 Error */ -static int +static bool write_keys(SORTPARAM *param, register uchar **sort_keys, uint count, IO_CACHE *buffpek_pointers, IO_CACHE *tempfile) { diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 3df2605f834..b97f2a9dc1e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -223,7 +223,7 @@ static Sys_var_ulonglong Sys_binlog_cache_size( "you can increase this to get more performance", GLOBAL_VAR(binlog_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(IO_SIZE, ULONGLONG_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); + VALID_RANGE(IO_SIZE, SIZE_T_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); static Sys_var_ulonglong Sys_binlog_stmt_cache_size( "binlog_stmt_cache_size", "The size of the statement cache for " @@ -232,7 +232,7 @@ static Sys_var_ulonglong Sys_binlog_stmt_cache_size( "you can increase this to get more performance", GLOBAL_VAR(binlog_stmt_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(IO_SIZE, ULONGLONG_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); + VALID_RANGE(IO_SIZE, SIZE_T_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); /* Some variables like @sql_log_bin and @binlog_format change how/if binlogging @@ -365,7 +365,7 @@ static Sys_var_ulonglong Sys_bulk_insert_buff_size( "bulk_insert_buffer_size", "Size of tree cache used in bulk " "insert optimisation. Note that this is a limit per thread!", SESSION_VAR(bulk_insert_buff_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(8192*1024), BLOCK_SIZE(1)); + VALID_RANGE(0, SIZE_T_MAX), DEFAULT(8192*1024), BLOCK_SIZE(1)); static Sys_var_charptr Sys_character_sets_dir( "character_sets_dir", "Directory where character sets are", @@ -827,7 +827,7 @@ static Sys_var_ulonglong Sys_join_buffer_size( "join_buffer_size", "The size of the buffer that is used for joins", SESSION_VAR(join_buff_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(128, ULONGLONG_MAX), DEFAULT(128*1024), BLOCK_SIZE(128)); + VALID_RANGE(128, SIZE_T_MAX), DEFAULT(128*1024), BLOCK_SIZE(128)); static Sys_var_keycache Sys_key_buffer_size( "key_buffer_size", "The size of the buffer used for " @@ -1067,16 +1067,16 @@ static Sys_var_ulonglong Sys_max_binlog_cache_size( "max_binlog_cache_size", "Sets the total size of the transactional cache", GLOBAL_VAR(max_binlog_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(IO_SIZE, ULONGLONG_MAX), - DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE), + VALID_RANGE(IO_SIZE, SIZE_T_MAX), + DEFAULT((SIZE_T_MAX/IO_SIZE)*IO_SIZE), BLOCK_SIZE(IO_SIZE)); static Sys_var_ulonglong Sys_max_binlog_stmt_cache_size( "max_binlog_stmt_cache_size", "Sets the total size of the statement cache", GLOBAL_VAR(max_binlog_stmt_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(IO_SIZE, ULONGLONG_MAX), - DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE), + VALID_RANGE(IO_SIZE, SIZE_T_MAX), + DEFAULT((SIZE_T_MAX/IO_SIZE)*IO_SIZE), BLOCK_SIZE(IO_SIZE)); static bool fix_max_binlog_size(sys_var *self, THD *thd, enum_var_type type) @@ -1870,7 +1870,7 @@ static Sys_var_ulonglong Sys_query_cache_size( "query_cache_size", "The memory allocated to store results from old queries", GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, ULONGLONG_MAX), DEFAULT(0), BLOCK_SIZE(1024), + VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_query_cache_size), ON_UPDATE(fix_query_cache_size)); @@ -2094,7 +2094,7 @@ static Sys_var_ulonglong Sys_sort_buffer( "sort_buffer_size", "Each thread that needs to do a sort allocates a buffer of this size", SESSION_VAR(sortbuff_size), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(MIN_SORT_MEMORY, ULONGLONG_MAX), DEFAULT(MAX_SORT_MEMORY), + VALID_RANGE(MIN_SORT_MEMORY, SIZE_T_MAX), DEFAULT(MAX_SORT_MEMORY), BLOCK_SIZE(1)); export ulonglong expand_sql_mode(ulonglong sql_mode) @@ -2911,7 +2911,7 @@ static Sys_var_ulonglong Sys_group_concat_max_len( "group_concat_max_len", "The maximum length of the result of function GROUP_CONCAT()", SESSION_VAR(group_concat_max_len), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(4, ULONGLONG_MAX), DEFAULT(1024), BLOCK_SIZE(1)); + VALID_RANGE(4, SIZE_T_MAX), DEFAULT(1024), BLOCK_SIZE(1)); static char *glob_hostname_ptr; static Sys_var_charptr Sys_hostname( diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index aac2414bca1..eceeb2c3e92 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -537,7 +537,6 @@ static int parse_url_error(FEDERATEDX_SHARE *share, TABLE *table, int error_num) int get_connection(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share) { int error_num= ER_FOREIGN_SERVER_DOESNT_EXIST; - char error_buffer[FEDERATEDX_QUERY_BUFFER_SIZE]; FOREIGN_SERVER *server, server_buffer; DBUG_ENTER("ha_federatedx::get_connection"); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 7958868689b..6eccc14b51a 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2126,7 +2126,9 @@ void ha_maria::start_bulk_insert(ha_rows rows) else if (!file->bulk_insert && (!rows || rows >= MARIA_MIN_ROWS_TO_USE_BULK_INSERT)) { - maria_init_bulk_insert(file, thd->variables.bulk_insert_buff_size, rows); + maria_init_bulk_insert(file, + (size_t) thd->variables.bulk_insert_buff_size, + rows); } } DBUG_VOID_RETURN; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 944ae93b17f..a9022417986 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -1715,7 +1715,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) } -int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows) +int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows) { MARIA_SHARE *share= info->s; MARIA_KEYDEF *key=share->keyinfo; @@ -1723,7 +1723,7 @@ int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows) uint i, num_keys, total_keylength; ulonglong key_map; DBUG_ENTER("_ma_init_bulk_insert"); - DBUG_PRINT("enter",("cache_size: %lu", cache_size)); + DBUG_PRINT("enter",("cache_size: %lu", (ulong) cache_size)); DBUG_ASSERT(!info->bulk_insert && (!rows || rows >= MARIA_MIN_ROWS_TO_USE_BULK_INSERT)); @@ -1741,11 +1741,11 @@ int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows) } if (num_keys==0 || - num_keys * MARIA_MIN_SIZE_BULK_INSERT_TREE > cache_size) + num_keys * (size_t) MARIA_MIN_SIZE_BULK_INSERT_TREE > cache_size) DBUG_RETURN(0); if (rows && rows*total_keylength < cache_size) - cache_size= (ulong)rows; + cache_size= (size_t)rows; else cache_size/=total_keylength*16; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index e455b00418c..14216794728 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1556,7 +1556,8 @@ void ha_myisam::start_bulk_insert(ha_rows rows) if (!file->bulk_insert && (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT)) { - mi_init_bulk_insert(file, thd->variables.bulk_insert_buff_size, rows); + mi_init_bulk_insert(file, (size_t) thd->variables.bulk_insert_buff_size, + rows); } } DBUG_VOID_RETURN; diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 7bb063f2c10..915ea2b21b8 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -962,7 +962,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) } -int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows) +int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows) { MYISAM_SHARE *share=info->s; MI_KEYDEF *key=share->keyinfo; @@ -970,7 +970,7 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows) uint i, num_keys, total_keylength; ulonglong key_map; DBUG_ENTER("_mi_init_bulk_insert"); - DBUG_PRINT("enter",("cache_size: %lu", cache_size)); + DBUG_PRINT("enter",("cache_size: %lu", (ulong) cache_size)); DBUG_ASSERT(!info->bulk_insert && (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT)); @@ -988,11 +988,11 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows) } if (num_keys==0 || - num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > cache_size) + num_keys * (size_t) MI_MIN_SIZE_BULK_INSERT_TREE > cache_size) DBUG_RETURN(0); if (rows && rows*total_keylength < cache_size) - cache_size= (ulong)rows; + cache_size= (size_t) rows; else cache_size/=total_keylength*16; diff --git a/storage/sphinx/snippets_udf.cc b/storage/sphinx/snippets_udf.cc index 5318592ab5f..785b0ea6d97 100644 --- a/storage/sphinx/snippets_udf.cc +++ b/storage/sphinx/snippets_udf.cc @@ -180,7 +180,7 @@ enum #define SPHINXSE_DEFAULT_SCHEME "sphinx" #define SPHINXSE_DEFAULT_HOST "127.0.0.1" #define SPHINXSE_DEFAULT_PORT 9312 -#define SPHINXSE_DEFAULT_INDEX "*" +#define SPHINXSE_DEFAULT_INDEX (char*) "*" class CSphBuffer { @@ -244,9 +244,9 @@ struct CSphUrl char * m_sBuffer; char * m_sFormatted; - char * m_sScheme; + const char * m_sScheme; char * m_sHost; - char * m_sIndex; + char * m_sIndex; int m_iPort; @@ -254,7 +254,7 @@ struct CSphUrl : m_sBuffer ( NULL ) , m_sFormatted ( NULL ) , m_sScheme ( SPHINXSE_DEFAULT_SCHEME ) - , m_sHost ( SPHINXSE_DEFAULT_HOST ) + , m_sHost ( (char*) SPHINXSE_DEFAULT_HOST ) , m_sIndex ( SPHINXSE_DEFAULT_INDEX ) , m_iPort ( SPHINXSE_DEFAULT_PORT ) {} @@ -446,7 +446,7 @@ int CSphUrl::Connect() uint uServerVersion; uint uClientVersion = htonl ( SPHINX_SEARCHD_PROTO ); int iSocket = -1; - char * pError = NULL; + const char * pError = NULL; do { iSocket = socket ( iDomain, SOCK_STREAM, 0 ); |