summaryrefslogtreecommitdiff
path: root/sql/sql_plugin.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r--sql/sql_plugin.cc66
1 files changed, 60 insertions, 6 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index ef4c63381e2..2a86844c8c6 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -181,6 +181,7 @@ public:
TYPELIB* plugin_var_typelib(void);
uchar* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
bool check(THD *thd, set_var *var);
+ bool check_default(enum_var_type type) { return is_readonly(); }
void set_default(THD *thd, enum_var_type type);
bool update(THD *thd, set_var *var);
};
@@ -1875,11 +1876,26 @@ err:
static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
void *save, st_mysql_value *value)
{
+ bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
plugin_opt_set_limits(&options, var);
- *(int *)save= (int) getopt_ull_limit_value(tmp, &options);
+
+ if (var->flags & PLUGIN_VAR_UNSIGNED)
+ *(uint *)save= (uint) getopt_ull_limit_value((ulonglong) tmp, &options,
+ &fixed);
+ else
+ *(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed);
+
+ if (fixed)
+ {
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), var->name,
+ ullstr(tmp, buf));
+ }
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
(*(int *)save != (int) tmp);
}
@@ -1888,24 +1904,55 @@ static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
void *save, st_mysql_value *value)
{
+ bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
plugin_opt_set_limits(&options, var);
- *(long *)save= (long) getopt_ull_limit_value(tmp, &options);
+
+ if (var->flags & PLUGIN_VAR_UNSIGNED)
+ *(ulong *)save= (ulong) getopt_ull_limit_value((ulonglong) tmp, &options,
+ &fixed);
+ else
+ *(long *)save= (long) getopt_ll_limit_value(tmp, &options, &fixed);
+
+ if (fixed)
+ {
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), var->name,
+ ullstr(tmp, buf));
+ }
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
(*(long *)save != (long) tmp);
}
static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,
- void *save, st_mysql_value *value)
+ void *save, st_mysql_value *value)
{
+ bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
plugin_opt_set_limits(&options, var);
- *(ulonglong *)save= getopt_ull_limit_value(tmp, &options);
+ *(ulonglong *)save= getopt_ull_limit_value(tmp, &options, &fixed);
+
+ if (var->flags & PLUGIN_VAR_UNSIGNED)
+ *(ulonglong *)save= getopt_ull_limit_value((ulonglong) tmp, &options,
+ &fixed);
+ else
+ *(longlong *)save= getopt_ll_limit_value(tmp, &options, &fixed);
+
+ if (fixed)
+ {
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), var->name,
+ ullstr(tmp, buf));
+ }
return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
(*(long long *)save != tmp);
}
@@ -2169,9 +2216,11 @@ static st_bookmark *register_var(const char *plugin, const char *name,
size= sizeof(int);
break;
case PLUGIN_VAR_LONG:
+ case PLUGIN_VAR_ENUM:
size= sizeof(long);
break;
case PLUGIN_VAR_LONGLONG:
+ case PLUGIN_VAR_SET:
size= sizeof(ulonglong);
break;
case PLUGIN_VAR_STR:
@@ -2612,6 +2661,7 @@ void sys_var_pluginvar::set_default(THD *thd, enum_var_type type)
if (is_readonly())
return;
+ pthread_mutex_lock(&LOCK_global_system_variables);
tgt= real_value_ptr(thd, type);
src= ((void **) (plugin_var + 1) + 1);
@@ -2628,12 +2678,14 @@ void sys_var_pluginvar::set_default(THD *thd, enum_var_type type)
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || type == OPT_GLOBAL)
{
- pthread_mutex_lock(&LOCK_plugin);
plugin_var->update(thd, plugin_var, tgt, src);
- pthread_mutex_unlock(&LOCK_plugin);
+ pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
+ {
+ pthread_mutex_unlock(&LOCK_global_system_variables);
plugin_var->update(thd, plugin_var, tgt, src);
+ }
}
@@ -2679,6 +2731,8 @@ bool sys_var_pluginvar::update(THD *thd, set_var *var)
static void plugin_opt_set_limits(struct my_option *options,
const struct st_mysql_sys_var *opt)
{
+ options->sub_size= 0;
+
switch (opt->flags & (PLUGIN_VAR_TYPEMASK |
PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL)) {
/* global system variables */