Commit 07fd5d6f authored by Oystein Grovlen's avatar Oystein Grovlen

Bug#57512 str_to_date crash...

str_to_date function should only try to generate a warning for
invalid input strings, not when input value is NULL. In latter
case, val_str() of input argument will return a nil pointer.
Trying to generate a warning using this pointer lead to a
segmentation fault. Solution: Only generate warning when pointer
to input string is non-nil.
parent 85360dc5
...@@ -1327,3 +1327,12 @@ SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1 ...@@ -1327,3 +1327,12 @@ SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1
date_date date_date
DROP TABLE t1; 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
#
...@@ -842,5 +842,13 @@ INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00'); ...@@ -842,5 +842,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 >= 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"); SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00");
DROP TABLE t1; 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 # --echo #
...@@ -3465,7 +3465,7 @@ bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date) ...@@ -3465,7 +3465,7 @@ bool Item_func_str_to_date::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
return 0; return 0;
null_date: null_date:
if (fuzzy_date & TIME_NO_ZERO_DATE) if (val && (fuzzy_date & TIME_NO_ZERO_DATE))
{ {
char buff[128]; char buff[128];
strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1)); strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1));
......
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