diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-03-07 23:19:26 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-03-07 23:19:26 +0100 |
commit | b27b5793a0d812cb2be535eadd280134efab22a5 (patch) | |
tree | 451da73aac3b73d20ae839a258faf3e5a8245eaa | |
parent | 30e5b4d7196eb56ef3032f016823ecaae2207680 (diff) | |
download | mariadb-git-b27b5793a0d812cb2be535eadd280134efab22a5.tar.gz |
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.
-rw-r--r-- | mysql-test/r/func_time.result | 18 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 14 | ||||
-rw-r--r-- | sql-common/my_time.c | 2 |
3 files changed, 14 insertions, 20 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index bc0fc98cd54..654ab0f7351 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1430,18 +1430,14 @@ NULL select cast(str_to_date(NULL, '%H:%i:%s') as time); cast(str_to_date(NULL, '%H:%i:%s') as time) NULL -create table t1 (a timestamp,key(a)); -insert t1 values ('2010-01-01 02:03:04'); -insert t1 select a + interval 1 day from t1; -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); -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 +create table t1 (f1 datetime, key (f1)); +insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49'); +select * from t1 where f1 > time('-23:00:06'); +f1 +2000-09-12 00:00:00 +2007-04-25 05:08:49 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; select maketime(20,61,10)+0; maketime(20,61,10)+0 diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 9c753f53509..a24261cdf90 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -886,16 +886,14 @@ select truncate(date('2010-40-10'), 6); select extract(month from '2010-40-50'); 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); -create table t1 (a timestamp,key(a)); -insert t1 values ('2010-01-01 02:03:04'); -insert t1 select a + interval 1 day from t1; -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); +create table t1 (f1 datetime, key (f1)); +insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49'); +select * from t1 where f1 > time('-23:00:06'); drop table t1; # diff --git a/sql-common/my_time.c b/sql-common/my_time.c index ae1e4b7aa89..11dd60646ef 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -84,7 +84,7 @@ my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, if (not_zero_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) && ltime->month && ltime->day > days_in_month[ltime->month-1] && (ltime->month != 2 || calc_days_in_year(ltime->year) != 366 || |