Bug 2202: CAST from binary to char still returns a binary string
This commit is contained in:
parent
229cc61277
commit
8fac0f4d27
@ -101,6 +101,21 @@ t1 CREATE TABLE `t1` (
|
||||
`c5` char(2) character set utf8 NOT NULL default ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a binary(10), b char(10) character set koi8r);
|
||||
insert into t1 values (_binary'ÔÅÓÔ',_binary'ÔÅÓÔ');
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
ÔÅÓÔ ÔÅÓÔ ÔÅÓÔ ÔÅÓÔ
|
||||
set names koi8r;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
ÔÅÓÔ ÔÅÓÔ æåõæ ÔÅÓÔ
|
||||
set names cp1251;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
a b cast(a as char character set cp1251) cast(b as binary)
|
||||
ÔÅÓÔ òåñò ÔÅÓÔ ÔÅÓÔ
|
||||
drop table t1;
|
||||
set names binary;
|
||||
select cast("2001-1-1" as date) = "2001-01-01";
|
||||
cast("2001-1-1" as date) = "2001-01-01"
|
||||
1
|
||||
|
@ -64,6 +64,19 @@ select * from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug 2202
|
||||
# CAST from BINARY to non-BINARY and from non-BINARY to BINARY
|
||||
#
|
||||
create table t1 (a binary(10), b char(10) character set koi8r);
|
||||
insert into t1 values (_binary'ÔÅÓÔ',_binary'ÔÅÓÔ');
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
set names koi8r;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
set names cp1251;
|
||||
select a,b,cast(a as char character set cp1251),cast(b as binary) from t1;
|
||||
drop table t1;
|
||||
set names binary;
|
||||
|
||||
#
|
||||
# The following should be fixed in 4.1
|
||||
|
@ -1848,6 +1848,8 @@ String *Item_char_typecast::val_str(String *str)
|
||||
}
|
||||
res= str;
|
||||
}
|
||||
|
||||
res->set_charset(cast_cs);
|
||||
|
||||
/*
|
||||
Cut the tail if cast with length
|
||||
|
@ -235,7 +235,7 @@ bool String::copy(const char *str, uint32 arg_length,
|
||||
{
|
||||
if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
|
||||
{
|
||||
return copy(str, arg_length, &my_charset_bin);
|
||||
return copy(str, arg_length, to_cs);
|
||||
}
|
||||
uint32 new_length= to_cs->mbmaxlen*arg_length;
|
||||
if (alloc(new_length))
|
||||
|
Loading…
x
Reference in New Issue
Block a user