summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/variables.result5
-rw-r--r--mysql-test/t/variables.test8
-rw-r--r--sql/set_var.cc14
3 files changed, 23 insertions, 4 deletions
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index efcc3d21144..67c78d82a24 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -491,6 +491,11 @@ SHOW VARIABLES LIKE 'table_cache';
Variable_name Value
table_cache 1
SET GLOBAL table_cache=DEFAULT;
+set character_set_results=NULL;
+select ifnull(@@character_set_results,"really null");
+ifnull(@@character_set_results,"really null")
+really null
+set names latin1;
select @@have_innodb;
@@have_innodb
#
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index f888541f17a..a8844070207 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -380,6 +380,14 @@ SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache';
SET GLOBAL table_cache=DEFAULT;
+#
+# Bugs12363: character_set_results is nullable,
+# but value_ptr returns string "NULL"
+#
+set character_set_results=NULL;
+select ifnull(@@character_set_results,"really null");
+set names latin1;
+
# End of 4.1 tests
#
diff --git a/sql/set_var.cc b/sql/set_var.cc
index c0186880a59..94968f664fd 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1602,11 +1602,17 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
return new Item_int((int32) *(my_bool*) value_ptr(thd, var_type, base),1);
case SHOW_CHAR:
{
- Item_string *tmp;
+ Item *tmp;
pthread_mutex_lock(&LOCK_global_system_variables);
char *str= (char*) value_ptr(thd, var_type, base);
- tmp= new Item_string(str, strlen(str),
- system_charset_info, DERIVATION_SYSCONST);
+ if (str)
+ tmp= new Item_string(str, strlen(str),
+ system_charset_info, DERIVATION_SYSCONST);
+ else
+ {
+ tmp= new Item_null();
+ tmp->collation.set(system_charset_info, DERIVATION_SYSCONST);
+ }
pthread_mutex_unlock(&LOCK_global_system_variables);
return tmp;
}
@@ -1896,7 +1902,7 @@ byte *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
- return cs ? (byte*) cs->csname : (byte*) "NULL";
+ return cs ? (byte*) cs->csname : (byte*) NULL;
}