From: Date: January 27 2008 12:36am Subject: bk commit into 5.1 tree (acurtis:1.2661) BUG#32902 List-Archive: http://lists.mysql.com/commits/41285 X-Bug: 32902 Message-Id: <200801262336.m0QNaex4027825@mail.mysql.com> Below is the list of changes that have just been committed into a local 5.1 repository of acurtis. When acurtis 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, 2008-01-26 15:36:22-08:00, acurtis@stripped +4 -0 Bug#32902 "plugin variables don't know their names" Implemented new plugin support function thd_plugin_var_name() to return the logical name of the plugin variable. include/mysql/plugin.h@stripped, 2008-01-26 15:36:07-08:00, acurtis@stripped +3 -0 bug32902 new function: thd_plugin_var_name() mysql-test/r/plugin.result@stripped, 2008-01-26 15:36:07-08:00, acurtis@stripped +1 -1 changed error text due to fixing bug32902 sql/set_var.cc@stripped, 2008-01-26 15:36:07-08:00, acurtis@stripped +18 -0 bug32902 new internal function: intern_find_sys_var() sql/sql_plugin.cc@stripped, 2008-01-26 15:36:07-08:00, acurtis@stripped +26 -3 bug32902 new static function: check_is_plugin_var() new function: thd_plugin_var_name() diff -Nrup a/include/mysql/plugin.h b/include/mysql/plugin.h --- a/include/mysql/plugin.h 2007-08-30 23:19:49 -07:00 +++ b/include/mysql/plugin.h 2008-01-26 15:36:07 -08:00 @@ -672,6 +672,9 @@ struct st_mysql_value extern "C" { #endif +const char *thd_plugin_var_name(MYSQL_THD thd, + struct st_mysql_sys_var *plugin_var); + int thd_in_lock_tables(const MYSQL_THD thd); int thd_tablespace_op(const MYSQL_THD thd); long long thd_test_options(const MYSQL_THD thd, long long test_options); diff -Nrup a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result --- a/mysql-test/r/plugin.result 2007-11-14 01:48:18 -08:00 +++ b/mysql-test/r/plugin.result 2008-01-26 15:36:07 -08:00 @@ -25,5 +25,5 @@ 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 'impossible' UNINSTALL PLUGIN example; diff -Nrup a/sql/set_var.cc b/sql/set_var.cc --- a/sql/set_var.cc 2008-01-10 09:44:20 -08:00 +++ b/sql/set_var.cc 2008-01-26 15:36:07 -08:00 @@ -3105,6 +3105,24 @@ sys_var *intern_find_sys_var(const char } +sys_var *intern_find_sys_var(bool (*func)(sys_var *, void*), void *data) +{ + uint index; + + /* + This function is only called from the sql_plugin.cc. + A lock on LOCK_system_variable_hash should be held + */ + for (index= 0; index < system_variable_hash.records; index++) + { + sys_var *var= (sys_var*) hash_element(&system_variable_hash, index); + if (func(var, data)) + return var; + } + return 0; +} + + /* Execute update of all variables diff -Nrup a/sql/sql_plugin.cc b/sql/sql_plugin.cc --- a/sql/sql_plugin.cc 2008-01-26 02:13:31 -08:00 +++ b/sql/sql_plugin.cc 2008-01-26 15:36:07 -08:00 @@ -210,6 +210,7 @@ static void reap_plugins(void); /* declared in set_var.cc */ extern sys_var *intern_find_sys_var(const char *str, uint length, bool no_error); +extern sys_var *intern_find_sys_var(bool (*func)(sys_var *, void*), void *data); #ifdef EMBEDDED_LIBRARY /* declared in sql_base.cc */ @@ -1853,6 +1854,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, void *save, st_mysql_value *value) { @@ -1887,7 +1889,8 @@ static int check_func_bool(THD *thd, str *(int*)save= -result; return 0; err: - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), + thd_plugin_var_name(thd, var), strvalue); return 1; } @@ -2032,7 +2035,8 @@ static int check_func_enum(THD *thd, str *(long*)save= result; return 0; err: - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), + thd_plugin_var_name(thd, var), strvalue); return 1; } @@ -2082,7 +2086,8 @@ static int check_func_set(THD *thd, stru *(ulonglong*)save= result; return 0; err: - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), + thd_plugin_var_name(thd, var), strvalue); return 1; } @@ -2131,6 +2136,24 @@ static void update_func_str(THD *thd, st /**************************************************************************** System Variables support ****************************************************************************/ + +static bool check_is_plugin_var(sys_var *var_arg, void *arg) +{ + sys_var_pluginvar *var= var_arg->cast_pluginvar(); + return var && ((void*) var->plugin_var == arg); +} + + +extern "C" +const char *thd_plugin_var_name(MYSQL_THD thd, + struct st_mysql_sys_var *plugin_var) +{ + rw_rdlock(&LOCK_system_variables_hash); + sys_var *var= intern_find_sys_var(check_is_plugin_var, plugin_var); + const char *name= thd->strdup(var ? var->name : plugin_var->name); + rw_unlock(&LOCK_system_variables_hash); + return name; +} sys_var *find_sys_var(THD *thd, const char *str, uint length)