|
| 1 | +select cast('' as signed); |
| 2 | +cast('' as signed) |
| 3 | +0 |
| 4 | +Level Code Message |
| 5 | +Warning 1292 Truncated incorrect INTEGER value: '' |
| 6 | +select cast('12345abcde' as signed); |
| 7 | +cast('12345abcde' as signed) |
| 8 | +12345 |
| 9 | +Level Code Message |
| 10 | +Warning 1292 Truncated incorrect INTEGER value: '12345abcde' |
| 11 | +select cast('123e456' as signed); |
| 12 | +cast('123e456' as signed) |
| 13 | +123 |
| 14 | +Level Code Message |
| 15 | +Warning 1292 Truncated incorrect INTEGER value: '123e456' |
| 16 | +select cast('-12345abcde' as signed); |
| 17 | +cast('-12345abcde' as signed) |
| 18 | +-12345 |
| 19 | +Level Code Message |
| 20 | +Warning 1292 Truncated incorrect INTEGER value: '-12345abcde' |
| 21 | +select cast('-123e456' as signed); |
| 22 | +cast('-123e456' as signed) |
| 23 | +-123 |
| 24 | +Level Code Message |
| 25 | +Warning 1292 Truncated incorrect INTEGER value: '-123e456' |
| 26 | +select coercibility(binary('a')); |
| 27 | +coercibility(binary('a')) |
| 28 | +2 |
| 29 | +select coercibility(cast('a' as char(10))); |
| 30 | +coercibility(cast('a' as char(10))) |
| 31 | +2 |
| 32 | +select coercibility(convert('abc', char(10))); |
| 33 | +coercibility(convert('abc', char(10))) |
| 34 | +2 |
| 35 | +drop table if exists t; |
| 36 | +create table t(d1 double, f float, d2 decimal(24,8)); |
| 37 | +insert into t values(0, 0, 0); |
| 38 | +select cast(111.1 as datetime) from t; |
| 39 | +cast(111.1 as datetime) |
| 40 | +2000-01-11 00:00:00 |
| 41 | +select cast(1311.1 as datetime) from t; |
| 42 | +cast(1311.1 as datetime) |
| 43 | +NULL |
| 44 | +insert into t values(111.1, 1122.1, 31212.111); |
| 45 | +insert into t values(121212.1111, 1121212.111111, 11121212.111111); |
| 46 | +insert into t values(99991111.1111111, 101.1111111, 20121212121212.1111111); |
| 47 | +insert into t values(NULL, NULL, NULL); |
| 48 | +insert into t values(1.1, 48.1, 100.1); |
| 49 | +insert into t values(1301.11, 1131.111, 100001111.111); |
| 50 | +insert into t values(20121212121260.1111111, 20121212126012.1111111, 20121212241212.1111111); |
| 51 | +select cast(d1 as datetime), cast(f as datetime), cast(d2 as datetime) from t; |
| 52 | +cast(d1 as datetime) cast(f as datetime) cast(d2 as datetime) |
| 53 | +NULL NULL NULL |
| 54 | +NULL NULL NULL |
| 55 | +NULL NULL NULL |
| 56 | +NULL NULL NULL |
| 57 | +0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 |
| 58 | +2000-01-11 00:00:00 2000-11-22 00:00:00 2003-12-12 00:00:00 |
| 59 | +2012-12-12 00:00:00 0112-12-12 00:00:00 1112-12-12 00:00:00 |
| 60 | +9999-11-11 00:00:00 2000-01-01 00:00:00 2012-12-12 12:12:12 |
| 61 | +drop table if exists t; |
| 62 | +create table t (col1 bigint, col2 double, col3 decimal, col4 varchar(20), col5 json); |
| 63 | +insert into t values (1, 1, 1, "1", "1"); |
| 64 | +insert into t values (null, null, null, null, null); |
| 65 | +select cast(col1 as time), cast(col2 as time), cast(col3 as time), cast(col4 as time), cast(col5 as time) from t where col1 = 1; |
| 66 | +cast(col1 as time) cast(col2 as time) cast(col3 as time) cast(col4 as time) cast(col5 as time) |
| 67 | +00:00:01 00:00:01 00:00:01 00:00:01 NULL |
| 68 | +select cast(col1 as time), cast(col2 as time), cast(col3 as time), cast(col4 as time), cast(col5 as time) from t where col1 is null; |
| 69 | +cast(col1 as time) cast(col2 as time) cast(col3 as time) cast(col4 as time) cast(col5 as time) |
| 70 | +NULL NULL NULL NULL NULL |
| 71 | +select cast(col1 as time(31)) from t where col1 is null; |
| 72 | +Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6. |
| 73 | +select cast(col2 as time(31)) from t where col1 is null; |
| 74 | +Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6. |
| 75 | +select cast(col3 as time(31)) from t where col1 is null; |
| 76 | +Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6. |
| 77 | +select cast(col4 as time(31)) from t where col1 is null; |
| 78 | +Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6. |
| 79 | +select cast(col5 as time(31)) from t where col1 is null; |
| 80 | +Error 1426 (42000): Too big precision 31 specified for column 'CAST'. Maximum is 6. |
| 81 | +drop table if exists t; |
| 82 | +create table t(a varchar(50)); |
| 83 | +insert into t values ('2020-01-01 12:00:00.123456 +0600 PST'); |
| 84 | +insert into t values ('2020-01-01 12:00:00.123456 -0600 PST'); |
| 85 | +insert into t values ('2020-01-01 12:00:00.123456'); |
| 86 | +select cast(a as datetime(3)) from t; |
| 87 | +cast(a as datetime(3)) |
| 88 | +2020-01-01 12:00:00.123 |
| 89 | +2020-01-01 12:00:00.123 |
| 90 | +2020-01-01 12:00:00.123 |
| 91 | +drop table if exists t1; |
| 92 | +create table t1 (c1 text); |
| 93 | +insert into t1 values ('a'); |
| 94 | +update t1 set c1 = cast('61qw' as decimal); |
| 95 | +Error 1292 (22007): Truncated incorrect DECIMAL value: '61qw' |
| 96 | +select cast('61qw' as decimal); |
| 97 | +cast('61qw' as decimal) |
| 98 | +61 |
| 99 | +Level Code Message |
| 100 | +Warning 1292 Truncated incorrect DECIMAL value: '61qw' |
| 101 | +drop table if exists t; |
| 102 | +create table t (y year); |
| 103 | +insert into t values (cast('14:15' as time)); |
| 104 | +select 1 from t where y = YEAR(CURDATE()); |
| 105 | +1 |
| 106 | +1 |
| 107 | +select cast(cast('14:15' as time) as year) = YEAR(CURDATE()); |
| 108 | +cast(cast('14:15' as time) as year) = YEAR(CURDATE()) |
| 109 | +1 |
| 110 | +explain select null as a union all select 'a' as a; |
| 111 | +id estRows task access object operator info |
| 112 | +Union_8 2.00 root |
| 113 | +├─Projection_10 1.00 root <nil>->Column#3 |
| 114 | +│ └─TableDual_11 1.00 root rows:1 |
| 115 | +└─Projection_12 1.00 root a->Column#3 |
| 116 | + └─TableDual_13 1.00 root rows:1 |
| 117 | +select null as a union all select 'a' as a; |
| 118 | +a |
| 119 | +NULL |
| 120 | +a |
| 121 | +drop table if exists t0; |
| 122 | +create table t0(c0 tinyint(1) unsigned not null ); |
| 123 | +insert into t0 values (1); |
| 124 | +select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end; |
| 125 | +c0 |
| 126 | +1 |
| 127 | +select t0.c0 > -1.194192591e9 from t0; |
| 128 | +t0.c0 > -1.194192591e9 |
| 129 | +1 |
| 130 | +select t0.c0 < -1.194192591e9 from t0; |
| 131 | +t0.c0 < -1.194192591e9 |
| 132 | +0 |
| 133 | +select -1.194192591e9 > t0.c0 from t0; |
| 134 | +-1.194192591e9 > t0.c0 |
| 135 | +0 |
| 136 | +select -1.194192591e9 < t0.c0 from t0; |
| 137 | +-1.194192591e9 < t0.c0 |
| 138 | +1 |
| 139 | +select t0.c0 > 1.194192591e9 from t0; |
| 140 | +t0.c0 > 1.194192591e9 |
| 141 | +0 |
| 142 | +select t0.c0 < 1.194192591e9 from t0; |
| 143 | +t0.c0 < 1.194192591e9 |
| 144 | +1 |
| 145 | +select 1.194192591e9 > t0.c0 from t0; |
| 146 | +1.194192591e9 > t0.c0 |
| 147 | +1 |
| 148 | +select 1.194192591e9 < t0.c0 from t0; |
| 149 | +1.194192591e9 < t0.c0 |
| 150 | +0 |
0 commit comments