summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-04-18 23:15:15 +0400
committerAlexander Barkov <bar@mariadb.org>2016-04-18 23:15:15 +0400
commit6fd54c01bb5bc480497b143d63181837148ff47f (patch)
tree6b6ff4590b8b265234b8083f5d6fcd4dff822f02 /sql/item_cmpfunc.cc
parent777c2131dd7aeaf25adbbbbb0c213950e852f22b (diff)
downloadmariadb-git-6fd54c01bb5bc480497b143d63181837148ff47f.tar.gz
MDEV-9521 Least function returns 0000-00-00 for null date columns instead of null
Item_func_ifnull::date_op() and Item_func_coalesce::date_op() could erroneously return 0000-00-00 instead of NULL when get_date() was called with the TIME_FUZZY_DATES flag, e.g. from LEAST().
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc14
1 files changed, 4 insertions, 10 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 81688f3321c..9287b74a867 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2558,10 +2558,7 @@ bool Item_func_ifnull::date_op(MYSQL_TIME *ltime, uint fuzzydate)
DBUG_ASSERT(fixed == 1);
if (!args[0]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES))
return (null_value= false);
- if (!args[1]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES))
- return (null_value= false);
- bzero((char*) ltime,sizeof(*ltime));
- return null_value= !(fuzzydate & TIME_FUZZY_DATES);
+ return (null_value= args[1]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES));
}
@@ -3311,15 +3308,12 @@ double Item_func_coalesce::real_op()
bool Item_func_coalesce::date_op(MYSQL_TIME *ltime,uint fuzzydate)
{
DBUG_ASSERT(fixed == 1);
- null_value= 0;
for (uint i= 0; i < arg_count; i++)
{
- bool res= args[i]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES);
- if (!args[i]->null_value)
- return res;
+ if (!args[i]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES))
+ return (null_value= false);
}
- bzero((char*) ltime,sizeof(*ltime));
- return null_value|= !(fuzzydate & TIME_FUZZY_DATES);
+ return (null_value= true);
}