summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Nozdrin <alexander.nozdrin@oracle.com>2010-11-25 14:33:11 +0300
committerAlexander Nozdrin <alexander.nozdrin@oracle.com>2010-11-25 14:33:11 +0300
commitb07b8de14fec04aaf5ba49869623d5c8e56ca91d (patch)
tree91aa6f910c027e9cdcc364081e0fa72d6ab6ceab
parentd71390449c9f2a3b0589804cd876d5f3172d4c90 (diff)
parent07fd5d6f993992f04074c6d16e08cdf42d22cc97 (diff)
downloadmariadb-git-b07b8de14fec04aaf5ba49869623d5c8e56ca91d.tar.gz
Auto-merge from mysql-5.5.7-rc-release.
-rw-r--r--mysql-test/r/func_time.result9
-rw-r--r--mysql-test/t/func_time.test8
-rw-r--r--sql/item_timefunc.cc2
3 files changed, 18 insertions, 1 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 0ed46ba270b..34987530b5a 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1341,3 +1341,12 @@ SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1
date_date
DROP TABLE t1;
#
+# Bug#57512 str_to_date crash...
+#
+SELECT WEEK(STR_TO_DATE(NULL,0));
+WEEK(STR_TO_DATE(NULL,0))
+NULL
+SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR);
+SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR)
+NULL
+#
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 0a2b473ca59..25600a2d583 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -852,5 +852,13 @@ INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00');
SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00");
SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00");
DROP TABLE t1;
+
+--echo #
+--echo # Bug#57512 str_to_date crash...
+--echo #
+
+SELECT WEEK(STR_TO_DATE(NULL,0));
+SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR);
+
--echo #
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 49336b04e16..3771706fb63 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -3465,7 +3465,7 @@ bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
return 0;
null_date:
- if (fuzzy_date & TIME_NO_ZERO_DATE)
+ if (val && (fuzzy_date & TIME_NO_ZERO_DATE))
{
char buff[128];
strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1));