Bug 2701: Function CHARSET() inconsistency

CONVERT3 was removed, it was for test purposes,
and rather harmful.
parent 251bf4ab
......@@ -64,12 +64,6 @@ test
select cast(_koi8r'' as char character set cp1251);
cast(_koi8r'' as char character set cp1251)
select convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci");
convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci")
test
select convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci");
convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci")
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
Table Create Table
......
......@@ -51,6 +51,20 @@ t1 CREATE TABLE `t1` (
`version` char(40) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
charset(charset(_utf8'a')) charset(collation(_utf8'a'))
utf8 utf8
select collation(charset(_utf8'a')), collation(collation(_utf8'a'));
collation(charset(_utf8'a')) collation(collation(_utf8'a'))
utf8_general_ci utf8_general_ci
create table t1 select charset(_utf8'a'), collation(_utf8'a');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`charset(_utf8'a')` char(64) character set utf8 NOT NULL default '',
`collation(_utf8'a')` char(64) character set utf8 NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select TRUE,FALSE,NULL;
TRUE FALSE NULL
1 0 NULL
......@@ -28,8 +28,6 @@ select CAST(DATE "2004-01-22 21:45:33" AS CHAR(4) BINARY);
set names binary;
select cast(_latin1'test' as char character set latin2);
select cast(_koi8r'' as char character set cp1251);
select convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci");
select convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci");
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
drop table t1;
......
......@@ -147,11 +147,6 @@ UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
SET CHARACTER SET koi8r;
SELECT * FROM t1;
#
# codecovarage for Item_func_conv_charset3
#
select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
explain extended select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
UPDATE t1 SET bin_f=koi8_ru_f;
......
......@@ -23,4 +23,10 @@ create table t1 (version char(40)) select database(), user(), version() as 'vers
show create table t1;
drop table t1;
select charset(charset(_utf8'a')), charset(collation(_utf8'a'));
select collation(charset(_utf8'a')), collation(collation(_utf8'a'));
create table t1 select charset(_utf8'a'), collation(_utf8'a');
show create table t1;
drop table t1;
select TRUE,FALSE,NULL;
......@@ -2124,42 +2124,6 @@ void Item_func_conv_charset::print(String *str)
str->append(')');
}
String *Item_func_conv_charset3::val_str(String *str)
{
char cs1[30], cs2[30];
String to_cs_buff(cs1, sizeof(cs1), default_charset_info);
String from_cs_buff(cs2, sizeof(cs2), default_charset_info);
String *arg= args[0]->val_str(str);
String *to_cs= args[1]->val_str(&to_cs_buff);
String *from_cs= args[2]->val_str(&from_cs_buff);
CHARSET_INFO *from_charset;
CHARSET_INFO *to_charset;
if (!arg || args[0]->null_value ||
!to_cs || args[1]->null_value ||
!from_cs || args[2]->null_value ||
!(from_charset=get_charset_by_name(from_cs->ptr(), MYF(MY_WME))) ||
!(to_charset=get_charset_by_name(to_cs->ptr(), MYF(MY_WME))))
{
null_value= 1;
return 0;
}
if (str_value.copy(arg->ptr(), arg->length(), from_charset, to_charset))
{
null_value= 1;
return 0;
}
null_value= 0;
return &str_value;
}
void Item_func_conv_charset3::fix_length_and_dec()
{
max_length = args[0]->max_length;
}
String *Item_func_set_collation::val_str(String *str)
{
str=args[0]->val_str(str);
......@@ -2226,7 +2190,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->csname,strlen(res->charset()->csname),
&my_charset_latin1, default_charset());
&my_charset_latin1, collation.collation);
return str;
}
......@@ -2237,7 +2201,7 @@ String *Item_func_collation::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name),
&my_charset_latin1, default_charset());
&my_charset_latin1, collation.collation);
return str;
}
......
......@@ -619,16 +619,6 @@ public:
void print(String *str) { print_op(str); }
};
class Item_func_conv_charset3 :public Item_str_func
{
public:
Item_func_conv_charset3(Item *arg1,Item *arg2,Item *arg3)
:Item_str_func(arg1,arg2,arg3) {}
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "convert"; }
};
class Item_func_charset :public Item_str_func
{
public:
......@@ -637,8 +627,8 @@ public:
const char *func_name() const { return "charset"; }
void fix_length_and_dec()
{
max_length=40; // should be enough
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
};
};
......@@ -650,8 +640,8 @@ public:
const char *func_name() const { return "collation"; }
void fix_length_and_dec()
{
max_length=40; // should be enough
collation.set(system_charset_info);
max_length= 64 * collation.collation->mbmaxlen; // should be enough
};
};
......
......@@ -2574,8 +2574,6 @@ simple_expr:
}
| CONVERT_SYM '(' expr USING charset_name ')'
{ $$= new Item_func_conv_charset($3,$5); }
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_conv_charset3($3,$7,$5); }
| DEFAULT '(' simple_ident ')'
{ $$= new Item_default_value($3); }
| VALUES '(' simple_ident ')'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment