• Gleb Shchepa's avatar
    Bug #39283: Date returned as VARBINARY to client for queries · e7520c4b
    Gleb Shchepa authored
                with COALESCE and JOIN
    
    The server returned to a client the VARBINARY column type
    instead of the DATE type for a result of the COALESCE,
    IFNULL, IF, CASE, GREATEST or LEAST functions if that result
    was filesorted in an anonymous temporary table during
    the query execution.
    
    For example:
      SELECT COALESCE(t1.date1, t2.date2) AS result
        FROM t1 JOIN t2 ON t1.id = t2.id ORDER BY result;
    
    
    To create a column of various date/time types in a
    temporary table the create_tmp_field_from_item() function
    uses the Item::tmp_table_field_from_field_type() method
    call. However, fields of the MYSQL_TYPE_NEWDATE type were
    missed there, and the VARBINARY columns were created
    by default.
    Necessary condition has been added.
    e7520c4b
metadata.test 3.6 KB