Commit 23f786b0 authored by unknown's avatar unknown

bug#6958

Fixed that negative arguments to certain integer options wrap around.


mysql-test/r/variables.result:
  Added a test case for bug#6958.
mysql-test/t/variables.test:
  Added a test case for bug#6958.
sql/set_var.cc:
  sys_var_long_ptr::check function was added.
sql/set_var.h:
  Use sys_var_long_ptr::check function for sys_var_long_ptr class.
parent a20f2382
...@@ -482,3 +482,8 @@ SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8; ...@@ -482,3 +482,8 @@ SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value Variable_name Value
myisam_data_pointer_size 8 myisam_data_pointer_size 8
SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache';
Variable_name Value
table_cache 1
SET GLOBAL table_cache=DEFAULT;
...@@ -362,3 +362,11 @@ drop table t1; ...@@ -362,3 +362,11 @@ drop table t1;
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8; SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
#
# Bug #6958: negative arguments to integer options wrap around
#
SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache';
SET GLOBAL table_cache=DEFAULT;
...@@ -1223,6 +1223,12 @@ static void fix_server_id(THD *thd, enum_var_type type) ...@@ -1223,6 +1223,12 @@ static void fix_server_id(THD *thd, enum_var_type type)
server_id_supplied = 1; server_id_supplied = 1;
} }
bool sys_var_long_ptr::check(THD *thd, set_var *var)
{
longlong v= var->value->val_int();
var->save_result.ulonglong_value= v < 0 ? 0 : v;
return 0;
}
bool sys_var_long_ptr::update(THD *thd, set_var *var) bool sys_var_long_ptr::update(THD *thd, set_var *var)
{ {
......
...@@ -93,6 +93,7 @@ class sys_var_long_ptr :public sys_var ...@@ -93,6 +93,7 @@ class sys_var_long_ptr :public sys_var
sys_var_long_ptr(const char *name_arg, ulong *value_ptr, sys_var_long_ptr(const char *name_arg, ulong *value_ptr,
sys_after_update_func func) sys_after_update_func func)
:sys_var(name_arg,func), value(value_ptr) {} :sys_var(name_arg,func), value(value_ptr) {}
bool check(THD *thd, set_var *var);
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type); void set_default(THD *thd, enum_var_type type);
SHOW_TYPE type() { return SHOW_LONG; } SHOW_TYPE type() { return SHOW_LONG; }
......
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