summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-03-19 14:54:46 +0100
committerSergei Golubchik <sergii@pisem.net>2011-03-19 14:54:46 +0100
commita67bf98f02237e39a475bedc362e8fc28dbe44fb (patch)
tree41cb85aa3fb793ad91ac77906f5682b56976a403
parente79a72a410ef74e5105616da8eceb2798f485c57 (diff)
downloadmariadb-git-a67bf98f02237e39a475bedc362e8fc28dbe44fb.tar.gz
lp:738067 Crash in get_datetime_value() in 5.1-micro
-rw-r--r--mysql-test/r/func_time.result3
-rw-r--r--mysql-test/t/func_time.test4
-rw-r--r--sql/item_func.cc2
3 files changed, 9 insertions, 0 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 75c57c34171..9e04078f1ee 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1536,3 +1536,6 @@ drop table t1;
select day(coalesce(null));
day(coalesce(null))
NULL
+select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
+timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'))
+2002-08-20 00:00:00
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index e4b52b0330c..70451e98763 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -973,3 +973,7 @@ drop table t1;
#
select day(coalesce(null));
+#
+# lp:738067 Crash in get_datetime_value() in 5.1-micro
+#
+select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3e539585dde..9ee239b702b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2274,6 +2274,8 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
longlong UNINIT_VAR(min_max);
DBUG_ASSERT(fixed == 1);
+ if (!compare_as_dates)
+ return Item_func::get_date(ltime, fuzzy_date);
for (uint i=0; i < arg_count ; i++)
{