• Alexander Barkov's avatar
    MDEV-23323 Rounding functions return a wrong data type for a BIT, ENUM, SET argument · 6d3186e3
    Alexander Barkov authored
    Implementing dedicated fixing methods:
    - Type_handler_bit::Item_func_round_fix_length_and_dec()
    - Type_handler_bit::Item_func_int_val_fix_length_and_dec()
    - Type_handler_typelib::Item_func_round_fix_length_and_dec()
    
    because the inherited methods did not work well.
    
    Fixing:
    - Type_handler_typelib::Item_func_int_val_fix_length_and_dec
      It did not work well, because it used args[0]->max_length to
      calculate the result data type. In case of ENUM and SET it was
      not correct, because in FLOOR() and CEILING() context
      ENUM and SET return not more than 5 digits (65535 is the biggest
      possible value).
    
    Misc:
    - Changing the API of
        Type_handler_bit::Bit_decimal_notation_int_digits(const Item *item)
      to a more generic form:
        Type_handler_bit::Bit_decimal_notation_int_digits_by_nbits(uint nbits)
    
    - Fixing Type_handler_bit::Bit_decimal_notation_int_digits_by_nbits() to
      return the exact number of decimal digits for all nbits 1..64.
      The old implementation was approximate.
      This change gives better (more precise) data types.
    6d3186e3
sql_type.cc 262 KB