From f43d6c2b738b12b7ff20fb6558c8b99c13d447fc Mon Sep 17 00:00:00 2001 From: Magne Mahre <magne.mahre@sun.com> Date: Thu, 16 Sep 2010 12:51:08 +0200 Subject: [PATCH] Bug #54606 innodb fast alter table + pack_keys=0 prevents adding new indexes A fast alter table requires that the existing (old) table and indices are unchanged (i.e only new indices can be added). To verify this, the layout and flags of the old table/indices are compared for equality with the new. The PACK_KEYS option is a no-op in InnoDB, but the flag exists, and is used in the table compare. We need to check this (table) option flag before deciding whether an index should be packed or not. If the table has explicitly set PACK_KEYS to 0, the created indices should not be marked as packed/packable. --- .../suite/innodb_plugin/r/innodb_mysql.result | 10 ++++++++++ mysql-test/suite/innodb_plugin/t/innodb_mysql.test | 14 ++++++++++++++ sql/sql_table.cc | 1 + 3 files changed, 25 insertions(+) diff --git a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result index b4ac88fc1c3..54a8854ecaf 100644 --- a/mysql-test/suite/innodb_plugin/r/innodb_mysql.result +++ b/mysql-test/suite/innodb_plugin/r/innodb_mysql.result @@ -2390,4 +2390,14 @@ a 2 UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1; DROP TABLE t1,t2; +# +# Bug#54606 innodb fast alter table + pack_keys=0 +# prevents adding new indexes +# +CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) +ENGINE=InnoDB +PACK_KEYS=0; +CREATE INDEX a ON t1 (a); +CREATE INDEX c on t1 (c); +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test index 3f6d9d96bb8..3d078062d43 100644 --- a/mysql-test/suite/innodb_plugin/t/innodb_mysql.test +++ b/mysql-test/suite/innodb_plugin/t/innodb_mysql.test @@ -632,4 +632,18 @@ UPDATE t1,t2 SET t1.a = t1.a + 100 WHERE t1.a = 1; DROP TABLE t1,t2; +--echo # +--echo # Bug#54606 innodb fast alter table + pack_keys=0 +--echo # prevents adding new indexes +--echo # + +CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) + ENGINE=InnoDB + PACK_KEYS=0; +CREATE INDEX a ON t1 (a); +CREATE INDEX c on t1 (c); + +DROP TABLE t1; + + --echo End of 5.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d3ac2bf0f95..7a7446c7f79 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3325,6 +3325,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_part_info->length=(uint16) length; /* Use packed keys for long strings on the first column */ if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) && + !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) && (length >= KEY_DEFAULT_PACK_LENGTH && (sql_field->sql_type == MYSQL_TYPE_STRING || sql_field->sql_type == MYSQL_TYPE_VARCHAR || -- 2.30.9