• Mats Kindahl's avatar
    Bug #52131: SET and ENUM stored endian-dependent in binary log · 8642812c
    Mats Kindahl authored
    Replication SET and ENUM fields from a big-endian to a little-
    endian machine (or the opposite) that are represented using
    more than 1 byte (SET fields with more than 8 members or ENUM
    fields with more than 256 constants) will fail to replicate
    correctly when using row-based replication.
    
    The reason is that there are no pack() or unpack() functions
    for Field_set or Field_enum, which make them rely on Field::pack
    and Field::unpack. These functions pack data as strings, but
    since Field_set and Field_enum use integral types for
    representation, the fields are stored incorrectly on big-endian
    machines.
    
    This patch adds Field_enum::pack and Field_enum::unpack
    functions that store the integral value correctly in the binary
    log even on big-endian machines. Since Field_set inherits from
    Field_enum, it will use the same functions for packing and
    unpacking the field.
    
    sql/field.cc:
      Removing some obsolete debug printouts and adding Field_enum::pack
      and Field_enum::unpack functions.
    sql/field.h:
      Adding helper functions for packing and unpacking 16- and
      24-bit integral types.
      
      Field_short::pack and Field_short::unpack now use these functions.
    sql/rpl_record.cc:
      Removing some obsolete debug printouts and adding some
      more useful ones.
    8642812c
field.h 82.8 KB