diff options
author | Alexander Barkov <bar@mariadb.org> | 2014-06-06 10:29:52 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2014-06-06 10:29:52 +0400 |
commit | 216fbe2af3c8dc81f492af79dee61d6a3d333678 (patch) | |
tree | 8fc7a2b00b5fe229d79d2b4216d236debd201fa1 /sql/item_cmpfunc.cc | |
parent | d8edb88cb15c3341a7686eb5909dde6deac16674 (diff) | |
download | mariadb-git-216fbe2af3c8dc81f492af79dee61d6a3d333678.tar.gz |
MDEV-6102 Comparison between TIME and DATETIME does not use CURRENT_DATE
MDEV-6101 Hybrid functions do not add CURRENT_DATE when converting TIME to DATETIME
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 2c4218279d7..289668f24ca 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -900,9 +900,11 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, { MYSQL_TIME ltime; uint fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES; - if (f_type == MYSQL_TYPE_TIME) - fuzzydate|= TIME_TIME_ONLY; - if (item->get_date(<ime, fuzzydate)) + if ((item->field_type() == MYSQL_TYPE_TIME && + is_temporal_type_with_date(warn_item->field_type())) ? + item->get_date_with_conversion(<ime, fuzzydate) : + item->get_date(<ime, fuzzydate | + (f_type == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0))) value= 0; /* invalid date */ else value= pack_time(<ime); @@ -2559,9 +2561,9 @@ Item_func_ifnull::str_op(String *str) 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)) + if (!args[0]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES)) return (null_value= false); - if (!args[1]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES)) + if (!args[1]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES)) return (null_value= false); bzero((char*) ltime,sizeof(*ltime)); return null_value= !(fuzzydate & TIME_FUZZY_DATES); @@ -2752,7 +2754,7 @@ bool Item_func_if::date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(fixed == 1); Item *arg= args[0]->val_bool() ? args[1] : args[2]; - return (null_value= arg->get_date(ltime, fuzzydate)); + return (null_value= arg->get_date_with_conversion(ltime, fuzzydate)); } @@ -2997,7 +2999,7 @@ bool Item_func_case::date_op(MYSQL_TIME *ltime, uint fuzzydate) Item *item= find_item(&dummy_str); if (!item) return (null_value= true); - return (null_value= item->get_date(ltime, fuzzydate)); + return (null_value= item->get_date_with_conversion(ltime, fuzzydate)); } @@ -3315,7 +3317,8 @@ bool Item_func_coalesce::date_op(MYSQL_TIME *ltime,uint fuzzydate) null_value= 0; for (uint i= 0; i < arg_count; i++) { - bool res= args[i]->get_date(ltime, fuzzydate & ~TIME_FUZZY_DATES); + bool res= args[i]->get_date_with_conversion(ltime, + fuzzydate & ~TIME_FUZZY_DATES); if (!args[i]->null_value) return res; } |