diff options
Diffstat (limited to 'mysql-test/r/cast.result')
-rw-r--r-- | mysql-test/r/cast.result | 156 |
1 files changed, 135 insertions, 21 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index f6f46bd4079..454a3766572 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -4,6 +4,11 @@ CAST(1-2 AS UNSIGNED) select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER); CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER) -1 +select CAST('10 ' as unsigned integer); +CAST('10 ' as unsigned integer) +10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '10 ' select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1 18446744073709551611 18446744073709551611 @@ -39,6 +44,15 @@ cast("1:2:3" as TIME) select CONVERT("2004-01-22 21:45:33",DATE); CONVERT("2004-01-22 21:45:33",DATE) 2004-01-22 +select 10+'10'; +10+'10' +20 +select 10.0+'10'; +10.0+'10' +20 +select 10E+0+'10'; +10E+0+'10' +20 select CONVERT(DATE "2004-01-22 21:45:33" USING latin1); CONVERT(DATE "2004-01-22 21:45:33" USING latin1) 2004-01-22 21:45:33 @@ -48,12 +62,18 @@ CONVERT(DATE "2004-01-22 21:45:33",CHAR) select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)); CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)) 2004 +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33' select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)); CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)) 2004 +Warnings: +Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33' select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)) 2004 +Warnings: +Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33' select CAST(0xb3 as signed); CAST(0xb3 as signed) 179 @@ -66,6 +86,31 @@ CAST(0xffffffffffffffff as unsigned) select CAST(0xfffffffffffffffe as signed); CAST(0xfffffffffffffffe as signed) -2 +select cast('-10a' as signed integer); +cast('-10a' as signed integer) +-10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-10a' +select cast('a10' as unsigned integer); +cast('a10' as unsigned integer) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a10' +select 10+'a'; +10+'a' +10 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +select 10.0+cast('a' as decimal); +10.0+cast('a' as decimal) +10.00 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'a' +select 10E+0+'a'; +10E+0+'a' +10 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' select cast('18446744073709551616' as unsigned); cast('18446744073709551616' as unsigned) 18446744073709551615 @@ -112,7 +157,7 @@ create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `t` char(4) character set cp1251 NOT NULL default '' + `t` varchar(4) character set cp1251 NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select @@ -120,26 +165,37 @@ 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; +hex(cast(_latin1'a' AS char(2))) as c5; c1 c2 c3 c4 c5 -ab a ab a a +ab a ab a 6100 +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'abc' +Warning 1292 Truncated incorrect BINARY(2) value: 'a ' +select cast(1000 as CHAR(3)); +cast(1000 as CHAR(3)) +100 +Warnings: +Warning 1292 Truncated incorrect BINARY(3) value: '1000' 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 +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'abc' +Warning 1292 Truncated incorrect BINARY(2) value: 'a ' +select c1,c2,c3,c4,hex(c5) from t1; +c1 c2 c3 c4 hex(c5) +ab a ab a 6100 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` binary(2) NOT NULL default '', - `c2` binary(2) NOT NULL default '', - `c3` binary(2) NOT NULL default '', - `c4` binary(2) NOT NULL default '', - `c5` binary(2) NOT NULL default '' + `c1` varbinary(2) NOT NULL default '', + `c2` varbinary(2) NOT NULL default '', + `c3` varbinary(2) NOT NULL default '', + `c4` varbinary(2) NOT NULL default '', + `c5` varbinary(2) NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select @@ -150,26 +206,32 @@ cast(_koi8r'Æ ' AS nchar(2)) as c4, cast(_koi8r'Æ' AS nchar(2)) as c5; c1 c2 c3 c4 c5 фг Ñ„ фг Ñ„ Ñ„ +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: 'фгх' +Warning 1292 Truncated incorrect CHAR(3) value: 'Ñ„ ' 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; +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: 'фгх' +Warning 1292 Truncated incorrect CHAR(3) value: 'Ñ„ ' 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 '' + `c1` varchar(2) character set utf8 NOT NULL default '', + `c2` varchar(2) character set utf8 NOT NULL default '', + `c3` varchar(2) character set utf8 NOT NULL default '', + `c4` varchar(2) character set utf8 NOT NULL default '', + `c5` varchar(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); +create table t1 (a binary(4), b char(4) 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) @@ -211,6 +273,10 @@ a CAST(a AS CHAR(3)) aac aac aab aab aaa aaa +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'aaa' +Warning 1292 Truncated incorrect BINARY(2) value: 'aab' +Warning 1292 Truncated incorrect BINARY(2) value: 'aac' SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ; a CAST(a AS UNSIGNED) aaa 3 @@ -221,6 +287,10 @@ a CAST(a AS CHAR(2)) aaa aa aab aa aac aa +Warnings: +Warning 1292 Truncated incorrect BINARY(2) value: 'aaa' +Warning 1292 Truncated incorrect BINARY(2) value: 'aab' +Warning 1292 Truncated incorrect BINARY(2) value: 'aac' DROP TABLE t1; select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour); date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour) @@ -264,9 +334,6 @@ cast(repeat('1',20) as signed) -7335632962598440505 Warnings: Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement -select cast(19999999999999999999 as unsigned); -cast(19999999999999999999 as unsigned) -18446744073709551615 select cast(1.0e+300 as signed int); cast(1.0e+300 as signed int) 9223372036854775807 @@ -277,6 +344,9 @@ SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; double_val cast_val -1e+30 -9223372036854775808 1e+30 9223372036854775807 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-1e+30' +Warning 1292 Truncated incorrect INTEGER value: '1e+30' DROP TABLE t1; select isnull(date(NULL)), isnull(cast(NULL as DATE)); isnull(date(NULL)) isnull(cast(NULL as DATE)) @@ -288,3 +358,47 @@ SELECT CAST(cast('01-01-01' as date) AS SIGNED); CAST(cast('01-01-01' as date) AS SIGNED) 20010101 End of 4.1 tests +select cast('1.2' as decimal(3,2)); +cast('1.2' as decimal(3,2)) +1.20 +select 1e18 * cast('1.2' as decimal(3,2)); +1e18 * cast('1.2' as decimal(3,2)) +1.2e+18 +select cast(cast('1.2' as decimal(3,2)) as signed); +cast(cast('1.2' as decimal(3,2)) as signed) +1 +set @v1=1e18; +select cast(@v1 as decimal(22, 2)); +cast(@v1 as decimal(22, 2)) +1000000000000000000.00 +select cast(-1e18 as decimal(22,2)); +cast(-1e18 as decimal(22,2)) +-1000000000000000000.00 +create table t1(s1 time); +insert into t1 values ('11:11:11'); +select cast(s1 as decimal(7,2)) from t1; +cast(s1 as decimal(7,2)) +111111.00 +drop table t1; +CREATE TABLE t1 (v varchar(10), tt tinytext, t text, +mt mediumtext, lt longtext); +INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05'); +SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL), +CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1; +CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS DECIMAL) +1.01 2.02 3.03 4.04 5.05 +DROP TABLE t1; +select cast(NULL as decimal(6)) as t1; +t1 +NULL +set names latin1; +select hex(cast('a' as char(2) binary)); +hex(cast('a' as char(2) binary)) +61 +select hex(cast('a' as binary(2))); +hex(cast('a' as binary(2))) +6100 +select hex(cast('a' as char(2) binary)); +hex(cast('a' as char(2) binary)) +61 +End of 5.0 tests |