2002-11-24 14:47:19 +01:00
|
|
|
|
select CAST(1-2 AS UNSIGNED);
|
|
|
|
|
CAST(1-2 AS UNSIGNED)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
|
|
|
|
|
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
|
|
|
|
|
-1
|
2005-04-01 14:04:50 +02:00
|
|
|
|
select CAST('10 ' as unsigned integer);
|
|
|
|
|
CAST('10 ' as unsigned integer)
|
|
|
|
|
10
|
2005-04-30 17:40:08 +02:00
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: '10 '
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
|
|
|
|
|
cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1
|
|
|
|
|
18446744073709551611 18446744073709551611
|
|
|
|
|
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
|
|
|
|
|
cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
|
|
|
|
|
18446744073709551610 18446744073709551612
|
|
|
|
|
select ~5, cast(~5 as signed);
|
|
|
|
|
~5 cast(~5 as signed)
|
|
|
|
|
18446744073709551610 -6
|
2003-10-30 11:57:26 +01:00
|
|
|
|
explain extended select ~5, cast(~5 as signed);
|
2006-07-28 19:27:01 +02:00
|
|
|
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
|
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
2003-10-30 11:57:26 +01:00
|
|
|
|
Warnings:
|
2004-05-13 22:47:20 +02:00
|
|
|
|
Note 1003 select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast(5 as unsigned) -6.0;
|
|
|
|
|
cast(5 as unsigned) -6.0
|
|
|
|
|
-1.0
|
2004-02-09 12:31:03 +01:00
|
|
|
|
select cast(NULL as signed), cast(1/0 as signed);
|
|
|
|
|
cast(NULL as signed) cast(1/0 as signed)
|
|
|
|
|
NULL NULL
|
|
|
|
|
select cast(NULL as unsigned), cast(1/0 as unsigned);
|
|
|
|
|
cast(NULL as unsigned) cast(1/0 as unsigned)
|
|
|
|
|
NULL NULL
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
|
|
|
|
|
cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
|
|
|
|
|
0 1
|
|
|
|
|
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
|
|
|
|
|
cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
|
2002-12-11 08:17:51 +01:00
|
|
|
|
2001-01-01 2001-01-01 00:00:00
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast("1:2:3" as TIME);
|
|
|
|
|
cast("1:2:3" as TIME)
|
2002-12-14 16:43:01 +01:00
|
|
|
|
01:02:03
|
2004-01-22 21:13:24 +01:00
|
|
|
|
select CONVERT("2004-01-22 21:45:33",DATE);
|
|
|
|
|
CONVERT("2004-01-22 21:45:33",DATE)
|
|
|
|
|
2004-01-22
|
2005-04-01 14:04:50 +02:00
|
|
|
|
select 10+'10';
|
|
|
|
|
10+'10'
|
|
|
|
|
20
|
|
|
|
|
select 10.0+'10';
|
|
|
|
|
10.0+'10'
|
|
|
|
|
20
|
|
|
|
|
select 10E+0+'10';
|
|
|
|
|
10E+0+'10'
|
|
|
|
|
20
|
2004-02-09 12:31:03 +01:00
|
|
|
|
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
|
|
|
|
|
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
|
|
|
|
|
CONVERT(DATE "2004-01-22 21:45:33",CHAR)
|
|
|
|
|
2004-01-22 21:45:33
|
|
|
|
|
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
|
|
|
|
|
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
|
|
|
|
|
2004
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
|
2004-03-26 13:11:46 +01:00
|
|
|
|
select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
|
|
|
|
|
CONVERT(DATE "2004-01-22 21:45:33",BINARY(4))
|
2004-02-09 12:31:03 +01:00
|
|
|
|
2004
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
|
2004-03-26 13:11:46 +01:00
|
|
|
|
select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
|
|
|
|
|
CAST(DATE "2004-01-22 21:45:33" AS BINARY(4))
|
2004-02-09 12:31:03 +01:00
|
|
|
|
2004
|
2005-09-28 13:29:13 +02:00
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
|
2005-09-25 20:22:23 +02:00
|
|
|
|
select CAST(0xb3 as signed);
|
|
|
|
|
CAST(0xb3 as signed)
|
|
|
|
|
179
|
|
|
|
|
select CAST(0x8fffffffffffffff as signed);
|
|
|
|
|
CAST(0x8fffffffffffffff as signed)
|
|
|
|
|
-8070450532247928833
|
|
|
|
|
select CAST(0xffffffffffffffff as unsigned);
|
|
|
|
|
CAST(0xffffffffffffffff as unsigned)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
select CAST(0xfffffffffffffffe as signed);
|
|
|
|
|
CAST(0xfffffffffffffffe as signed)
|
|
|
|
|
-2
|
2005-04-01 14:04:50 +02:00
|
|
|
|
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)
|
2006-08-08 13:03:42 +02:00
|
|
|
|
10.0
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
2005-04-08 06:23:10 +02:00
|
|
|
|
Warning 1292 Truncated incorrect DECIMAL value: 'a'
|
2005-04-01 14:04:50 +02:00
|
|
|
|
select 10E+0+'a';
|
|
|
|
|
10E+0+'a'
|
|
|
|
|
10
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect DOUBLE value: 'a'
|
2005-04-29 16:03:34 +02:00
|
|
|
|
select cast('18446744073709551616' as unsigned);
|
|
|
|
|
cast('18446744073709551616' as unsigned)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616'
|
|
|
|
|
select cast('18446744073709551616' as signed);
|
|
|
|
|
cast('18446744073709551616' as signed)
|
|
|
|
|
-1
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: '18446744073709551616'
|
|
|
|
|
select cast('9223372036854775809' as signed);
|
|
|
|
|
cast('9223372036854775809' as signed)
|
|
|
|
|
-9223372036854775807
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
|
|
|
|
select cast('-1' as unsigned);
|
|
|
|
|
cast('-1' as unsigned)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1105 Cast to unsigned converted negative integer to it's positive complement
|
|
|
|
|
select cast('abc' as signed);
|
|
|
|
|
cast('abc' as signed)
|
|
|
|
|
0
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: 'abc'
|
|
|
|
|
select cast('1a' as signed);
|
|
|
|
|
cast('1a' as signed)
|
|
|
|
|
1
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: '1a'
|
|
|
|
|
select cast('' as signed);
|
|
|
|
|
cast('' as signed)
|
|
|
|
|
0
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: ''
|
2003-05-30 20:09:35 +02:00
|
|
|
|
set names binary;
|
2003-05-28 14:57:58 +02:00
|
|
|
|
select cast(_latin1'test' as char character set latin2);
|
|
|
|
|
cast(_latin1'test' as char character set latin2)
|
|
|
|
|
test
|
|
|
|
|
select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251);
|
|
|
|
|
cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
create table t1 select cast(_koi8r'<27><><EFBFBD><EFBFBD>' as char character set cp1251) as t;
|
|
|
|
|
show create table t1;
|
|
|
|
|
Table Create Table
|
|
|
|
|
t1 CREATE TABLE `t1` (
|
2006-02-22 10:09:59 +01:00
|
|
|
|
`t` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT ''
|
2003-12-10 05:31:42 +01:00
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2003-05-28 14:57:58 +02:00
|
|
|
|
drop table t1;
|
2003-08-21 11:15:25 +02:00
|
|
|
|
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,
|
2005-11-21 16:59:58 +01:00
|
|
|
|
hex(cast(_latin1'a' AS char(2))) as c5;
|
2003-08-21 11:15:25 +02:00
|
|
|
|
c1 c2 c3 c4 c5
|
2005-11-21 16:59:58 +01:00
|
|
|
|
ab a ab a 6100
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'abc'
|
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'a '
|
2005-04-01 14:04:50 +02:00
|
|
|
|
select cast(1000 as CHAR(3));
|
|
|
|
|
cast(1000 as CHAR(3))
|
|
|
|
|
100
|
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(3) value: '1000'
|
2003-08-21 11:15:25 +02:00
|
|
|
|
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;
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'abc'
|
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'a '
|
2005-11-21 16:59:58 +01:00
|
|
|
|
select c1,c2,c3,c4,hex(c5) from t1;
|
|
|
|
|
c1 c2 c3 c4 hex(c5)
|
|
|
|
|
ab a ab a 6100
|
2003-08-21 11:15:25 +02:00
|
|
|
|
show create table t1;
|
|
|
|
|
Table Create Table
|
|
|
|
|
t1 CREATE TABLE `t1` (
|
2006-02-22 10:09:59 +01:00
|
|
|
|
`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 ''
|
2003-12-10 05:31:42 +01:00
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2003-08-21 11:15:25 +02:00
|
|
|
|
drop table t1;
|
|
|
|
|
select
|
|
|
|
|
cast(_koi8r'<27><>' AS nchar) as c1,
|
|
|
|
|
cast(_koi8r'<27> ' AS nchar) as c2,
|
|
|
|
|
cast(_koi8r'<27><><EFBFBD>' AS nchar(2)) as c3,
|
|
|
|
|
cast(_koi8r'<27> ' AS nchar(2)) as c4,
|
|
|
|
|
cast(_koi8r'<27>' AS nchar(2)) as c5;
|
|
|
|
|
c1 c2 c3 c4 c5
|
|
|
|
|
фг ф фг ф ф
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect CHAR(4) value: 'фгх'
|
|
|
|
|
Warning 1292 Truncated incorrect CHAR(3) value: 'ф '
|
2003-08-21 11:15:25 +02:00
|
|
|
|
create table t1 select
|
|
|
|
|
cast(_koi8r'<27><>' AS nchar) as c1,
|
|
|
|
|
cast(_koi8r'<27> ' AS nchar) as c2,
|
|
|
|
|
cast(_koi8r'<27><><EFBFBD>' AS nchar(2)) as c3,
|
|
|
|
|
cast(_koi8r'<27> ' AS nchar(2)) as c4,
|
|
|
|
|
cast(_koi8r'<27>' AS nchar(2)) as c5;
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect CHAR(4) value: 'фгх'
|
|
|
|
|
Warning 1292 Truncated incorrect CHAR(3) value: 'ф '
|
2003-08-21 11:15:25 +02:00
|
|
|
|
select * from t1;
|
|
|
|
|
c1 c2 c3 c4 c5
|
2004-12-07 14:47:00 +01:00
|
|
|
|
фг ф фг ф ф
|
2003-08-21 11:15:25 +02:00
|
|
|
|
show create table t1;
|
|
|
|
|
Table Create Table
|
|
|
|
|
t1 CREATE TABLE `t1` (
|
2006-02-22 10:09:59 +01:00
|
|
|
|
`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 ''
|
2003-12-10 05:31:42 +01:00
|
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2003-08-21 11:15:25 +02:00
|
|
|
|
drop table t1;
|
2005-10-13 16:16:19 +02:00
|
|
|
|
create table t1 (a binary(4), b char(4) character set koi8r);
|
2003-12-25 14:42:17 +01:00
|
|
|
|
insert into t1 values (_binary'<27><><EFBFBD><EFBFBD>',_binary'<27><><EFBFBD><EFBFBD>');
|
|
|
|
|
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)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
|
|
|
|
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)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
|
|
|
|
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)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>
|
|
|
|
|
drop table t1;
|
|
|
|
|
set names binary;
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast("2001-1-1" as date) = "2001-01-01";
|
|
|
|
|
cast("2001-1-1" as date) = "2001-01-01"
|
2003-07-08 12:06:05 +02:00
|
|
|
|
1
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
|
|
|
|
|
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
|
2003-07-08 12:06:05 +02:00
|
|
|
|
1
|
2002-11-24 14:47:19 +01:00
|
|
|
|
select cast("1:2:3" as TIME) = "1:02:03";
|
|
|
|
|
cast("1:2:3" as TIME) = "1:02:03"
|
wl#173 - temporal types with sub-second resolution
and collateral changes.
* introduce my_hrtime_t, my_timediff_t, and conversion macros
* inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(),
never from Item::result_type()
* pack_time/unpack_time function for "packed" representation of
MYSQL_TIME in a longlong that can be compared
* ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
* numbers aren't quoted in EXPLAIN EXTENDED
* new column I_S.COLUMNS.DATETIME_PRECISION
* date/time values are compares to anything as date/time, not as strings or numbers.
* old timestamp(X) is no longer supported
* MYSQL_TIME to string conversion functions take precision as an argument
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* Lazy_string class to pass a value (string, number, time) polymorphically down the stack
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
* introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* in many cases date/time types are treated like other types, not as special cases
* greatly simplified Arg_comparator (regarding date/time/year code)
* SEC_TO_TIME is real function, not integer.
* microsecond precision in NOW, CURTIME, etc
* Item_temporal. All items derived from it only provide get_date, but no val* methods
* replication of NOW(6)
* Protocol::store(time) now takes the precision as an argument
* @@TIMESTAMP is a double
client/mysqlbinlog.cc:
remove unneded casts
include/my_sys.h:
introduce my_hrtime_t, my_timediff_t, and conversion macros
include/my_time.h:
pack_time/unpack_time, etc.
convenience functions to work with MYSQL_TIME::second_part
libmysql/libmysql.c:
str_to_time() is gone. str_to_datetime() does it now.
my_TIME_to_str() takes the precision as an argument
mysql-test/include/ps_conv.inc:
time is not equal to datetime anymore
mysql-test/r/distinct.result:
a test for an old MySQL bug
mysql-test/r/explain.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_default.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_sapdb.result:
when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/func_test.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_time.result:
ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
mysql-test/r/having.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/information_schema.result:
new column I_S.COLUMNS.DATETIME_PRECISION
mysql-test/r/join_outer.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/metadata.result:
TIMESTAMP no longer has zerofill flag
mysql-test/r/range.result:
invalid datetime is not compared with as a string
mysql-test/r/select.result:
NO_ZERO_IN_DATE, etc only affect storage - according to the manual
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/subselect.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/sysdate_is_now.result:
when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/type_blob.result:
TIMESTAMP(N) is not deprecated
mysql-test/r/type_timestamp.result:
old TIMESTAMP(X) semantics is not supported anymore
mysql-test/r/union.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/varbinary.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/t/distinct.test:
test for an old MySQL bug
mysql-test/t/func_time.test:
+- INTERVAL now works with TIME values
mysql-test/t/select.test:
typo
mysql-test/t/subselect.test:
only one error per statement, please
mysql-test/t/system_mysql_db_fix40123.test:
old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50030.test:
old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50117.test:
old timestamp(X) is no longer supported
mysql-test/t/type_blob.test:
old timestamp(X) is no longer supported
mysql-test/t/type_timestamp.test:
old timestamp(X) is no longer supported
mysys/my_getsystime.c:
functions to get the time with microsecond precision
mysys/my_init.c:
move the my_getsystime.c initialization code to my_getsystime.c
mysys/my_static.c:
no need to make these variables extern
mysys/my_static.h:
no need to make these variables extern
scripts/mysql_system_tables.sql:
old timestamp(X) is no longer supported
scripts/mysql_system_tables_fix.sql:
old timestamp(X) is no longer supported
scripts/mysqlhotcopy.sh:
old timestamp(X) is no longer supported
sql-common/my_time.c:
* call str_to_time from str_to_datetime, as appropriate
* date/time to string conversions take precision as an argument
* number_to_time()
* TIME_to_double()
* pack_time() and unpack_time()
sql/event_data_objects.cc:
cast is not needed
my_datetime_to_str() takes precision as an argument
sql/event_db_repository.cc:
avoid dangerous downcast (because the pointer is
not always Field_timestamp, see events_1.test)
sql/event_queue.cc:
avoid silly double-work for cond_wait
(having an endpoint of wait, subtract the current time to get the timeout,
and use set_timespec() macro to fill in struct timespec, by adding the current
time to the timeout)
sql/field.cc:
* remove virtual Field::get_time(), everyone should use only Field::get_date()
* remove lots of #ifdef WORDS_BIGENDIAN
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
sql/field.h:
* remove virtual Field::get_time(), everyone should use only Field::get_date()
* remove lots of #ifdef WORDS_BIGENDIAN
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
sql/filesort.cc:
TIME_RESULT, cmp_time()
sql/item.cc:
* numbers aren't quoted in EXPLAIN EXTENDED
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* virtual Item::get_time() is gone
* Item_param::field_type() is set correctly
* Item_datetime, for a datetime constant
* time to anything is compared as a time
* Item_cache::print() prints the value is available
* bug fixed in Item_cache_int::val_str()
sql/item.h:
* Item::print_value(), to be used from Item_xxx::print() when needed
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* virtual Item::get_time() is gone
* Item_datetime, for a datetime constant
* better default for cast_to_int_type()
* Item_cache objects now *always* have the field_type() set
sql/item_cmpfunc.cc:
* get_year_value, get_time_value are gone. get_datetime_value does it all
* get_value_a_func, get_value_b_func are gone
* can_compare_as_dates() is gone too, TIME_RESULT is used instead
* cmp_type() instead or result_type() when doing a comparison
* compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
sql/item_cmpfunc.h:
greatly simplified Arg_comparator
sql/item_create.cc:
* fix a bug in error messages in CAST
sql/item_func.cc:
Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
mention all possibitiles in switch over Item_result values, or use default:
sql/item_row.h:
overwrite the default cmp_type() for Item_row,
as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT
sql/item_timefunc.cc:
rewrite make_datetime to support precision argument
SEC_TO_TIME is real function, not integer.
many functions that returned temporal values had duplicate code in val_* methods,
some of them did not have get_date() which resulted in unnecessary date->str->date conversions.
Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
many fixes to set decimals (datetime precision) correctly.
sql/item_timefunc.h:
SEC_TO_TIME is real function, not integer.
many functions that returned temporal values had duplicate code in val_* methods,
some of them did not have get_date() which resulted in unnecessary date->str->date conversions.
Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
many fixes to set decimals (datetime precision) correctly.
sql/log_event.cc:
replication of NOW(6)
sql/log_event.h:
replication of NOW(6)
sql/mysql_priv.h:
Lazy_string class to pass a value (string, number, time) polymorphically down the stack.
make_truncated_value_warning() that uses it.
sql/mysqld.cc:
datetime in Arg_comparator::comparator_matrix
sql/opt_range.cc:
cleanup: don't disable warnings before calling save_in_field_no_warnings()
sql/protocol.cc:
Protocol::store(time) now takes the precision as an argument
sql/protocol.h:
Protocol::store(time) now takes the precision as an argument
sql/rpl_rli.cc:
small cleanup
sql/set_var.cc:
SET TIMESTAMP=double
sql/set_var.h:
@@TIMESTAMP is a double
sql/share/errmsg.txt:
precision and scale are unsigned
sql/slave.cc:
replication of NOW(6)
sql/sp_head.cc:
cleanup
sql/sql_class.cc:
support for NOW(6)
sql/sql_class.h:
support for NOW(6)
sql/sql_insert.cc:
support for NOW(6)
sql/sql_select.cc:
use item->cmp_type().
move a comment where it belongs
sql/sql_show.cc:
new column I_S.COLUMNS.DATETIME_PRECISION
sql/sql_yacc.yy:
TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc
sql/time.cc:
fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument
storage/myisam/ha_myisam.cc:
TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible.
strings/my_vsnprintf.c:
warnings
tests/mysql_client_test.c:
old timestamp(X) does not work anymore
datetime is no longer equal to time
2011-03-01 13:24:36 +01:00
|
|
|
|
1
|
2003-03-27 15:11:01 +01:00
|
|
|
|
select cast(NULL as DATE);
|
|
|
|
|
cast(NULL as DATE)
|
|
|
|
|
NULL
|
2003-03-28 15:57:03 +01:00
|
|
|
|
select cast(NULL as BINARY);
|
|
|
|
|
cast(NULL as BINARY)
|
|
|
|
|
NULL
|
2004-09-07 12:42:19 +02:00
|
|
|
|
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
|
|
|
|
|
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
|
|
|
|
|
SELECT a, CAST(a AS CHAR) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
|
|
|
|
|
a CAST(a AS CHAR)
|
|
|
|
|
aac aac
|
|
|
|
|
aab aab
|
|
|
|
|
aaa aaa
|
|
|
|
|
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
|
|
|
|
|
a CAST(a AS CHAR(3))
|
|
|
|
|
aac aac
|
|
|
|
|
aab aab
|
|
|
|
|
aaa aaa
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'aaa'
|
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'aab'
|
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'aac'
|
2004-09-07 12:42:19 +02:00
|
|
|
|
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
|
|
|
|
|
a CAST(a AS UNSIGNED)
|
|
|
|
|
aaa 3
|
|
|
|
|
aab 2
|
|
|
|
|
aac 1
|
|
|
|
|
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
|
|
|
|
|
a CAST(a AS CHAR(2))
|
|
|
|
|
aaa aa
|
|
|
|
|
aab aa
|
|
|
|
|
aac aa
|
2005-04-01 14:04:50 +02:00
|
|
|
|
Warnings:
|
2005-11-21 18:11:28 +01:00
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'aaa'
|
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'aab'
|
|
|
|
|
Warning 1292 Truncated incorrect BINARY(2) value: 'aac'
|
2004-09-07 12:42:19 +02:00
|
|
|
|
DROP TABLE t1;
|
2004-12-30 11:39:01 +01:00
|
|
|
|
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)
|
|
|
|
|
2004-12-30 00:00:00
|
|
|
|
|
select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
|
|
|
|
|
timediff(cast('2004-12-30 12:00:00' as time), '12:00:00')
|
|
|
|
|
00:00:00
|
|
|
|
|
select timediff(cast('1 12:00:00' as time), '12:00:00');
|
|
|
|
|
timediff(cast('1 12:00:00' as time), '12:00:00')
|
|
|
|
|
24:00:00
|
2005-04-29 16:03:34 +02:00
|
|
|
|
select cast(18446744073709551615 as unsigned);
|
|
|
|
|
cast(18446744073709551615 as unsigned)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
select cast(18446744073709551615 as signed);
|
|
|
|
|
cast(18446744073709551615 as signed)
|
|
|
|
|
-1
|
|
|
|
|
select cast('18446744073709551615' as unsigned);
|
|
|
|
|
cast('18446744073709551615' as unsigned)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
select cast('18446744073709551615' as signed);
|
|
|
|
|
cast('18446744073709551615' as signed)
|
|
|
|
|
-1
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
|
|
|
|
select cast('9223372036854775807' as signed);
|
|
|
|
|
cast('9223372036854775807' as signed)
|
|
|
|
|
9223372036854775807
|
|
|
|
|
select cast(concat('184467440','73709551615') as unsigned);
|
|
|
|
|
cast(concat('184467440','73709551615') as unsigned)
|
|
|
|
|
18446744073709551615
|
|
|
|
|
select cast(concat('184467440','73709551615') as signed);
|
|
|
|
|
cast(concat('184467440','73709551615') as signed)
|
|
|
|
|
-1
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
|
|
|
|
select cast(repeat('1',20) as unsigned);
|
|
|
|
|
cast(repeat('1',20) as unsigned)
|
|
|
|
|
11111111111111111111
|
|
|
|
|
select cast(repeat('1',20) as signed);
|
|
|
|
|
cast(repeat('1',20) as signed)
|
|
|
|
|
-7335632962598440505
|
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
|
2005-10-13 18:28:44 +02:00
|
|
|
|
select cast(1.0e+300 as signed int);
|
|
|
|
|
cast(1.0e+300 as signed int)
|
|
|
|
|
9223372036854775807
|
2006-03-28 15:21:19 +02:00
|
|
|
|
CREATE TABLE t1 (f1 double);
|
|
|
|
|
INSERT INTO t1 SET f1 = -1.0e+30 ;
|
|
|
|
|
INSERT INTO t1 SET f1 = +1.0e+30 ;
|
|
|
|
|
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
|
2006-03-29 16:31:16 +02:00
|
|
|
|
Warnings:
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: '-1e+30'
|
|
|
|
|
Warning 1292 Truncated incorrect INTEGER value: '1e+30'
|
2006-03-28 15:21:19 +02:00
|
|
|
|
DROP TABLE t1;
|
2006-12-04 14:06:25 +01:00
|
|
|
|
select isnull(date(NULL)), isnull(cast(NULL as DATE));
|
|
|
|
|
isnull(date(NULL)) isnull(cast(NULL as DATE))
|
|
|
|
|
1 1
|
2007-05-03 22:53:37 +02:00
|
|
|
|
SELECT CAST(cast('01-01-01' as date) AS UNSIGNED);
|
|
|
|
|
CAST(cast('01-01-01' as date) AS UNSIGNED)
|
|
|
|
|
20010101
|
|
|
|
|
SELECT CAST(cast('01-01-01' as date) AS SIGNED);
|
|
|
|
|
CAST(cast('01-01-01' as date) AS SIGNED)
|
|
|
|
|
20010101
|
2006-12-04 14:06:25 +01:00
|
|
|
|
End of 4.1 tests
|
2005-02-21 16:20:05 +01:00
|
|
|
|
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
|
2005-03-07 17:53:51 +01: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))
|
2006-08-08 13:03:42 +02:00
|
|
|
|
99999.99
|
|
|
|
|
Warnings:
|
|
|
|
|
Error 1264 Out of range value for column 'cast(s1 as decimal(7,2))' at row 1
|
2005-03-07 17:53:51 +01:00
|
|
|
|
drop table t1;
|
2005-06-15 17:27:33 +02:00
|
|
|
|
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)
|
2006-08-08 13:03:42 +02:00
|
|
|
|
1 2 3 4 5
|
2005-06-15 17:27:33 +02:00
|
|
|
|
DROP TABLE t1;
|
2005-06-15 16:02:35 +02:00
|
|
|
|
select cast(NULL as decimal(6)) as t1;
|
|
|
|
|
t1
|
|
|
|
|
NULL
|
2006-07-12 22:22:38 +02:00
|
|
|
|
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
|
2007-07-19 22:06:35 +02:00
|
|
|
|
CREATE TABLE t1 (d1 datetime);
|
|
|
|
|
INSERT INTO t1(d1) VALUES ('2007-07-19 08:30:00'), (NULL),
|
|
|
|
|
('2007-07-19 08:34:00'), (NULL), ('2007-07-19 08:36:00');
|
|
|
|
|
SELECT cast(date(d1) as signed) FROM t1;
|
|
|
|
|
cast(date(d1) as signed)
|
|
|
|
|
20070719
|
|
|
|
|
NULL
|
|
|
|
|
20070719
|
|
|
|
|
NULL
|
|
|
|
|
20070719
|
|
|
|
|
drop table t1;
|
2007-11-08 06:08:44 +01:00
|
|
|
|
CREATE TABLE t1 (f1 DATE);
|
|
|
|
|
INSERT INTO t1 VALUES ('2007-07-19'), (NULL);
|
|
|
|
|
SELECT HOUR(f1),
|
|
|
|
|
MINUTE(f1),
|
|
|
|
|
SECOND(f1) FROM t1;
|
|
|
|
|
HOUR(f1) MINUTE(f1) SECOND(f1)
|
|
|
|
|
0 0 0
|
|
|
|
|
NULL NULL NULL
|
|
|
|
|
SELECT HOUR(CAST('2007-07-19' AS DATE)),
|
|
|
|
|
MINUTE(CAST('2007-07-19' AS DATE)),
|
|
|
|
|
SECOND(CAST('2007-07-19' AS DATE));
|
|
|
|
|
HOUR(CAST('2007-07-19' AS DATE)) MINUTE(CAST('2007-07-19' AS DATE)) SECOND(CAST('2007-07-19' AS DATE))
|
|
|
|
|
0 0 0
|
|
|
|
|
SELECT HOUR(CAST(NULL AS DATE)),
|
|
|
|
|
MINUTE(CAST(NULL AS DATE)),
|
|
|
|
|
SECOND(CAST(NULL AS DATE));
|
|
|
|
|
HOUR(CAST(NULL AS DATE)) MINUTE(CAST(NULL AS DATE)) SECOND(CAST(NULL AS DATE))
|
|
|
|
|
NULL NULL NULL
|
|
|
|
|
SELECT HOUR(NULL),
|
|
|
|
|
MINUTE(NULL),
|
|
|
|
|
SECOND(NULL);
|
|
|
|
|
HOUR(NULL) MINUTE(NULL) SECOND(NULL)
|
|
|
|
|
NULL NULL NULL
|
|
|
|
|
DROP TABLE t1;
|
2006-07-12 22:22:38 +02:00
|
|
|
|
End of 5.0 tests
|
2009-05-21 10:06:43 +02:00
|
|
|
|
#
|
|
|
|
|
# Bug #44766: valgrind error when using convert() in a subquery
|
|
|
|
|
#
|
|
|
|
|
CREATE TABLE t1(a tinyint);
|
|
|
|
|
INSERT INTO t1 VALUES (127);
|
|
|
|
|
SELECT 1 FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1
|
|
|
|
|
) AS s LIMIT 1;
|
|
|
|
|
1
|
|
|
|
|
1
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
End of 5.1 tests
|