1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug#12363

character_set_results is nullable, but value_ptr returns string "NULL"

set_var.cc:
  Create Item_null instead of Item_string for NULL values

variables.result, variables.test:
  adding test case
This commit is contained in:
bar@mysql.com
2005-08-30 17:11:59 +05:00
parent d61780999b
commit 3ff1acb8db
3 changed files with 23 additions and 4 deletions

View File

@ -491,3 +491,8 @@ SHOW VARIABLES LIKE 'table_cache';
Variable_name Value Variable_name Value
table_cache 1 table_cache 1
SET GLOBAL table_cache=DEFAULT; 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;

View File

@ -380,4 +380,12 @@ SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache'; SHOW VARIABLES LIKE 'table_cache';
SET GLOBAL table_cache=DEFAULT; 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 # End of 4.1 tests

View File

@ -1598,11 +1598,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); return new Item_int((int32) *(my_bool*) value_ptr(thd, var_type, base),1);
case SHOW_CHAR: case SHOW_CHAR:
{ {
Item_string *tmp; Item *tmp;
pthread_mutex_lock(&LOCK_global_system_variables); pthread_mutex_lock(&LOCK_global_system_variables);
char *str= (char*) value_ptr(thd, var_type, base); char *str= (char*) value_ptr(thd, var_type, base);
if (str)
tmp= new Item_string(str, strlen(str), tmp= new Item_string(str, strlen(str),
system_charset_info, DERIVATION_SYSCONST); 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); pthread_mutex_unlock(&LOCK_global_system_variables);
return tmp; return tmp;
} }
@ -1892,7 +1898,7 @@ byte *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base) LEX_STRING *base)
{ {
CHARSET_INFO *cs= ci_ptr(thd,type)[0]; CHARSET_INFO *cs= ci_ptr(thd,type)[0];
return cs ? (byte*) cs->csname : (byte*) "NULL"; return cs ? (byte*) cs->csname : (byte*) NULL;
} }