• Alexander Barkov's avatar
    MDEV-23351 Rounding functions return wrong data types for DATE input · dc513dff
    Alexander Barkov authored
    Fixing ROUND(date,0), TRUNCATE(date,x), FLOOR(date), CEILING(date)
    to return the `int(8) unsigned` data type.
    
    Details:
    1. Cleanup: moving virtual implementations
       - Type_handler_temporal_result::Item_func_int_val_fix_length_and_dec()
       - Type_handler_temporal_result::Item_func_round_fix_length_and_dec()
       to Type_handler_date_common. Other temporal data type handlers
       override these methods anyway. So they were only DATE specific.
       This change makes the code clearer.
    2. Backporting DTCollation_numeric from 10.5, to reuse the code easier.
    3. Adding the `preferred_attrs` argument to Item_func_round::fix_arg_int(). Now
       Type_handler_xxx::Item_func_round_val_fix_length_and_dec() work as follows:
       - The INT-alike and YEAR handlers copy preferred_attrs from args[0].
       - The DATE handler passes explicit attributes, to get `int(8) unsigned`.
       - The hex hybrid handler passes NULL, so fix_arg_int() calculates attributes.
    4. Type_handler_date_common::Item_func_int_val_fix_length_and_dec()
       now sets the type handler and attributes to get `int(8) unsigned`.
    dc513dff
item_func.h 108 KB