diff options
-rw-r--r-- | mysql-test/r/type_datetime.result | 9 | ||||
-rw-r--r-- | mysql-test/t/type_datetime.test | 10 | ||||
-rw-r--r-- | sql/item.cc | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index ffe4bac142d..2a5d306cb23 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -427,6 +427,15 @@ f1 Warnings: Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 drop table t1; +create table t1 (f1 time); +insert into t1 set f1 = '45:44:44'; +insert into t1 set f1 = '15:44:44'; +select * from t1 where (convert(f1,datetime)) != 1; +f1 +15:44:44 +Warnings: +Warning 1292 Incorrect datetime value: '0000-00-00 45:44:44' +drop table t1; set @org_mode=@@sql_mode; create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03'); Warnings: diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index d8d137d81e6..b02fc1a9af0 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -284,6 +284,16 @@ select * from t1 where f1 between 20020101 and 2007010100000; drop table t1; # +# Bug #31253: crash comparing datetime to double +# Should return 1st row only. Crashes if NULL propagation fails. +# +create table t1 (f1 time); +insert into t1 set f1 = '45:44:44'; +insert into t1 set f1 = '15:44:44'; +select * from t1 where (convert(f1,datetime)) != 1; +drop table t1; + +# # Test of storing datetime into date fields # diff --git a/sql/item.cc b/sql/item.cc index d8080d62c39..dc94615c6e6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -272,6 +272,7 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) if (get_date(<ime, TIME_FUZZY_DATE)) { my_decimal_set_zero(decimal_value); + null_value= 1; // set NULL, stop processing return 0; } return date2my_decimal(<ime, decimal_value); |