Bug #53818 Default values in .frm file not byte-order-independent
Submitted: 19 May 2010 17:31 Modified: 26 May 2010 9:00
Reporter: Frazer Clement Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:mysql-5.1 OS:Any
Assigned to: CPU Architecture:Any

[19 May 2010 17:31] Frazer Clement
The .frm files used to store MySQL table schemata are advertised as byte-order independent.

This is mostly the case, but column default values are stored within the .frm file in the byte-order preferred by the table's handler object - as returned by a call to the ha->low_byte_first() function.

Some storage engines are fixed-endian (either little or big endian) on all platforms which they run (e.g. MyISAM is always little-endian).  This implies that .frm files created for MyISAM tables will have the same format on all platforms.  It also implies that MyISAM must always do data conversions at runtime on big-endian architectures.

Some storage engines prefer to use the byte-order of the underlying platform for efficiency.  However they still need the .frm files describing the table schema to be byte-order independent.

This suggests that the Server itself should choose a fixed byte-order for .frm files, independent of the handler's (current) byte order.  It should convert the defaults record to/from the fixed byte-order automatically when loading / storing the frm file.

How to repeat:
Using Ndb storage engine.

1) Define table stored in Ndb engine on little-endian platform with default values which are byte-order-sensitive (e.g int, float, double...)

2) Define same table in Ndb engine on big-endian platform

3) Compare binary .frm files.

Suggested fix:
1) Standardise format of defaults record within .frm file to one byte order
   (Little makes sense as the rest of the .frm is little)
   Server should have code to convert to/from standard format if ha->low_byte_first() is different.

2) Add code to detect (if possible) when frm file being loaded is in 'wrong' order, and convert defaults on the fly
[26 May 2010 9:00] Sveta Smirnova
Thank you for the report.

Verified as described using mysql-cluster-gpl-7.1.3-linux-x86_64-glibc23 package.