diff options
-rw-r--r-- | mysql-test/r/plugin.result | 7 | ||||
-rw-r--r-- | mysql-test/t/plugin.test | 3 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 14 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | storage/example/ha_example.cc | 9 |
5 files changed, 27 insertions, 8 deletions
diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result index 53b6a6f1651..4fb4986d0fd 100644 --- a/mysql-test/r/plugin.result +++ b/mysql-test/r/plugin.result @@ -40,15 +40,20 @@ SELECT * FROM t1; a set global example_ulong_var=500; set global example_enum_var= e1; +set session example_int_var= -1; show status like 'example%'; Variable_name Value -example_func_example enum_var is 0, ulong_var is 500, double_var is 8.500000, really +example_func_example enum_var is 0, ulong_var is 500, int_var is -1, double_var is 8.500000, really show variables like 'example%'; Variable_name Value example_double_thdvar 8.500000 example_double_var 8.500000 example_enum_var e1 +example_int_var -1 example_ulong_var 500 +select @@session.example_int_var; +@@session.example_int_var +-1 UNINSTALL SONAME 'ha_example'; Warnings: Warning 1620 Plugin is busy and will be uninstalled on shutdown diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 49f4ae9f1c3..c61a9239218 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -25,9 +25,12 @@ SELECT * FROM t1; # a couple of tests for variables set global example_ulong_var=500; set global example_enum_var= e1; +set session example_int_var= -1; show status like 'example%'; show variables like 'example%'; +select @@session.example_int_var; + UNINSTALL SONAME 'ha_example'; --replace_column 5 # --replace_regex /\.dll/.so/ diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index fa10699ca55..56f335c2359 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3165,15 +3165,21 @@ static void plugin_vars_free_values(sys_var *vars) static SHOW_TYPE pluginvar_show_type(st_mysql_sys_var *plugin_var) { - switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { + switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_UNSIGNED)) { case PLUGIN_VAR_BOOL: return SHOW_MY_BOOL; case PLUGIN_VAR_INT: - return SHOW_INT; + return SHOW_SINT; + case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED: + return SHOW_UINT; case PLUGIN_VAR_LONG: - return SHOW_LONG; + return SHOW_SLONG; + case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED: + return SHOW_ULONG; case PLUGIN_VAR_LONGLONG: - return SHOW_LONGLONG; + return SHOW_SLONGLONG; + case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED: + return SHOW_ULONGLONG; case PLUGIN_VAR_STR: return SHOW_CHAR_PTR; case PLUGIN_VAR_ENUM: diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 91e1693fb94..1890daa4215 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2703,7 +2703,7 @@ static bool show_status_array(THD *thd, const char *wild, end= int10_to_str((long) *(uint*) value, buff, 10); break; case SHOW_SINT: - end= int10_to_str((long) *(uint*) value, buff, -10); + end= int10_to_str((long) *(int*) value, buff, -10); break; case SHOW_SLONG: end= int10_to_str(*(long*) value, buff, -10); diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 74604ea3f56..83c923dc69f 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -1081,6 +1081,9 @@ static MYSQL_SYSVAR_ENUM( 0, // def &enum_var_typelib); // typelib +static MYSQL_THDVAR_INT(int_var, PLUGIN_VAR_RQCMDARG, "-1..1", + NULL, NULL, 0, -1, 1, 0); + static MYSQL_SYSVAR_ULONG( ulong_var, srv_ulong_var, @@ -1119,6 +1122,7 @@ static MYSQL_THDVAR_DOUBLE( static struct st_mysql_sys_var* example_system_variables[]= { MYSQL_SYSVAR(enum_var), MYSQL_SYSVAR(ulong_var), + MYSQL_SYSVAR(int_var), MYSQL_SYSVAR(double_var), MYSQL_SYSVAR(double_thdvar), NULL @@ -1131,9 +1135,10 @@ static int show_func_example(MYSQL_THD thd, struct st_mysql_show_var *var, var->type= SHOW_CHAR; var->value= buf; // it's of SHOW_VAR_FUNC_BUFF_SIZE bytes my_snprintf(buf, SHOW_VAR_FUNC_BUFF_SIZE, - "enum_var is %lu, ulong_var is %lu, " + "enum_var is %lu, ulong_var is %lu, int_var is %d, " "double_var is %f, %.6b", // %b is a MySQL extension - srv_enum_var, srv_ulong_var, srv_double_var, "really"); + srv_enum_var, srv_ulong_var, THDVAR(thd, int_var), + srv_double_var, "really"); return 0; } |