Commit 57307860 authored by Michael Widenius's avatar Michael Widenius

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
parent bef95a4b
......@@ -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
......
......@@ -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;
......
......@@ -49,7 +49,7 @@ 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,
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);
......@@ -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)
{
......
......@@ -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(
......
......@@ -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");
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,7 +244,7 @@ struct CSphUrl
char * m_sBuffer;
char * m_sFormatted;
char * m_sScheme;
const char * m_sScheme;
char * m_sHost;
char * m_sIndex;
......@@ -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 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment