• unknown's avatar
    Fix bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced · 7fde035c
    unknown authored
    length.
    
    When temporary field created for DATE(LEFT(column,8)) expression, max_length
    value is taken from Item_date_typecast, and it is getting it from underlaid
    Item_func_left and it's max_length is 8 in given expression. And all this
    results in stripping last 2 digits.
    
    To Item_date_typecast class added its own fix_length_and_dec() function 
    that sets max_length value to 10, which is proper for DATE field.
    
    
    mysql-test/t/group_by.test:
      Test case for bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced length.
    mysql-test/r/group_by.result:
      Test case for bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced length.
    sql/item_timefunc.h:
      Fix bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced length.
      To Item_date_typecast class added its own fix_length_and_dec() which sets proper max_length value.
    7fde035c
group_by.test 25.5 KB