summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhf@deer.(none) <>2005-03-07 20:53:51 +0400
committerhf@deer.(none) <>2005-03-07 20:53:51 +0400
commitfbbb58c6aeaab9ac5983f5fc57204e0e74b5b954 (patch)
tree93b78a95b8ba743ba7f9069cfb83219382d5cfc3
parente5a2d037437cc92966b2d593bc7a9bef1d3c7e94 (diff)
downloadmariadb-git-fbbb58c6aeaab9ac5983f5fc57204e0e74b5b954.tar.gz
Fix for bug #8935 CAST(time AS DECIMAL) crashes
-rw-r--r--mysql-test/r/cast.result6
-rw-r--r--mysql-test/r/func_group.result1
-rw-r--r--mysql-test/t/cast.test5
-rw-r--r--sql/field.cc1
4 files changed, 11 insertions, 2 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index 57821699f68..b015648534b 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -203,3 +203,9 @@ cast(@v1 as decimal(22, 2))
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;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 34ecb2906d2..46dba6cdfa9 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -855,7 +855,6 @@ select col1,sum(col1),max(col1),min(col1) from t1 group by col1;
col1 sum(col1) max(col1) min(col1)
5.000000000010 10.000000000020 5.000000000010 5.000000000010
DROP TABLE t1;
-
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 5866431e687..94d9590dd5f 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -126,3 +126,8 @@ 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;
diff --git a/sql/field.cc b/sql/field.cc
index 1538edc59a3..fd4d83a8b1c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -626,7 +626,6 @@ int Field_str::store_decimal(const my_decimal *d)
my_decimal *Field_str::val_decimal(my_decimal *decimal_value)
{
- DBUG_ASSERT(result_type() == INT_RESULT);
longlong nr= val_int();
int2my_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value);
return decimal_value;