Commit 23f786b0 authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -482,3 +482,8 @@ SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name	Value
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;
+8 −0
Original line number Diff line number Diff line
@@ -362,3 +362,11 @@ drop table t1;

SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8;
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;
+6 −0
Original line number Diff line number Diff line
@@ -1223,6 +1223,12 @@ static void fix_server_id(THD *thd, enum_var_type type)
  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)
{
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ class sys_var_long_ptr :public sys_var
  sys_var_long_ptr(const char *name_arg, ulong *value_ptr,
		   sys_after_update_func func)
    :sys_var(name_arg,func), value(value_ptr) {}
  bool check(THD *thd, set_var *var);
  bool update(THD *thd, set_var *var);
  void set_default(THD *thd, enum_var_type type);
  SHOW_TYPE type() { return SHOW_LONG; }