Commit dc72037a authored by Sergei Golubchik's avatar Sergei Golubchik

followup for lp:730637

mysql-test/t/func_time.test:
  fixed wrong test case
sql-common/my_time.c:
  negative datetime is invalid.
  fix check_date() to reflect that.
parent 5c8cbba3
...@@ -1430,18 +1430,14 @@ NULL ...@@ -1430,18 +1430,14 @@ NULL
select cast(str_to_date(NULL, '%H:%i:%s') as time); select cast(str_to_date(NULL, '%H:%i:%s') as time);
cast(str_to_date(NULL, '%H:%i:%s') as time) cast(str_to_date(NULL, '%H:%i:%s') as time)
NULL NULL
create table t1 (a timestamp,key(a)); create table t1 (f1 datetime, key (f1));
insert t1 values ('2010-01-01 02:03:04'); insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49');
insert t1 select a + interval 1 day from t1; select * from t1 where f1 > time('-23:00:06');
insert t1 select a + interval 2 day from t1; f1
insert t1 select a + interval 4 day from t1; 2000-09-12 00:00:00
insert t1 select a + interval 8 day from t1; 2007-04-25 05:08:49
insert t1 select a + interval 16 day from t1;
explain select * from t1 where a > cast('2010-10-00 01:02:03' as datetime);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index a a 4 NULL 32 Using where; Using index
Warnings: Warnings:
Warning 1292 Incorrect datetime value: '2010-10-00 01:02:03' for column 'a' at row 1 Warning 1292 Incorrect datetime value: '-23:00:06' for column 'f1' at row 1
drop table t1; drop table t1;
select maketime(20,61,10)+0; select maketime(20,61,10)+0;
maketime(20,61,10)+0 maketime(20,61,10)+0
......
...@@ -886,16 +886,14 @@ select truncate(date('2010-40-10'), 6); ...@@ -886,16 +886,14 @@ select truncate(date('2010-40-10'), 6);
select extract(month from '2010-40-50'); select extract(month from '2010-40-50');
select subtime('0000-00-10 10:10:10', '30 10:00:00'); select subtime('0000-00-10 10:10:10', '30 10:00:00');
#
# lp:730637 Valgrind warnings in 5.1-micro
#
select cast(str_to_date(NULL, '%H:%i:%s') as time); select cast(str_to_date(NULL, '%H:%i:%s') as time);
create table t1 (a timestamp,key(a)); create table t1 (f1 datetime, key (f1));
insert t1 values ('2010-01-01 02:03:04'); insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49');
insert t1 select a + interval 1 day from t1; select * from t1 where f1 > time('-23:00:06');
insert t1 select a + interval 2 day from t1;
insert t1 select a + interval 4 day from t1;
insert t1 select a + interval 8 day from t1;
insert t1 select a + interval 16 day from t1;
explain select * from t1 where a > cast('2010-10-00 01:02:03' as datetime);
drop table t1; drop table t1;
# #
......
...@@ -84,7 +84,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, ...@@ -84,7 +84,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date,
if (not_zero_date) if (not_zero_date)
{ {
if ((((flags & TIME_NO_ZERO_IN_DATE) || !(flags & TIME_FUZZY_DATE)) && if ((((flags & TIME_NO_ZERO_IN_DATE) || !(flags & TIME_FUZZY_DATE)) &&
(ltime->month == 0 || ltime->day == 0)) || (ltime->month == 0 || ltime->day == 0)) || ltime->neg ||
(!(flags & TIME_INVALID_DATES) && (!(flags & TIME_INVALID_DATES) &&
ltime->month && ltime->day > days_in_month[ltime->month-1] && ltime->month && ltime->day > days_in_month[ltime->month-1] &&
(ltime->month != 2 || calc_days_in_year(ltime->year) != 366 || (ltime->month != 2 || calc_days_in_year(ltime->year) != 366 ||
......
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