diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-01-08 21:23:03 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-01-08 21:23:03 +0100 |
commit | b0ee31c89480519490537b89dca1e8cc65e2b73b (patch) | |
tree | ed4d62ba164ba63763704fc41007489910489fc8 | |
parent | 6f26aac9409e3456798e58a4ee4306e43c7ebf7b (diff) | |
download | mariadb-git-b0ee31c89480519490537b89dca1e8cc65e2b73b.tar.gz |
MDEV-3942 FROM_DAYS(<timestamp column>) returns different result in MariaDB comparing to MySQL: NULL vs 0000-00-00
fixed a regression, introduced while fixing MDEV-456
-rw-r--r-- | mysql-test/r/datetime_456.result | 2 | ||||
-rw-r--r-- | mysql-test/r/func_time.result | 2 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 8 | ||||
-rw-r--r-- | sql/time.cc | 4 |
4 files changed, 7 insertions, 9 deletions
diff --git a/mysql-test/r/datetime_456.result b/mysql-test/r/datetime_456.result index ba020a250b7..44351a821bc 100644 --- a/mysql-test/r/datetime_456.result +++ b/mysql-test/r/datetime_456.result @@ -4,5 +4,5 @@ insert t1 values (addtime('9999-12-31 23:59:59', '00:00:01')), select * from t1; d NULL -NULL +0000-00-00 00:00:00 drop table t1; diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 2df0c691083..14d2729e952 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1453,7 +1453,7 @@ MAKEDATE(11111111,1) NULL SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1); WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1) -NULL +0 # # Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0, # diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index eaddd39fa58..9f2f9b2950d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. + Copyright (c) 2010, 2013, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1386,13 +1387,10 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date) if (get_date_from_daynr((long) value, <ime->year, <ime->month, <ime->day)) - return (null_value= 1); - - if ((fuzzy_date & TIME_NO_ZERO_DATE) && ltime->year == 0) - return (null_value= 1); + return 0; ltime->time_type= MYSQL_TIMESTAMP_DATE; - return (null_value= 0); + return 0; } diff --git a/sql/time.cc b/sql/time.cc index 21ecc3f8050..3b1613282fb 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. - Copyright (c) 2009-2011 Monty Program Ab + Copyright (c) 2009-2013 Monty Program Ab Use is subject to license terms. This program is free software; you can redistribute it and/or modify @@ -153,7 +153,7 @@ bool get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month, uchar *month_pos; DBUG_ENTER("get_date_from_daynr"); - if (daynr < 365 || daynr > MAX_DAY_NUMBER) + if (daynr < 366 || daynr > MAX_DAY_NUMBER) DBUG_RETURN(1); year= (uint) (daynr*100 / 36525L); |