mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-30 04:26:45 +03:00 
			
		
		
		
	into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge BitKeeper/etc/ignore: auto-union BitKeeper/deleted/.del-im_options_set.result~59278f56be61d921: Auto merged BitKeeper/deleted/.del-mysqld.dsp~ffdbf2d234e23e56: Auto merged BitKeeper/deleted/.del-mysys.dsp~32695fee91189326: Auto merged BitKeeper/deleted/.del-im_options_set.imtest~b53d9d60e5684833: Auto merged BitKeeper/deleted/.del-im_options_unset.imtest~768eb186b51d0048: Auto merged BitKeeper/deleted/.del-im_options_unset.result~20a4790cd3c70a4f: Auto merged client/mysql.cc: Auto merged client/mysqlbinlog.cc: Auto merged client/mysqlcheck.c: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged dbug/dbug.c: Auto merged extra/perror.c: Auto merged extra/yassl/src/yassl_imp.cpp: Auto merged extra/yassl/src/yassl_int.cpp: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged libmysql/libmysql.c: Auto merged mysql-test/r/cast.result: Auto merged mysql-test/r/date_formats.result: Auto merged mysql-test/r/federated.result: Auto merged mysql-test/r/func_compress.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/gis-rtree.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/im_daemon_life_cycle.result: Auto merged mysql-test/r/im_utils.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/mysqlcheck.result: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/r/rpl_trigger.result: Auto merged mysql-test/r/sp-code.result: Auto merged mysql-test/r/sp-security.result: Auto merged mysql-test/r/strict.result: Auto merged mysql-test/r/type_blob.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/r/type_ranges.result: Auto merged mysql-test/r/udf.result: Auto merged mysql-test/r/user_var.result: Auto merged mysql-test/t/cast.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/func_group.test: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/im_daemon_life_cycle.imtest: Auto merged mysql-test/t/im_life_cycle.imtest: Auto merged mysql-test/t/im_utils.imtest: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/mysqlcheck.test: Auto merged mysql-test/t/ps.test: Auto merged mysql-test/t/rpl_trigger.test: Auto merged mysql-test/t/sp-security.test: Auto merged mysql-test/t/strict.test: Auto merged mysql-test/t/udf.test: Auto merged sql/field.cc: Auto merged sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/slave.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_udf.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged sql-common/my_time.c: Auto merged sql/table.h: Auto merged storage/ndb/src/kernel/error/ndbd_exit_codes.c: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged mysql-test/r/im_life_cycle.result: e use local mysql-test/r/ps.result: use local client/Makefile.am: Manual merge. client/mysqlimport.c: Manual merge. configure.in: Manual merge. mysql-test/mysql-test-run.pl: Manual merge. mysql-test/r/mysqldump.result: Manual merge. mysql-test/r/mysqltest.result: Manual merge. mysql-test/r/ndb_basic.result: Manual merge. mysql-test/r/rpl_view.result: Manual merge. mysql-test/r/show_check.result: Manual merge. mysql-test/r/sp-error.result: Manual merge. mysql-test/r/sp.result: Manual merge. mysql-test/r/union.result: Manual merge. mysql-test/t/mysqldump.test: Manual merge. mysql-test/t/mysqltest.test: Manual merge. mysql-test/t/ndb_basic.test: Manual merge. mysql-test/t/rpl_sp.test: Manual merge. mysql-test/t/rpl_view.test: Manual merge. mysql-test/t/show_check.test: Manual merge. mysql-test/t/sp-error.test: Manual merge. mysql-test/t/sp.test: Manual merge. sql/item_sum.cc: Manual merge. sql/mysql_priv.h: Manual merge. sql/sp_head.cc: Manual merge. sql/sql_db.cc: Manual merge. sql/sql_delete.cc: Manual merge. sql/sql_lex.h: Manual merge. sql/sql_show.cc: Manual merge. sql/sql_table.cc: Manual merge. sql/sql_trigger.cc: Manual merge. sql/sql_yacc.yy: Manual merge. tests/mysql_client_test.c: Manual merge.
		
			
				
	
	
		
			223 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			223 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| #
 | |
| # Test of cast function
 | |
| #
 | |
| 
 | |
| select CAST(1-2 AS UNSIGNED);
 | |
| select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
 | |
| select CAST('10 ' as unsigned integer);
 | |
| select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
 | |
| select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
 | |
| select ~5, cast(~5 as signed);
 | |
| explain extended select ~5, cast(~5 as signed);
 | |
| select cast(5 as unsigned) -6.0;
 | |
| select cast(NULL as signed), cast(1/0 as signed); 
 | |
| select cast(NULL as unsigned), cast(1/0 as unsigned); 
 | |
| select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
 | |
| select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
 | |
| select cast("1:2:3" as TIME);
 | |
| select CONVERT("2004-01-22 21:45:33",DATE);
 | |
| select 10+'10';
 | |
| select 10.0+'10';
 | |
| select 10E+0+'10';
 | |
| 
 | |
| # The following cast creates warnings
 | |
| 
 | |
| select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
 | |
| select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
 | |
| select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
 | |
| select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
 | |
| select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
 | |
| select CAST(0xb3 as signed);
 | |
| select CAST(0x8fffffffffffffff as signed);
 | |
| select CAST(0xffffffffffffffff as unsigned);
 | |
| select CAST(0xfffffffffffffffe as signed);
 | |
| select cast('-10a' as signed integer);
 | |
| select cast('a10' as unsigned integer);
 | |
| select 10+'a';
 | |
| select 10.0+cast('a' as decimal);
 | |
| select 10E+0+'a';
 | |
| 
 | |
| # out-of-range cases
 | |
| select cast('18446744073709551616' as unsigned);
 | |
| select cast('18446744073709551616' as signed);
 | |
| select cast('9223372036854775809' as signed);
 | |
| select cast('-1' as unsigned);
 | |
| select cast('abc' as signed);
 | |
| select cast('1a' as signed);
 | |
| select cast('' as signed);
 | |
| 
 | |
| #
 | |
| # Character set conversion
 | |
| #
 | |
| set names binary;
 | |
| select cast(_latin1'test' as char character set latin2);
 | |
| select cast(_koi8r'ÔÅÓÔ' as char character set cp1251);
 | |
| create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t;
 | |
| 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,
 | |
|   hex(cast(_latin1'a'   AS char(2))) as c5;
 | |
| select cast(1000 as CHAR(3));
 | |
| 
 | |
| 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 c1,c2,c3,c4,hex(c5) 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;
 | |
| 
 | |
| #
 | |
| # Bug 2202
 | |
| # CAST from BINARY to non-BINARY and from non-BINARY to BINARY
 | |
| #
 | |
| 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;
 | |
| 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
 | |
| #
 | |
| 
 | |
| select cast("2001-1-1" as date) = "2001-01-01";
 | |
| select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
 | |
| select cast("1:2:3" as TIME) = "1:02:03";
 | |
| select cast(NULL as DATE);
 | |
| select cast(NULL as BINARY);
 | |
| 
 | |
| #
 | |
| # Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions
 | |
| #
 | |
| CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
 | |
| INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
 | |
| # these two should be in enum order
 | |
| SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
 | |
| SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
 | |
| # these two should be in alphabetic order
 | |
| SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
 | |
| SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
 | |
| DROP TABLE t1;
 | |
| 
 | |
| #
 | |
| # Test for bug #6914 "Problems using time()/date() output in expressions".
 | |
| # When we are casting datetime value to DATE/TIME we should throw away
 | |
| # time/date parts (correspondingly).
 | |
| #
 | |
| select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
 | |
| select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
 | |
| # Still we should not throw away "days" part of time value
 | |
| select timediff(cast('1 12:00:00' as time), '12:00:00');
 | |
| 
 | |
| #
 | |
| # Bug #7036: Casting from string to unsigned would cap value of result at
 | |
| # maximum signed value instead of maximum unsigned value
 | |
| #
 | |
| select cast(18446744073709551615 as unsigned);
 | |
| select cast(18446744073709551615 as signed);
 | |
| select cast('18446744073709551615' as unsigned);
 | |
| select cast('18446744073709551615' as signed);
 | |
| select cast('9223372036854775807' as signed);
 | |
| 
 | |
| select cast(concat('184467440','73709551615') as unsigned);
 | |
| select cast(concat('184467440','73709551615') as signed);
 | |
| 
 | |
| select cast(repeat('1',20) as unsigned);
 | |
| select cast(repeat('1',20) as signed);
 | |
| 
 | |
| #
 | |
| # Bug #13344: cast of large decimal to signed int not handled correctly
 | |
| #
 | |
| select cast(1.0e+300 as signed int);
 | |
| 
 | |
| #
 | |
| # Bugs: #15098: CAST(column double TO signed int), wrong result
 | |
| #
 | |
| CREATE TABLE t1 (f1 double);
 | |
| INSERT INTO t1 SET f1 = -1.0e+30 ;
 | |
| INSERT INTO t1 SET f1 = +1.0e+30 ;
 | |
| # Expected result is +-1e+30, but Windows returns +-1e+030.
 | |
| --replace_result 1e+030 1e+30
 | |
| SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
 | |
| DROP TABLE t1;					   
 | |
| 
 | |
| # End of 4.1 tests
 | |
| 
 | |
| 
 | |
| #decimal-related additions
 | |
| select cast('1.2' as decimal(3,2));
 | |
| select 1e18 * cast('1.2' as decimal(3,2));
 | |
| select cast(cast('1.2' as decimal(3,2)) as signed);
 | |
| set @v1=1e18;
 | |
| select cast(@v1 as decimal(22, 2));
 | |
| select cast(-1e18 as decimal(22,2));
 | |
| 
 | |
| create table t1(s1 time);
 | |
| insert into t1 values ('11:11:11');
 | |
| select cast(s1 as decimal(7,2)) from t1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Test for bug #11283: field conversion from varchar, and text types to decimal
 | |
| #
 | |
| 
 | |
| 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;
 | |
| 
 | |
| DROP TABLE t1;
 | |
| 
 | |
| #
 | |
| # Bug #10237 (CAST(NULL DECIMAL) crashes server)
 | |
| #
 | |
| select cast(NULL as decimal(6)) as t1;
 | |
| 
 | |
| 
 | |
| #
 | |
| # Bug #17903: cast to char results in binary
 | |
| #
 | |
| set names latin1;
 | |
| select hex(cast('a' as char(2) binary));
 | |
| select hex(cast('a' as binary(2)));
 | |
| select hex(cast('a' as char(2) binary));
 | |
| 
 | |
| --echo End of 5.0 tests
 |