From 34e882dd79663c428199a76ba8fcfe6d704592af Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 14:15:25 +0500 Subject: CAST(expr AS CHAR(10)) is now working --- mysql-test/r/cast.result | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ mysql-test/t/cast.test | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 5d185bee005..d604a17d270 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -42,6 +42,60 @@ t1 CREATE TABLE `t1` ( `t` char(4) character set cp1251 NOT NULL default '' ) TYPE=MyISAM CHARSET=latin1 drop table t1; +select +cast(_latin1'ab' AS char) as c1, +cast(_latin1'a ' AS char) as c2, +cast(_latin1'abc' AS char(2)) as c3, +cast(_latin1'a ' AS char(2)) as c4, +cast(_latin1'a' AS char(2)) as c5; +c1 c2 c3 c4 c5 +ab a ab a a +create table t1 select +cast(_latin1'ab' AS char) as c1, +cast(_latin1'a ' AS char) as c2, +cast(_latin1'abc' AS char(2)) as c3, +cast(_latin1'a ' AS char(2)) as c4, +cast(_latin1'a' AS char(2)) as c5; +select * from t1; +c1 c2 c3 c4 c5 +ab a ab a a +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` char(2) binary NOT NULL default '', + `c2` char(2) binary NOT NULL default '', + `c3` char(2) binary NOT NULL default '', + `c4` char(2) binary NOT NULL default '', + `c5` char(2) binary NOT NULL default '' +) TYPE=MyISAM CHARSET=latin1 +drop table t1; +select +cast(_koi8r'ÆÇ' AS nchar) as c1, +cast(_koi8r'Æ ' AS nchar) as c2, +cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3, +cast(_koi8r'Æ ' AS nchar(2)) as c4, +cast(_koi8r'Æ' AS nchar(2)) as c5; +c1 c2 c3 c4 c5 +фг Ñ„ фг Ñ„ Ñ„ +create table t1 select +cast(_koi8r'ÆÇ' AS nchar) as c1, +cast(_koi8r'Æ ' AS nchar) as c2, +cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3, +cast(_koi8r'Æ ' AS nchar(2)) as c4, +cast(_koi8r'Æ' AS nchar(2)) as c5; +select * from t1; +c1 c2 c3 c4 c5 +фг Ñ„ фг Ñ„ Ñ„ +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` char(2) character set utf8 NOT NULL default '', + `c2` char(2) character set utf8 NOT NULL default '', + `c3` char(2) character set utf8 NOT NULL default '', + `c4` char(2) character set utf8 NOT NULL default '', + `c5` char(2) character set utf8 NOT NULL default '' +) TYPE=MyISAM CHARSET=latin1 +drop table t1; select cast("2001-1-1" as date) = "2001-01-01"; cast("2001-1-1" as date) = "2001-01-01" 1 diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 8241d491465..b3ae8981671 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -23,6 +23,47 @@ create table t1 select cast(_koi8r' show create table t1; drop table t1; +# +# CAST to CHAR with/without length +# +select + cast(_latin1'ab' AS char) as c1, + cast(_latin1'a ' AS char) as c2, + cast(_latin1'abc' AS char(2)) as c3, + cast(_latin1'a ' AS char(2)) as c4, + cast(_latin1'a' AS char(2)) as c5; + +create table t1 select + cast(_latin1'ab' AS char) as c1, + cast(_latin1'a ' AS char) as c2, + cast(_latin1'abc' AS char(2)) as c3, + cast(_latin1'a ' AS char(2)) as c4, + cast(_latin1'a' AS char(2)) as c5; +select * from t1; +show create table t1; +drop table t1; + +# +# CAST to NCHAR with/without length +# +select + cast(_koi8r'ÆÇ' AS nchar) as c1, + cast(_koi8r'Æ ' AS nchar) as c2, + cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3, + cast(_koi8r'Æ ' AS nchar(2)) as c4, + cast(_koi8r'Æ' AS nchar(2)) as c5; + +create table t1 select + cast(_koi8r'ÆÇ' AS nchar) as c1, + cast(_koi8r'Æ ' AS nchar) as c2, + cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3, + cast(_koi8r'Æ ' AS nchar(2)) as c4, + cast(_koi8r'Æ' AS nchar(2)) as c5; +select * from t1; +show create table t1; +drop table t1; + + # # The following should be fixed in 4.1 # -- cgit v1.2.1