Bug #31254 "Max_data_length" truncated / reported wrong (compiler issue ?)
Submitted: 27 Sep 2007 18:23 Modified: 24 Oct 2007 20:01
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:5.1.22-rc OS:IBM AIX (+ i5os, 32 Bit, IBM compiler)
Assigned to: Alexey Kopytov CPU Architecture:Any

[27 Sep 2007 18:23] Joerg Bruehe
Description:
This report is from the 5.1.22-rc build, but the issue can also be observed in (at least) 5.1.21.

It is specific to the 32 bit version on AiX and i5os, which both use the same compiler (IBM) on the PowerPC CPU.

-------------------------------------------------------
*** /PATH/mysql-test/r/myisam.result
--- /PATH/mysql-test/r/myisam.reject
***************
*** 941,947
  CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
  SHOW TABLE STATUS LIKE 't1';
  Name  Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free Auto_increment   Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
! t1    MyISAM  10      Dynamic X       X       X       72057594037927935       X       X       X       X       X       X latin1_swedish_ci        X       max_rows=4100100100 avg_row_length=70100
  DROP TABLE t1;
  CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
  INSERT INTO t1 VALUES
--- 941,947
  CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
  SHOW TABLE STATUS LIKE 't1';
  Name  Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free Auto_increment   Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
! t1    MyISAM  10      Dynamic X       X       X       2147483647      X       X       X       X       X       X       latin1_swedish_ci  X       max_rows=4100100100 avg_row_length=70100
  DROP TABLE t1;
  CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
  INSERT INTO t1 VALUES
-------------------------------------------------------

So the "Max_data_length" for this table is cut at 0x7FFFFFFF (max signed 32 bit)
whereas the reference protocol has 0xFFFFFFFFFFFFFF (7 byte 0xFF) if I calculated it right.

How to repeat:
Run the test on AIX or i5os (32 bit).
[8 Oct 2007 13:13] Alexey Kopytov
This is a build issue. On AIX off_t is 32-bit by default, and we have the following code in mi_open() which truncates max_data_file_length to INT_MAX32 (0x7FFFFFFF):

#if SIZEOF_OFF_T == 4
    set_if_smaller(max_data_file_length, INT_MAX32);
    set_if_smaller(max_key_file_length, INT_MAX32);
#endif

We need to add -D_LARGE_FILES to CFLAGS on AIX to overcome this limitation. That makes off_t to be defined as a signed 64-bit integer.
[12 Oct 2007 10:04] 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/35458

ChangeSet@1.2527, 2007-10-12 14:03:51+04:00, kaa@polly.(none) +2 -0
  Fix for bug #31254: "Max_data_length" truncated / reported wrong
  (compiler issue ?)
  
  Problem:
  
  Improper compile-time flags on AIX prevented use of files > 2 GB. This
  resulted in Max_data_length being truncated to 2 GB by MyISAM code.
  
  Solution:
  
  Reverted large-file changes from the fix for bug10776. We need to define
  _LARGE_FILES on AIX to have support for files > 2 GB.
  
   Since _LARGE_FILE_API is incompatible with _LARGE_FILES and may be
  automatically defined by including standards.h, we also need a
  workaround to avoid this conflict.
[18 Oct 2007 21:33] Bugs System
Pushed into 5.1.23-beta
[18 Oct 2007 21:36] Bugs System
Pushed into 5.0.52
[24 Oct 2007 20:01] Paul Dubois
No changelog entry needed.