mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Bug #31253: crash comparing datetime to double
convert(<invalid time>, datetime) in WHERE caused crash as function returned (void*)NULL, but did not flag SQL NULL. It does now. mysql-test/r/type_datetime.result: show that convert() to datetime in a WHERE-clause will no longer crash the server on invalid input. mysql-test/t/type_datetime.test: show that convert() to datetime in a WHERE-clause will no longer crash the server on invalid input. sql/item.cc: When failing to process time values, do not just return (void*)NULL, but flag SQL NULL as well so no caller will try to process the 0x0L. This makes behaviour for Item::Item::val_decimal_from_date() and Item::Item::val_decimal_from_time() identical.
This commit is contained in:
parent
ba0cd51eb1
commit
2e8ca84e89
3 changed files with 20 additions and 0 deletions
|
@ -427,3 +427,12 @@ 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 Truncated incorrect datetime value: '0000-00-00 45:44:44'
|
||||
drop table t1;
|
||||
|
|
|
@ -282,3 +282,13 @@ select * from t1 where f1 between 20020101 and 20070101000000;
|
|||
select * from t1 where f1 between 2002010 and 20070101000000;
|
||||
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;
|
||||
|
|
|
@ -274,6 +274,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);
|
||||
|
|
Loading…
Reference in a new issue