diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 4983e0ae3e8..a5b76c03b29 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -513,6 +513,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; create table t1 (a int); select a into @x from t1; Warnings: diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 7ce2cf22db0..372e865467e 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -390,6 +390,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/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 642772bca44..098cd894916 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -412,7 +412,12 @@ sub get_mysqladmin_options $mysqladmin_found= 0 if (!length($mysqladmin)); $com = "$mysqladmin"; $tmp = " -u $opt_user"; - $tmp.= defined($opt_password) ? " -p$opt_password" : ""; + if (defined($opt_password)) { + my $pw= $opt_password; + # Protect single quotes in password + $pw =~ s/'/'"'"'/g; + $tmp.= " -p'$pw'"; + } $tmp.= $opt_tcp_ip ? " -h 127.0.0.1" : ""; for ($j = 0; defined($options[$j]); $j++) { diff --git a/sql/set_var.cc b/sql/set_var.cc index 26912becc81..ea4c08cea27 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1725,11 +1725,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; } @@ -2019,7 +2025,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; }