• Chaithra Gopalareddy's avatar
    Bug#11757005: UNION CONVERTS UNSIGNED MEDIUMINT AND BIGINT · adc973d5
    Chaithra Gopalareddy authored
                  TO SIGNED
    Problem:
    When we are joining types (of fields) in case of a union, we usually
    upgrade the datatypes to the largest present in the query.
    In case of mediumint, it is not happening.
    Analysis:
    When joined with types LONG and LONGLONG, mediumint should get
    upgraded to LONG and LONGLONG respectively.
    W.r.t the given query, constant '1' will be created as a LONGLONG
    internally and SIGNED flag is enabled. As a result, while combining
    types for the field, LONGLONG along with MEDIUMINT gets converted
    to LONG first. LONG with MEDIUMINT(of the third select) gets converted
    to MEDIUMINT. SIGNED FLAG would be that of the first field's.
    As a result, the final result would be SIGNED MEDIUMINT.
    Fix:
    While joining types, MEDIUMINT with LONGLONG and MEDIUMINT with LONG
    is converted to LONGLONG and LONG respectively. Also, made some 
    changes for FLOAT and DOUBLE.
    adc973d5
field.cc 290 KB