Commit 1c6f6dc8 authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent 885edc4f
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment