Skip to content

Commit

Permalink
bugfix: Item_cache_temporal::convert_to_basic_const_item assumed DATE…
Browse files Browse the repository at this point in the history
…TIME

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.
  • Loading branch information
vuvova committed Mar 14, 2018
1 parent 885edc4 commit 1c6f6dc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1c6f6dc

Please sign in to comment.