summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-09-03 20:05:51 +0200
committerSergei Golubchik <serg@mariadb.org>2014-10-10 22:27:42 +0200
commita7b2c95a40101f218d6ed608e8703c2ff761ea47 (patch)
tree7963fc33deb93aa05fe504d3121eea4260c1a639
parentb969a690217f2364cd6c8b55315360223fe1f00b (diff)
downloadmariadb-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
-rw-r--r--mysql-test/r/ctype_cp1250_ch.result2
-rw-r--r--sql/set_var.cc24
-rw-r--r--sql/set_var.h4
-rw-r--r--sql/sql_string.h10
4 files changed, 25 insertions, 15 deletions
diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result
index 063cec289ab..52c2406ae4d 100644
--- a/mysql-test/r/ctype_cp1250_ch.result
+++ b/mysql-test/r/ctype_cp1250_ch.result
@@ -351,7 +351,7 @@ a
DROP TABLE t1;
set global LC_MESSAGES=convert((@@global.log_bin_trust_function_creators)
using cp1250);
-ERROR HY000: Unknown locale: '1'
+ERROR HY000: Unknown locale: 'ON'
#
# Start of 5.6 tests
#
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;
}
diff --git a/sql/set_var.h b/sql/set_var.h
index b495c17867d..580a3378b23 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -206,8 +206,8 @@ private:
protected:
/**
A pointer to a value of the variable for SHOW.
- It must be of show_val_type type (bool for SHOW_BOOL, int for SHOW_INT,
- longlong for SHOW_LONGLONG, etc).
+ It must be of show_val_type type (my_bool for SHOW_MY_BOOL,
+ int for SHOW_INT, longlong for SHOW_LONGLONG, etc).
*/
virtual uchar *session_value_ptr(THD *thd, const LEX_STRING *base);
virtual uchar *global_value_ptr(THD *thd, const LEX_STRING *base);
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 95c82518f9e..0b7e949392d 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -211,10 +211,12 @@ public:
str_charset=cs;
}
bool set_int(longlong num, bool unsigned_flag, CHARSET_INFO *cs);
- bool set(longlong num, CHARSET_INFO *cs)
- { return set_int(num, false, cs); }
- bool set(ulonglong num, CHARSET_INFO *cs)
- { return set_int((longlong)num, true, cs); }
+ bool set(int num, CHARSET_INFO *cs) { return set_int(num, false, cs); }
+ bool set(uint num, CHARSET_INFO *cs) { return set_int(num, true, cs); }
+ bool set(long num, CHARSET_INFO *cs) { return set_int(num, false, cs); }
+ bool set(ulong num, CHARSET_INFO *cs) { return set_int(num, true, cs); }
+ bool set(longlong num, CHARSET_INFO *cs) { return set_int(num, false, cs); }
+ bool set(ulonglong num, CHARSET_INFO *cs) { return set_int((longlong)num, true, cs); }
bool set_real(double num,uint decimals, CHARSET_INFO *cs);
/* Move handling of buffer from some other object to String */