Description:
When updating a system variable installed by a plugin to an illegal value with SET, will not show the correct variable name in the warning/error message.
This can be shown by the example plugin, that installs a variable named "ulong_var", since the name of the plugin is "example", the variable will be installed as "example_ulong_var". But when updating that variable to an illegal value with SET, the warning shown will print only "ulong_var" - it should say "example_ulong_var".
How to repeat:
mysql> INSTALL PLUGIN example SONAME 'ha_example.so';
mysql> set global example_ulong_var=1111;
ERROR 42000: Variable 'ulong_var' can't be set to the value of '1111'
^^^^^^^^
The easiest way or reproducing is to look in mysql-test/r/plugin.result where the faulty warning message is already recorded.
The following patch corrects the .result file to show the problem:
=== modified file 'mysql-test/r/plugin.result'
--- mysql-test/r/plugin.result 2008-02-24 13:12:17 +0000
+++ mysql-test/r/plugin.result 2009-02-11 19:18:06 +0000
@@ -25,7 +25,7 @@ INSTALL PLUGIN example SONAME 'ha_exampl
SET GLOBAL example_enum_var= e1;
SET GLOBAL example_enum_var= e2;
SET GLOBAL example_enum_var= impossible;
-ERROR 42000: Variable 'enum_var' can't be set to the value of 'impossible'
+ERROR 42000: Variable 'example_enum_var' can't be set to the value of 'impossib
le'
UNINSTALL PLUGIN example;
INSTALL PLUGIN example SONAME 'ha_example.so';
select @@session.sql_mode into @old_sql_mode;
@@ -36,7 +36,7 @@ select @@global.example_ulong_var;
500
set global example_ulong_var=1111;
Warnings:
-Warning 1292 Truncated incorrect ulong_var value: '1111'
+Warning 1292 Truncated incorrect example_ulong_var value: '1111'
select @@global.example_ulong_var;
@@global.example_ulong_var
1000
@@ -46,7 +46,7 @@ select @@global.example_ulong_var;
@@global.example_ulong_var
500
set global example_ulong_var=1111;
-ERROR 42000: Variable 'ulong_var' can't be set to the value of '1111'
+ERROR 42000: Variable 'example_ulong_var' can't be set to the value of '1111'
select @@global.example_ulong_var;
@@global.example_ulong_var
500
Suggested fix:
The following fix does "fix" the problem (but unfortunately modiffies mysql/plugin.h which is probably not what we want). Maybe it also exposes, some internal class?
=== modified file 'include/mysql/plugin.h'
--- include/mysql/plugin.h 2008-03-07 21:46:29 +0000
+++ include/mysql/plugin.h 2009-02-11 19:09:32 +0000
@@ -168,7 +168,7 @@ struct st_mysql_value;
*/
typedef int (*mysql_var_check_func)(MYSQL_THD thd,
- struct st_mysql_sys_var *var,
+ class sys_var_pluginvar *var,
void *save, struct st_mysql_value *value);
/*
@@ -186,7 +186,7 @@ typedef int (*mysql_var_check_func)(MYSQ
For example, strings may require memory to be allocated.
*/
typedef void (*mysql_var_update_func)(MYSQL_THD thd,
- struct st_mysql_sys_var *var,
+ class sys_var_pluginvar *var,
void *var_ptr, const void *save);
=== modified file 'sql/sql_plugin.cc'
--- sql/sql_plugin.cc 2009-02-09 15:03:52 +0000
+++ sql/sql_plugin.cc 2009-02-11 19:16:41 +0000
@@ -1871,7 +1871,7 @@ typedef uchar *(*mysql_sys_var_ptr_p)(vo
default variable data check and update functions
****************************************************************************/
-static int check_func_bool(THD *thd, struct st_mysql_sys_var *var,
+static int check_func_bool(THD *thd, sys_var_pluginvar *var,
void *save, st_mysql_value *value)
{
char buff[STRING_BUFFER_USUAL_SIZE];
@@ -1910,66 +1910,66 @@ err:
}
-static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
+static int check_func_int(THD *thd, sys_var_pluginvar *var,
void *save, st_mysql_value *value)
{
my_bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
- plugin_opt_set_limits(&options, var);
+ plugin_opt_set_limits(&options, var->plugin_var);
- if (var->flags & PLUGIN_VAR_UNSIGNED)
+ if (var->plugin_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);
- return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
+ return throw_bounds_warning(thd, fixed, var->plugin_var->flags & PLUGIN_VAR_UNSIGNED,
var->name, (longlong) tmp);
}
-static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
+static int check_func_long(THD *thd, sys_var_pluginvar *var,
void *save, st_mysql_value *value)
{
my_bool fixed;
long long tmp;
struct my_option options;
value->val_int(value, &tmp);
- plugin_opt_set_limits(&options, var);
+ plugin_opt_set_limits(&options, var->plugin_var);
- if (var->flags & PLUGIN_VAR_UNSIGNED)
+ if (var->plugin_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);
- return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
+ return throw_bounds_warning(thd, fixed, var->plugin_var->flags & PLUGIN_VAR_UNSIGNED,
var->name, (longlong) tmp);
}
<snip>
Description: When updating a system variable installed by a plugin to an illegal value with SET, will not show the correct variable name in the warning/error message. This can be shown by the example plugin, that installs a variable named "ulong_var", since the name of the plugin is "example", the variable will be installed as "example_ulong_var". But when updating that variable to an illegal value with SET, the warning shown will print only "ulong_var" - it should say "example_ulong_var". How to repeat: mysql> INSTALL PLUGIN example SONAME 'ha_example.so'; mysql> set global example_ulong_var=1111; ERROR 42000: Variable 'ulong_var' can't be set to the value of '1111' ^^^^^^^^ The easiest way or reproducing is to look in mysql-test/r/plugin.result where the faulty warning message is already recorded. The following patch corrects the .result file to show the problem: === modified file 'mysql-test/r/plugin.result' --- mysql-test/r/plugin.result 2008-02-24 13:12:17 +0000 +++ mysql-test/r/plugin.result 2009-02-11 19:18:06 +0000 @@ -25,7 +25,7 @@ INSTALL PLUGIN example SONAME 'ha_exampl SET GLOBAL example_enum_var= e1; SET GLOBAL example_enum_var= e2; SET GLOBAL example_enum_var= impossible; -ERROR 42000: Variable 'enum_var' can't be set to the value of 'impossible' +ERROR 42000: Variable 'example_enum_var' can't be set to the value of 'impossib le' UNINSTALL PLUGIN example; INSTALL PLUGIN example SONAME 'ha_example.so'; select @@session.sql_mode into @old_sql_mode; @@ -36,7 +36,7 @@ select @@global.example_ulong_var; 500 set global example_ulong_var=1111; Warnings: -Warning 1292 Truncated incorrect ulong_var value: '1111' +Warning 1292 Truncated incorrect example_ulong_var value: '1111' select @@global.example_ulong_var; @@global.example_ulong_var 1000 @@ -46,7 +46,7 @@ select @@global.example_ulong_var; @@global.example_ulong_var 500 set global example_ulong_var=1111; -ERROR 42000: Variable 'ulong_var' can't be set to the value of '1111' +ERROR 42000: Variable 'example_ulong_var' can't be set to the value of '1111' select @@global.example_ulong_var; @@global.example_ulong_var 500 Suggested fix: The following fix does "fix" the problem (but unfortunately modiffies mysql/plugin.h which is probably not what we want). Maybe it also exposes, some internal class? === modified file 'include/mysql/plugin.h' --- include/mysql/plugin.h 2008-03-07 21:46:29 +0000 +++ include/mysql/plugin.h 2009-02-11 19:09:32 +0000 @@ -168,7 +168,7 @@ struct st_mysql_value; */ typedef int (*mysql_var_check_func)(MYSQL_THD thd, - struct st_mysql_sys_var *var, + class sys_var_pluginvar *var, void *save, struct st_mysql_value *value); /* @@ -186,7 +186,7 @@ typedef int (*mysql_var_check_func)(MYSQ For example, strings may require memory to be allocated. */ typedef void (*mysql_var_update_func)(MYSQL_THD thd, - struct st_mysql_sys_var *var, + class sys_var_pluginvar *var, void *var_ptr, const void *save); === modified file 'sql/sql_plugin.cc' --- sql/sql_plugin.cc 2009-02-09 15:03:52 +0000 +++ sql/sql_plugin.cc 2009-02-11 19:16:41 +0000 @@ -1871,7 +1871,7 @@ typedef uchar *(*mysql_sys_var_ptr_p)(vo default variable data check and update functions ****************************************************************************/ -static int check_func_bool(THD *thd, struct st_mysql_sys_var *var, +static int check_func_bool(THD *thd, sys_var_pluginvar *var, void *save, st_mysql_value *value) { char buff[STRING_BUFFER_USUAL_SIZE]; @@ -1910,66 +1910,66 @@ err: } -static int check_func_int(THD *thd, struct st_mysql_sys_var *var, +static int check_func_int(THD *thd, sys_var_pluginvar *var, void *save, st_mysql_value *value) { my_bool fixed; long long tmp; struct my_option options; value->val_int(value, &tmp); - plugin_opt_set_limits(&options, var); + plugin_opt_set_limits(&options, var->plugin_var); - if (var->flags & PLUGIN_VAR_UNSIGNED) + if (var->plugin_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); - return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED, + return throw_bounds_warning(thd, fixed, var->plugin_var->flags & PLUGIN_VAR_UNSIGNED, var->name, (longlong) tmp); } -static int check_func_long(THD *thd, struct st_mysql_sys_var *var, +static int check_func_long(THD *thd, sys_var_pluginvar *var, void *save, st_mysql_value *value) { my_bool fixed; long long tmp; struct my_option options; value->val_int(value, &tmp); - plugin_opt_set_limits(&options, var); + plugin_opt_set_limits(&options, var->plugin_var); - if (var->flags & PLUGIN_VAR_UNSIGNED) + if (var->plugin_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); - return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED, + return throw_bounds_warning(thd, fixed, var->plugin_var->flags & PLUGIN_VAR_UNSIGNED, var->name, (longlong) tmp); } <snip>