Bug #72033 No warning when setting KEY_BLOCK_SIZE on a MyISAM index, value silently ignored

Submitted: 13 Mar 2014 14:50 Modified: 14 Mar 2014 6:12
Reporter: Hartmut Holzgraefe Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:5.6.18 OS:Any
Assigned to: CPU Architecture:Any

[13 Mar 2014 14:50] Hartmut Holzgraefe
Description:
With InnoDB I'm getting a warning when using key_block_size=... in a situation where it isn't supported:

  mysql> create table t1 (id int primary key, i int, key(i)) 
           engine=innodb   key_block_size=4;
  Query OK, 0 rows affected, 2 warnings (0.85 sec)

  mysql> show warnings;
  | Warning | 1478 | InnoDB: KEY_BLOCK_SIZE requires innodb_file_format > Antelope. |
  | Warning | 1478 | InnoDB: ignoring 

With MyISAM (or actually any non-InnoDB engine?) there is no such warning:

  mysql> create table t2 (id int primary key, i int, key(i)) engine=myisam key_block_size=4;
  Query OK, 0 rows affected (0.05 sec)

  mysql> create table t3 (id int primary key, i int, key(i)) engine=memory key_block_size=4;
  Query OK, 0 rows affected (0.62 sec)

With engine=memory the table default and per-index values are preserved, but probably not used in any meaningful way.

With engine=MyISAM the per-index value defaults to 1024 (1MB?) instead:

  mysql> show create table t2\G
  *************************** 1. row ***************************
         Table: t2
  Create Table: CREATE TABLE `t2` (
    `id` int(11) NOT NULL,
    `i` int(11) DEFAULT NULL,
    PRIMARY KEY (`id`) KEY_BLOCK_SIZE=1024,
    KEY `i` (`i`) KEY_BLOCK_SIZE=1024
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=4
  1 row in set (0.00 sec)

And even when trying to explicitly set a different value key_block_size will stay as 1024, without any error or warning:

  mysql> alter table t2 add column j int, add key (j) key_block_size=4;
  Query OK, 0 rows affected (0.05 sec)
  Records: 0  Duplicates: 0  Warnings: 0

  mysql> show create table t2\G
  *************************** 1. row ***************************
         Table: t2
  Create Table: CREATE TABLE `t2` (
    `id` int(11) NOT NULL,
    `i` int(11) DEFAULT NULL,
    `j` int(11) DEFAULT NULL,
    PRIMARY KEY (`id`) KEY_BLOCK_SIZE=1024,
    KEY `i` (`i`) KEY_BLOCK_SIZE=1024,
    KEY `j` (`j`) KEY_BLOCK_SIZE=1024
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=4 
  1 row in set (0.00 sec)

How to repeat:
See embedded statements and results above

Suggested fix:
Raise "key_block_size ignored" warnings when used with engines that don't actually support it ...
[14 Mar 2014 6:12] MySQL Verification Team
Hello Hartmut,

Thank you for the bug report and test case.
Verified as described.

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.046 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.