Bug #52131 SET and ENUM stored endian-dependent in binary log
Submitted: 17 Mar 2010 10:09 Modified: 24 Nov 2010 10:53
Reporter: Mats Kindahl Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S2 (Serious)
Version:5.1 OS:Any
Assigned to: Mats Kindahl CPU Architecture:Any

[17 Mar 2010 10:09] Mats Kindahl
Description:
SET and ENUM fields are represented in the record format as integers, but pack() and unpack() treats them as strings.

How to repeat:
Read the code and see that Field_enum and Field_set does not override pack() and unpack() the same way as integer fields like Field_tiny do.

Suggested fix:
Create pack() and unpack() functions for Field_enum (which will then be used by Field_set as well).
[9 Sep 2010 12:41] Bernd Ocklin
Failing test cases on solaris in e.g. mysql-5.1-telco-7.1:

rpl_ndb.rpl_ndb_typeconv_all
rpl_ndb.rpl_ndb_typeconv_lossy
[6 Oct 2010 17:20] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/120155

3089 Mats Kindahl	2010-10-06
      Bug #52131: SET and ENUM stored endian-dependent in binary log
      
      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.
[22 Oct 2010 12:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/121679

3915 Martin Skold	2010-10-22 [merge]
      Merge
      modified:
        mysql-test/collections/default.experimental
        sql/field.cc
        sql/field.h
        sql/rpl_record.cc
[22 Oct 2010 12:47] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin@swordfish-20101022114802-8b7a2g8tfcn4voyy) (version source revid:martin@swordfish-20101022114802-8b7a2g8tfcn4voyy) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[22 Oct 2010 12:47] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin@swordfish-20101022115556-maut2js38d8sl9nt) (version source revid:martin@swordfish-20101022115556-maut2js38d8sl9nt) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[26 Oct 2010 8:18] Jon Stephens
Verified by code inspection that fix appears in 7.1 tree, set Documenting status.
[26 Oct 2010 9:20] Jon Stephens
Documented bugfix in the NDB-6.3.39, 7.0.20 and 7.1.9 changelogs as follows:

      Replication of SET and ENUM columns represented using
      more than 1 byte (that is, SET columns with more than 8 members 
      and ENUM columns with more than 256 constants) between platforms 
      using different endianness when using the row-based format. This 
      was because columns of these types are represented internally 
      using integers, but the internal functions used by MySQL to handle 
      them treated them as strings.

Set Patch Pending status as requested by Mats, waiting for merges to 5.1-main and 5.5 trees.
[27 Oct 2010 21:14] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122157

3102 Mats Kindahl	2010-10-27 [merge]
      Merging patch for BUG#52131 with mysql-5.5-bugteam.
[27 Oct 2010 21:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122158

3296 Mats Kindahl	2010-10-27 [merge]
      Merging patch for BUG#52131 into mysql-trunk-bugfixing
[27 Oct 2010 21:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122159

3340 Mats Kindahl	2010-10-27 [merge]
      Merging patch for BUG#52131 into mysql-next-mr-bugfixing
[29 Oct 2010 14:17] Jon Stephens
Also documented in the 5.5.8 changelog. Waiting for merges to 5.1 and trunk.
[4 Nov 2010 17:27] Jon Stephens
Already documented in 5.5; still waiting for merges to 5.1/trunk.
[13 Nov 2010 16:06] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (merge vers: 5.6.99-m4) (pib:21)
[13 Nov 2010 16:33] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:alexander.nozdrin@oracle.com-20101113152540-gxro4g0v29l27f5x) (pib:21)
[15 Nov 2010 12:53] Jon Stephens
No changelog entry needed for -trunk.

Will this fix go into 5.1?

Thanks.
[24 Nov 2010 10:53] Jon Stephens
Mats and Luís confirm we don't plan to put this into 5.1 main at this time; closing.
[16 Dec 2010 22:28] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)