Hi Sergei, On 02/03/2014 07:44 PM, Sergei Golubchik wrote:
Hi, Alexander!
Ah, so at the end you've decided to fix the type, not the assert. Fine. Ok to push.
There were two problems actually: - the type - the assert I fixed both. Thanks for review! Btw, the problem with type can be back ported to 5.5 or 5.3.
On Jan 31, Alexander Barkov wrote:
Hi Sergei,
Please review a patch for mdev-5450.
Thanks.
=== modified file 'sql/item_timefunc.cc' --- sql/item_timefunc.cc 2013-12-16 12:02:21 +0000 +++ sql/item_timefunc.cc 2014-01-31 12:35:17 +0000 @@ -1480,12 +1480,42 @@ String *Item_temporal_func::val_str(Stri }
+bool Item_temporal_hybrid_func::fix_temporal_type(MYSQL_TIME *ltime) +{ + if (ltime->time_type < 0) /* MYSQL_TIMESTAMP_NONE, MYSQL_TIMESTAMP_ERROR */ + return false; + switch (field_type()) + { + case MYSQL_TYPE_TIME: + ltime->year= ltime->month= ltime->day= 0; + ltime->time_type= MYSQL_TIMESTAMP_TIME; + return false; + case MYSQL_TYPE_DATETIME: + case MYSQL_TYPE_TIMESTAMP: + ltime->neg= 0; + ltime->time_type= MYSQL_TIMESTAMP_DATETIME; + return false; + case MYSQL_TYPE_DATE: + ltime->neg= 0; + ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; + ltime->time_type= MYSQL_TIMESTAMP_DATE; + return false; + case MYSQL_TYPE_STRING: /* DATE_ADD, ADDTIME can return VARCHAR */ + return false; + default: + DBUG_ASSERT(0); + return true; + } + return false; +} + + String *Item_temporal_hybrid_func::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime;
- if (get_date(<ime, 0) || + if (get_date(<ime, 0) || fix_temporal_type(<ime) || (null_value= my_TIME_to_str(<ime, str, decimals))) return (String *) 0;
Regards, Sergei