summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/myoffice.izhnet.ru>2006-11-16 15:26:33 +0400
committerunknown <ramil/ram@mysql.com/myoffice.izhnet.ru>2006-11-16 15:26:33 +0400
commit096631a3d39c52a98f3c941dd30aa7ed07237cb0 (patch)
tree153aa0aac99ed1dd374044f2e4f878501cc4a7ed
parent44f15caec3145adb09020de90aa38e0201e7a63b (diff)
parent69d8bfe2319f313ab31f92a450890a870b630fe7 (diff)
downloadmariadb-git-096631a3d39c52a98f3c941dd30aa7ed07237cb0.tar.gz
Merge mysql.com:/usr/home/ram/work/bug23653/my41-bug23653
into mysql.com:/usr/home/ram/work/bug23653/my50-bug23653 mysql-test/r/func_time.result: Auto merged mysql-test/t/func_time.test: Auto merged sql/item_timefunc.cc: Auto merged
-rw-r--r--mysql-test/r/func_time.result3
-rw-r--r--mysql-test/t/func_time.test6
-rw-r--r--sql/item_timefunc.cc3
3 files changed, 11 insertions, 1 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index e8fd7a4e4c9..1e5c01be288 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1047,6 +1047,9 @@ union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
H
5
+select last_day('0000-00-00');
+last_day('0000-00-00')
+NULL
End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index a3985998b13..b0c2c50d4d1 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -564,6 +564,12 @@ union
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
+#
+# Bug #23653: crash if last_day('0000-00-00')
+#
+
+select last_day('0000-00-00');
+
--echo End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index a776d8a5ff7..db526050bfd 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -3369,7 +3369,8 @@ String *Item_func_str_to_date::val_str(String *str)
bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date)
{
- if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE))
+ if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
+ (ltime->month == 0))
return 1;
uint month_idx= ltime->month-1;
ltime->day= days_in_month[month_idx];