Bug #33785 myisamchk show warning message
Submitted: 10 Jan 2008 5:29 Modified: 18 Dec 2009 13:22
Reporter: Masahiro Tomita Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:5.0.54 OS:Linux (i686-glibc23, Windows XP)
Assigned to: Satya B CPU Architecture:Any

[10 Jan 2008 5:29] Masahiro Tomita
Description:
In mysql-enterprise-5.0.54-linux-i686-glibc23 binary package, myisamchk show warning message:
# uname -a
Linux myhostname 2.4.21-4.0.1.ELsmp #1 SMP Wed Jan 21 14:18:23 JST 2004 i686 i686 i386 GNU/Linux

# myisamchk -s mysql/user.MYI
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted to 4294963200
Warning: option 'read_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'write_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'sort_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295

How to repeat:
above.
[10 Jan 2008 5:59] Valeriy Kravchuk
Thank you for a problem report. Please, send you my.cnf file content.
[10 Jan 2008 7:29] Masahiro Tomita
No my.cnf file exists. So myisamchk --no-defaults show same warning messages.

It work fine by mysql-enterprise-5.0.52-linux-i686-glibc23.

# ./mysql-enterprise-5.0.52-linux-i686-glibc23/bin/myisamchk /var/lib/mysql/mysql/user.MYI
Checking MyISAM file: /var/lib/mysql/mysql/user.MYI
Data records:       5   Deleted blocks:       0
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check record links

# ./mysql-enterprise-5.0.54-linux-i686-glibc23/bin/myisamchk /var/lib/mysql/mysql/user.MYI
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted to 4294963200
Warning: option 'read_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'write_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'sort_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Checking MyISAM file: /var/lib/mysql/mysql/user.MYI
Data records:       5   Deleted blocks:       0
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check record links
[10 Jan 2008 15:40] Valeriy Kravchuk
Thank you for a bug report.
[11 Apr 2008 22:14] Martin Mokrejs
# mysql_install_db
Installing MySQL system tables...
080412  0:01:01 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
080412  0:01:01 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
Installation of system tables failed!

Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:

shell> /usr/bin/mysql -u root mysql
mysql> show tables

Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.

The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
# ls -la
total 16
drwxr-x---  4 mysql mysql 4096 Apr 12 00:01 .
drwxr-xr-x 38 root  root  4096 Apr  2 12:00 ..
drwx------  2 mysql root  4096 Apr 12 00:01 mysql
drwx------  2 mysql root  4096 Apr 12 00:01 test
# grep join /etc/mysql/my.cnf 
#

Gentoo linux on i686, dev-db/mysql-5.0.56, sys-libs/glibc-2.7-r2.
[18 Aug 2008 11:46] Richlv -
upon starting up mysql 5.0.67, the following is logged in the error log :

[Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295

my.cnf does not contain max_join_size directive
[3 Sep 2008 7:18] Shoo Reek
WinXP SP2 / 5.0.67 / Default installation & config

C:\>myisamchk
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted to 4294963200
Warning: option 'read_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'write_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'sort_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295

...etc...
[3 Sep 2008 9:15] Shoo Reek
WinXP SP2 / 5.0.67 / Default installation & config

Strange for me behaviour of myisampack and/or myisamchk.

Pack some table:

C:\>myisampack  "tbl1.MYI"
Compressing tbl1.MYD: (420812 records)
- Calculating statistics
- Compressing file
62.56%
Remember to run myisamchk -rq on compressed tables

C:\>myisamchk -rq  "tbl1.MYI"
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted to 4294963200
Warning: option 'read_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'write_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'sort_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
- check record delete-chain
- recovering (with sort) MyISAM-table 'tbl1.MYI'
Data records: 420812
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5

 *** After this check 'show table status'. Max_data_length for this table is 281474976710655.
 *** Unpack table and pack again:

C:\>myisamchk -u  "tbl1.MYI"
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted to 4294963200
Warning: option 'read_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'write_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'sort_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
- recovering (with sort) MyISAM-table 'tbl1.MYI'
Data records: 420812
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5

C:\>myisampack  "tbl1.MYI"
Compressing tbl1.MYD: (420812 records)
- Calculating statistics
- Compressing file
60.17%
Remember to run myisamchk -rq on compressed tables

C:\>myisamchk -rq  "tbl1.MYI"
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted to 4294963200
Warning: option 'read_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'write_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
Warning: option 'sort_buffer_size': unsigned value 18446744073709551615 adjusted to 4294967295
- check record delete-chain
- recovering (with sort) MyISAM-table 'tbl1.MYI'
Data records: 420812
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5

C:\>

 *** After this see 'show table status'. Max_data_length for this table is 4294967295. 
 
 *** The same value appears in myisamchk warning messages. I think it means something :-)
[19 Nov 2008 3:22] Meiji KIMURA
I could reproduce this problem on MySQL 5.0.58 Windows 32-bit version.
I made a debug version of it using Visual Studio 2005, then I looked into a cause of this problem.

That warning message is displayed at my_getopt.c (L.849)

[Warning message]
Warning: option 'key_buffer_size': unsigned value 18446744073709551615 adjusted
to 4294963200

[Code]
if (adjusted)
    my_getopt_error_reporter(WARNING_LEVEL,
                             "option '%s': unsigned value %s adjusted to %s",
                             optp->name, ullstr(old, buf1), ullstr(num, buf2));

Here is a call stack at that time. (Sorry there is some japanese, because I use a Visual Studio 2005 Japanese Version.)

[Call stack]
	myisamchk.exe!getopt_ull_limit_value(unsigned __int64 num=4294963200, const my_option * optp=0x00554c18, int * fix=0x00000000)  行 851	C
 	myisamchk.exe!init_one_value(const my_option * optp=0x00554c18, char * * variable=0x00697510, __int64 value=-1)  行 886 + 0x13 バイト	C
 	myisamchk.exe!init_variables(const my_option * options=0x00554c18)  行 929 + 0x1b バイト	C
 	myisamchk.exe!handle_options(int * argc=0x0013ff5c, char * * * argv=0x0013ff60, const my_option * longopts=0x005541b0, char (int, const my_option *, char *)* get_one_option=0x00401650)  行 112 + 0x9 バイト	C
 	myisamchk.exe!get_options(int * argc=0x0013ff5c, char * * * argv=0x0013ff60)  行 753 + 0x17 バイト	C
 	myisamchk.exe!main(int argc=1, char * * argv=0x003a30c4)  行 101 + 0xd バイト	C
 	myisamchk.exe!__tmainCRTStartup()  行 327 + 0x19 バイト	C
 	myisamchk.exe!mainCRTStartup()  行 196	C

In this situation, the key of this problem is 'options->max_value'.
When calling init_one_value(), 'options->max_value' = -1, and it was extended to __int64 (longlong) like this,

myisamchk.exe!init_one_value(const my_option * optp=0x00554c18, char * * variable=0x00697510, __int64 value=-1)

in init_one_value(), (my_getopt.c L.887) getopt_ull_limit_value() is called.

[code]
case GET_ULONG:
    *((ulong*) variable)= (ulong) getopt_ull_limit_value(value, optp, NULL);
    break;

At that time value = -1, but when entering getopt_ull_limit_value(), -1 is extended to ulonglong(unsigned __int64), Thus -1 became 18446744073709551615.

It is a cause of this problem.

options for 'key_buffer_size' is defined in myisamchk.c L.295 like this.
(I formatted that source code with comment to view easily)

[myisamchk.c]
{ "key_buffer_size",			//	name
OPT_KEY_BUFFER_SIZE,			//	id
"",					//	comment
(gptr*) &check_param.use_buffers,	//	value
(gptr*) &check_param.use_buffers,	//	u_max_values
0,					//	str_values
GET_ULONG,				//	var_type
REQUIRED_ARG,				//	arg_type
(long) USE_BUFFER_INIT,			//	def_value
(long) MALLOC_OVERHEAD,			//	min_value
(long) ~0L,				//	max_value
(long) MALLOC_OVERHEAD,			//	sub_size
(long) IO_SIZE,				//	block_size
0},					//	app_type

"key_buffer_size" is defined as GET_ULONG, but many parameter are defined as signed long. It caused this problem. Some compile option may avoid this situation , but we should modify 'long' to 'ulong'.

[Suggestion to fix]
I can confirm that this modification can avoid waning messages.

  [Current Code]
  (long) ~0L,				//	max_value
  
  [New Code]
  (ulong) ~0,				//	max_value

Please modify about read_buffer_size, write_buffer_size, sort_buffer_size.

That's all.
[21 Aug 2009 12:44] 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/81288

2790 Satya B	2009-08-21
      Fix for Bug #33785 - myisamchk show warning message
      
      myisamchk tool generates warnings when run on an myisam files (.MYI or .MYD)
      This is because of the conversion of max_value for certain options in myisamchk 
      from singed long to unsigned long
      
      The max value for the options key_buffer_size, read_buffer_size, write_buffer
      _size and sort_buffer_size is given as (long) ~0L which becomes -1 when signed 
      convention is used and generates errors from getopt_ull_limit_value() due to 
      conversion of signed long to unsigned long.
      
      Fixed by using the right max size which should be unsigned long.
      
      Note: testcase not attached
      modified:
        myisam/myisamchk.c
[31 Aug 2009 8:40] 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/81985

2794 Satya B	2009-08-31
      Fix for Bug#33785 - myisamchk show warning message
      
      myisamchk tool generates warnings when run on an myisam files (.MYI or .MYD)
      This is because of the conversion of max_value for certain options in myisamchk 
      from singed long to unsigned long
      
      The max value for the options key_buffer_size, read_buffer_size, write_buffer
      _size and sort_buffer_size is given as (long) ~0L which becomes -1 when signed 
      convention is used and generates errors from getopt_ull_limit_value() due to 
      conversion of signed long to unsigned long.
      
      Fixed by using the right max size
      
      Max values for the modified variables (from mysqld.cc)
      -------------------------------------
      1. key_buffer_size
         5.0: ULONG_MAX
         5.1: SIZE_T_MAX
         6.0: SIZE_T_MAX
      
      2. read_buffer_size and write_buffer_size
         5.0: INT_MAX32
         5.1: INT_MAX32
         6.0: INT_MAX32
      
      3. sort_buffer_size (aka myisam_sort_buffer_size)
         5.0: UINT_MAX32
         5.1: ULONG_MAX
         6.0: ULONG_MAX
      
      Note: testcase not attached
      modified:
        myisam/myisamchk.c
[3 Sep 2009 18:05] 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/82368

2805 Satya B	2009-09-03
      Fix for Bug#33785 - myisamchk show warning message
      
      myisamchk tool generates warnings when run on an myisam files (.MYI or .MYD)
      This is because of the conversion of max_value for certain options in myisamchk 
      from singed long to unsigned long
      
      The max value for the options key_buffer_size, read_buffer_size, write_buffer
      _size and sort_buffer_size is given as (long) ~0L which becomes -1  when casted
      from signed long to longlong and then casted to ulonglong. When (ulonglong) -1 
      is compared with maximal value for GET_ULONG data type, we adjust it to 
      (ulonglong) ULONG_MAX and throw the warning.
      
      Fixed by using the right max size.
      
      Max values for the variables (from mysqld.cc)
      ----------------------------
      1. key_buffer_size
         5.0: ULONG_MAX
         5.1: SIZE_T_MAX
         6.0: SIZE_T_MAX
      
      2. read_buffer_size and write_buffer_size
         5.0: INT_MAX32
         5.1: INT_MAX32
         6.0: INT_MAX32
      
      3. sort_buffer_size (aka myisam_sort_buffer_size)
         5.0: UINT_MAX32
         5.1: ULONG_MAX
         6.0: ULONG_MAX
      
      Note: testcase not attached
     @ myisam/myisamchk.c
        Bug#33785 - myisamchk show warning message
            
        Fixed the Max value for key_buffer_size, read_buffer_size, write_buffer_size and
        sort_buffer_size options
[14 Sep 2009 16:04] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (version source revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (merge vers: 5.4.4-alpha) (pib:11)
[15 Sep 2009 0:12] Meiji KIMURA
Does this patch apply for 5.4 only?

Is there any chance to apply to 5.1 (or 5.0). Many customer think this is a bug, so will send a bug report periodically....
[15 Sep 2009 4:47] Satya B
I have pushed the patch to 5.0,5.1 & 5.4 -bugteam trees but I think 5.4 was merged first to main trunk.

The fix will also be available in 5.0 & 5.1 when they are merged to main.
[23 Sep 2009 15:57] Paul DuBois
Noted in 5.4.4 changelog.

myisamchk performed parameter value casting at startup that generated
unnecessary warning messages. 

Setting report to NDI pending push into 5.0.x/5.1.x.
[6 Oct 2009 8:56] Bugs System
Pushed into 5.0.87 (revid:joro@sun.com-20091006073202-rj21ggvo2gw032ks) (version source revid:satya.bn@sun.com-20090903180442-sdmxit4819b28eyv) (merge vers: 5.0.86) (pib:11)
[6 Oct 2009 9:00] Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:mikael@mysql.com-20090907102257-fflwgm6rp5m5kmfw) (merge vers: 5.1.39) (pib:11)
[6 Oct 2009 22:56] Paul DuBois
Noted in 5.0.87, 5.1.40 changelogs.
[6 Oct 2009 23:05] Paul DuBois
This fix has been pushed into 5.4.3.
[18 Dec 2009 10:32] Bugs System
Pushed into 5.1.41-ndb-7.1.0 (revid:jonas@mysql.com-20091218102229-64tk47xonu3dv6r6) (version source revid:jonas@mysql.com-20091218095730-26gwjidfsdw45dto) (merge vers: 5.1.41-ndb-7.1.0) (pib:15)
[18 Dec 2009 10:48] Bugs System
Pushed into 5.1.41-ndb-6.2.19 (revid:jonas@mysql.com-20091218100224-vtzr0fahhsuhjsmt) (version source revid:jonas@mysql.com-20091217101452-qwzyaig50w74xmye) (merge vers: 5.1.41-ndb-6.2.19) (pib:15)
[18 Dec 2009 11:03] Bugs System
Pushed into 5.1.41-ndb-6.3.31 (revid:jonas@mysql.com-20091218100616-75d9tek96o6ob6k0) (version source revid:jonas@mysql.com-20091217154335-290no45qdins5bwo) (merge vers: 5.1.41-ndb-6.3.31) (pib:15)
[18 Dec 2009 11:17] Bugs System
Pushed into 5.1.41-ndb-7.0.11 (revid:jonas@mysql.com-20091218101303-ga32mrnr15jsa606) (version source revid:jonas@mysql.com-20091218064304-ezreonykd9f4kelk) (merge vers: 5.1.41-ndb-7.0.11) (pib:15)
[18 Dec 2009 13:22] MC Brown
Already noted in earlier changelogs.
[22 May 2011 8:26] Valeriy Kravchuk
Bug #61250 was marked as a duplicate of this one.