From: Roy Lyseng Date: October 7 2010 6:48am Subject: Re: bzr commit into mysql-5.5-bugteam branch (epotemkin:3213) Bug#57095 List-Archive: http://lists.mysql.com/commits/120188 Message-Id: <4CAD6D3D.90701@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 07.10.10 08.29, Evgeny Potemkin wrote: >> Do we have the same issue with other functions? E.g. CASE? > The difference between coalesce and case is that case just passes val_xxx call > to the appropriate item from the internal items array while coalesce is a > descendant of Item_func_numhybrid and it operates in a bit different way. > Item_func_numhybrid::val_xxx first calls xxx_op function of appropriate result > type (str_op in case of datetime values) and then converts what it got to asked > type. So there is no easy and safe way to fix it this way, IMO. > With this fix even if there are similar problems they'll be hidden. Prior to it > Item_cache_datetime expected a datetime returning item to also return correct > int datetime representation. Now this is explicitly checked. > However it's worth adding better implementation of result_as_longlong for > IF/CASE functions. Will do in the next patch. Just to chime in here, COALESCE is just a special case of a CASE, and could easily have been transformed directly to a CASE expression. Simpler optimization, simpler execution and less errors would be the result. The same applies to NULLIF. Thanks, Roy