Commit 00a163d4 authored by unknown's avatar unknown

Fix for bug #8935 CAST(time AS DECIMAL) crashes

mysql-test/r/cast.result:
  test result
mysql-test/r/func_group.result:
  test result
mysql-test/t/cast.test:
  test case
sql/field.cc:
  this assert isn't correct actually
parent 01c3fb8e
...@@ -203,3 +203,9 @@ cast(@v1 as decimal(22, 2)) ...@@ -203,3 +203,9 @@ cast(@v1 as decimal(22, 2))
select cast(-1e18 as decimal(22,2)); select cast(-1e18 as decimal(22,2));
cast(-1e18 as decimal(22,2)) cast(-1e18 as decimal(22,2))
-1000000000000000000.00 -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;
...@@ -855,7 +855,6 @@ select col1,sum(col1),max(col1),min(col1) from t1 group by col1; ...@@ -855,7 +855,6 @@ select col1,sum(col1),max(col1),min(col1) from t1 group by col1;
col1 sum(col1) max(col1) min(col1) col1 sum(col1) max(col1) min(col1)
5.000000000010 10.000000000020 5.000000000010 5.000000000010 5.000000000010 10.000000000020 5.000000000010 5.000000000010
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1( CREATE TABLE t1(
id int PRIMARY KEY, id int PRIMARY KEY,
a int, a int,
......
...@@ -126,3 +126,8 @@ select cast(cast('1.2' as decimal(3,2)) as signed); ...@@ -126,3 +126,8 @@ select cast(cast('1.2' as decimal(3,2)) as signed);
set @v1=1e18; set @v1=1e18;
select cast(@v1 as decimal(22, 2)); select cast(@v1 as decimal(22, 2));
select cast(-1e18 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;
...@@ -626,7 +626,6 @@ int Field_str::store_decimal(const my_decimal *d) ...@@ -626,7 +626,6 @@ int Field_str::store_decimal(const my_decimal *d)
my_decimal *Field_str::val_decimal(my_decimal *decimal_value) my_decimal *Field_str::val_decimal(my_decimal *decimal_value)
{ {
DBUG_ASSERT(result_type() == INT_RESULT);
longlong nr= val_int(); longlong nr= val_int();
int2my_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value); int2my_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value);
return decimal_value; return decimal_value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment