1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-28 17:36:30 +03:00

bugfix: Item_cache_temporal::convert_to_basic_const_item assumed DATETIME

while it should look at the actual field_type() and use get_date()
or get_time() as appropriate.

test case is in the following commit.
This commit is contained in:
Sergei Golubchik
2018-03-12 20:15:18 +01:00
parent 885edc4fa5
commit 1c6f6dc892

View File

@@ -9853,9 +9853,18 @@ Item *Item_cache_temporal::convert_to_basic_const_item(THD *thd)
else
{
MYSQL_TIME ltime;
unpack_time(val_datetime_packed(), &ltime);
new_item= (Item*) new (thd->mem_root) Item_datetime_literal(thd, &ltime,
decimals);
if (Item_cache_temporal::field_type() == MYSQL_TYPE_TIME)
{
unpack_time(val_time_packed(), &ltime);
new_item= (Item*) new (thd->mem_root) Item_time_literal(thd, &ltime,
decimals);
}
else
{
unpack_time(val_datetime_packed(), &ltime);
new_item= (Item*) new (thd->mem_root) Item_datetime_literal(thd, &ltime,
decimals);
}
}
return new_item;
}