diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-09-03 20:05:51 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-10-10 22:27:42 +0200 |
commit | a7b2c95a40101f218d6ed608e8703c2ff761ea47 (patch) | |
tree | 7963fc33deb93aa05fe504d3121eea4260c1a639 /sql/set_var.cc | |
parent | b969a690217f2364cd6c8b55315360223fe1f00b (diff) | |
download | mariadb-git-a7b2c95a40101f218d6ed608e8703c2ff761ea47.tar.gz |
bugs in sys_var::val_* code
1. @@boolean_var differs from SHOW VARIABLES
2. @@str_var ignored variable charset (which is wrong
for path variables that use filesystem charset)
3. @@signed_int_var in the string context was printed
as unsigned
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r-- | sql/set_var.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc index bc9d7638ca6..03378f2be73 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -274,9 +274,7 @@ do { \ case SHOW_UINT: do_num_val (uint,CMD); \ case SHOW_ULONG: do_num_val (ulong,CMD); \ case SHOW_ULONGLONG:do_num_val (ulonglong,CMD); \ - case SHOW_HA_ROWS: do_num_val (ha_rows,CMD); \ - case SHOW_BOOL: do_num_val (bool,CMD); \ - case SHOW_MY_BOOL: do_num_val (my_bool,CMD) + case SHOW_HA_ROWS: do_num_val (ha_rows,CMD); #define case_for_double(CMD) \ case SHOW_DOUBLE: do_num_val (double,CMD) @@ -307,6 +305,7 @@ longlong sys_var::val_int(bool *is_null, case_get_string_as_lex_string; case_for_integers(return val); case_for_double(return (longlong) val); + case SHOW_MY_BOOL: return *(my_bool*)value; default: my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str); return 0; @@ -314,7 +313,7 @@ longlong sys_var::val_int(bool *is_null, longlong ret= 0; if (!(*is_null= !sval.str)) - ret= longlong_from_string_with_check(system_charset_info, + ret= longlong_from_string_with_check(charset(thd), sval.str, sval.str + sval.length); return ret; } @@ -322,18 +321,27 @@ longlong sys_var::val_int(bool *is_null, String *sys_var::val_str_nolock(String *str, THD *thd, const uchar *value) { + static LEX_STRING bools[]= + { + { C_STRING_WITH_LEN("OFF") }, + { C_STRING_WITH_LEN("ON") } + }; + LEX_STRING sval; switch (show_type()) { case_get_string_as_lex_string; - case_for_integers(return str->set((ulonglong)val, system_charset_info) ? 0 : str); + case_for_integers(return str->set(val, system_charset_info) ? 0 : str); case_for_double(return str->set_real(val, 6, system_charset_info) ? 0 : str); + case SHOW_MY_BOOL: + sval= bools[(int)*(my_bool*)value]; + break; default: my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str); return 0; } - if (!sval.str || str->copy(sval.str, sval.length, system_charset_info)) + if (!sval.str || str->copy(sval.str, sval.length, charset(thd))) str= NULL; return str; } @@ -361,6 +369,7 @@ double sys_var::val_real(bool *is_null, case_get_string_as_lex_string; case_for_integers(return val); case_for_double(return val); + case SHOW_MY_BOOL: return *(my_bool*)value; default: my_error(ER_VAR_CANT_BE_READ, MYF(0), name.str); return 0; @@ -368,9 +377,8 @@ double sys_var::val_real(bool *is_null, double ret= 0; if (!(*is_null= !sval.str)) - ret= double_from_string_with_check(system_charset_info, + ret= double_from_string_with_check(charset(thd), sval.str, sval.str + sval.length); - mysql_mutex_unlock(&LOCK_global_system_variables); return ret; } |