1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-15293 CAST(AS TIME) returns bad results for LAST_VALUE(),NAME_CONST(),SP variable

This commit is contained in:
Alexander Barkov
2018-02-13 20:37:31 +04:00
parent 0c4aeef976
commit 95d075a0e5
16 changed files with 420 additions and 62 deletions

View File

@ -2651,6 +2651,12 @@ Type_handler_int_result::Item_get_cache(THD *thd, const Item *item) const
return new (thd->mem_root) Item_cache_int(thd, item->type_handler());
}
Item_cache *
Type_handler_year::Item_get_cache(THD *thd, const Item *item) const
{
return new (thd->mem_root) Item_cache_year(thd);
}
Item_cache *
Type_handler_real_result::Item_get_cache(THD *thd, const Item *item) const
{
@ -3175,6 +3181,53 @@ bool Type_handler_string_result::Item_val_bool(Item *item) const
}
/*************************************************************************/
bool Type_handler_int_result::Item_get_date(Item *item, MYSQL_TIME *ltime,
ulonglong fuzzydate) const
{
return item->get_date_from_int(ltime, fuzzydate);
}
bool Type_handler_year::Item_get_date(Item *item, MYSQL_TIME *ltime,
ulonglong fuzzydate) const
{
return item->get_date_from_year(ltime, fuzzydate);
}
bool Type_handler_real_result::Item_get_date(Item *item, MYSQL_TIME *ltime,
ulonglong fuzzydate) const
{
return item->get_date_from_real(ltime, fuzzydate);
}
bool Type_handler_decimal_result::Item_get_date(Item *item, MYSQL_TIME *ltime,
ulonglong fuzzydate) const
{
return item->get_date_from_decimal(ltime, fuzzydate);
}
bool Type_handler_string_result::Item_get_date(Item *item, MYSQL_TIME *ltime,
ulonglong fuzzydate) const
{
return item->get_date_from_string(ltime, fuzzydate);
}
bool Type_handler_temporal_result::Item_get_date(Item *item, MYSQL_TIME *ltime,
ulonglong fuzzydate) const
{
DBUG_ASSERT(0); // Temporal type items must implement native get_date()
item->null_value= true;
set_zero_time(ltime, mysql_timestamp_type());
return true;
}
/*************************************************************************/
longlong Type_handler_real_result::
@ -3892,7 +3945,7 @@ bool Type_handler_string_result::
::get_date() can be called for non-temporal values,
for example, SELECT MONTH(GREATEST("2011-11-21", "2010-10-09"))
*/
return func->Item::get_date(ltime, fuzzydate);
return func->get_date_from_string(ltime, fuzzydate);
}
@ -3900,7 +3953,7 @@ bool Type_handler_numeric::
Item_func_min_max_get_date(Item_func_min_max *func,
MYSQL_TIME *ltime, ulonglong fuzzydate) const
{
return func->Item::get_date(ltime, fuzzydate);
return Item_get_date(func, ltime, fuzzydate);
}