Below is the list of changes that have just been committed into a local
5.0 repository of antony. When antony does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-20 02:33:50-07:00, antony@stripped +2 -0
Bug#10516
"No error or warning message in getopt_ull_limit_value()"
Validation does not emit any error messages if values are out of
range.
Perform checks when updating system variables when in STRICT mode.
Initial commit for review.
sql/set_var.cc@stripped, 2007-06-20 02:33:44-07:00, antony@stripped +73 -26
bug10516
check if getopt_ull_limit_value() has altered the value in ::check()
methods.
sql/set_var.h@stripped, 2007-06-20 02:33:44-07:00, antony@stripped +3 -0
bug10516
declare some new ::check() methods
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: antony
# Host: ppcg5.local
# Root: /private/Network/Servers/anubis.xiphis.org/home/antony/work/p3-bug10516.1
--- 1.187/sql/set_var.cc 2007-06-05 14:04:33 -07:00
+++ 1.188/sql/set_var.cc 2007-06-20 02:33:44 -07:00
@@ -1445,19 +1445,26 @@
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
{
- longlong v= var->value->val_int();
- var->save_result.ulonglong_value= v < 0 ? 0 : v;
- return 0;
+ sys_var_global::check(thd, var);
+ longlong v= (longlong) var->save_result.ulonglong_value;
+ ulonglong tmp= v < 0 ? 0 : v;
+
+ if (option_limits)
+ tmp= (ulong) getopt_ull_limit_value(tmp, option_limits);
+ else
+ tmp= (ulong) tmp;
+
+ bool result= (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)) &&
+ tmp != var->save_result.ulonglong_value;
+ var->save_result.ulonglong_value= tmp;
+ return result;
}
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
{
- ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(guard);
- if (option_limits)
- *value= (ulong) getopt_ull_limit_value(tmp, option_limits);
- else
- *value= (ulong) tmp;
+ *value= (ulong) var->save_result.ulonglong_value;
pthread_mutex_unlock(guard);
return 0;
}
@@ -1471,19 +1478,28 @@
}
-bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
+bool sys_var_ulonglong_ptr::check(THD *thd, set_var *var)
{
+ sys_var::check(thd, var);
ulonglong tmp= var->save_result.ulonglong_value;
- pthread_mutex_lock(&LOCK_global_system_variables);
if (option_limits)
- *value= (ulonglong) getopt_ull_limit_value(tmp, option_limits);
- else
- *value= (ulonglong) tmp;
+ tmp= (ulonglong) getopt_ull_limit_value(tmp, option_limits);
+
+ bool result= (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)) &&
+ tmp != var->save_result.ulonglong_value;
+ var->save_result.ulonglong_value= tmp;
+ return result;
+}
+
+bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
+{
+ pthread_mutex_lock(&LOCK_global_system_variables);
+ *value= var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
return 0;
}
-
void sys_var_ulonglong_ptr::set_default(THD *thd, enum_var_type type)
{
pthread_mutex_lock(&LOCK_global_system_variables);
@@ -1519,12 +1535,11 @@
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
{
- return (sys_var_thd::check(thd, var) ||
+ bool rc= (sys_var_thd::check(thd, var) ||
(check_func && (*check_func)(thd, var)));
-}
+ if (rc)
+ return TRUE;
-bool sys_var_thd_ulong::update(THD *thd, set_var *var)
-{
ulonglong tmp= var->save_result.ulonglong_value;
/* Don't use bigger value than given with --maximum-variable-name=.. */
@@ -1539,10 +1554,20 @@
if (option_limits)
tmp= (ulong) getopt_ull_limit_value(tmp, option_limits);
+
+ bool result= (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)) &&
+ tmp != var->save_result.ulonglong_value;
+ var->save_result.ulonglong_value= tmp;
+ return result;
+}
+
+bool sys_var_thd_ulong::update(THD *thd, set_var *var)
+{
if (var->type == OPT_GLOBAL)
- global_system_variables.*offset= (ulong) tmp;
+ global_system_variables.*offset= (ulong) var->save_result.ulonglong_value;
else
- thd->variables.*offset= (ulong) tmp;
+ thd->variables.*offset= (ulong) var->save_result.ulonglong_value;
return 0;
}
@@ -1568,8 +1593,9 @@
}
-bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
+bool sys_var_thd_ha_rows::check(THD *thd, set_var *var)
{
+ sys_var_thd::check(thd, var);
ulonglong tmp= var->save_result.ulonglong_value;
/* Don't use bigger value than given with --maximum-variable-name=.. */
@@ -1578,15 +1604,25 @@
if (option_limits)
tmp= (ha_rows) getopt_ull_limit_value(tmp, option_limits);
+
+ bool result= (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)) &&
+ tmp != var->save_result.ulonglong_value;
+ var->save_result.ulonglong_value= tmp;
+ return result;
+}
+
+bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
+{
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
pthread_mutex_lock(&LOCK_global_system_variables);
- global_system_variables.*offset= (ha_rows) tmp;
+ global_system_variables.*offset= (ha_rows) var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
- thd->variables.*offset= (ha_rows) tmp;
+ thd->variables.*offset= (ha_rows) var->save_result.ulonglong_value;
return 0;
}
@@ -1613,8 +1649,9 @@
return (byte*) &(thd->variables.*offset);
}
-bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
+bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
{
+ sys_var_thd::check(thd, var);
ulonglong tmp= var->save_result.ulonglong_value;
if (tmp > max_system_variables.*offset)
@@ -1622,15 +1659,25 @@
if (option_limits)
tmp= getopt_ull_limit_value(tmp, option_limits);
+
+ bool result= (thd->variables.sql_mode & (MODE_STRICT_TRANS_TABLES |
+ MODE_STRICT_ALL_TABLES)) &&
+ tmp != var->save_result.ulonglong_value;
+ var->save_result.ulonglong_value= tmp;
+ return result;
+}
+
+bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
+{
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
pthread_mutex_lock(&LOCK_global_system_variables);
- global_system_variables.*offset= (ulonglong) tmp;
+ global_system_variables.*offset= var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
- thd->variables.*offset= (ulonglong) tmp;
+ thd->variables.*offset= var->save_result.ulonglong_value;
return 0;
}
--- 1.83/sql/set_var.h 2007-02-21 03:05:01 -08:00
+++ 1.84/sql/set_var.h 2007-06-20 02:33:44 -07:00
@@ -132,6 +132,7 @@
sys_var_ulonglong_ptr(const char *name_arg, ulonglong *value_ptr_arg,
sys_after_update_func func)
:sys_var(name_arg,func), value(value_ptr_arg) {}
+ 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 show_type() { return SHOW_LONGLONG; }
@@ -319,6 +320,7 @@
sys_after_update_func func)
:sys_var_thd(name_arg,func), offset(offset_arg)
{}
+ 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 show_type() { return SHOW_HA_ROWS; }
@@ -339,6 +341,7 @@
:sys_var_thd(name_arg, func), offset(offset_arg),
only_global(only_global_arg)
{}
+ 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 show_type() { return SHOW_LONGLONG; }