From: Date: October 2 2008 9:35am Subject: bzr commit into mysql-5.1 branch (Sergey.Glukhov:2754) Bug#39372 List-Archive: http://lists.mysql.com/commits/55000 X-Bug: 39372 Message-Id: <0K83004YKP3MIB10@fe-emea-09.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT #At file:///home/gluh/MySQL/mysql-5.1-bug-39372/ 2754 Sergey Glukhov 2008-10-02 Bug#39372 "Smart" ALTER TABLE not so smart after all. The problem was that PACK_KEYS clause in ALTER TABLE did not trigger table reconstruction. The fix is to rebuild a table if PACK_KEYS is specified. modified: mysql-test/r/alter_table.result mysql-test/t/alter_table.test sql/sql_table.cc per-file messages: mysql-test/r/alter_table.result test result mysql-test/t/alter_table.test test case sql/sql_table.cc The problem was that PACK_KEYS clause in ALTER TABLE did not trigger table reconstruction. The fix is to rebuild a table if PACK_KEYS is specified. === modified file 'mysql-test/r/alter_table.result' --- a/mysql-test/r/alter_table.result 2008-06-17 14:12:21 +0000 +++ b/mysql-test/r/alter_table.result 2008-10-02 07:35:18 +0000 @@ -1222,4 +1222,14 @@ ALTER TABLE t1 CHANGE d c varchar(10); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t1; +create table t1(f1 int not null, f2 int not null, key (f1), key (f2)); +select index_length into @unpaked_keys_size from +information_schema.tables where table_name='t1'; +alter table t1 pack_keys=1; +select index_length into @paked_keys_size from +information_schema.tables where table_name='t1'; +select (@unpaked_keys_size > @paked_keys_size); +(@unpaked_keys_size > @paked_keys_size) +1 +drop table t1; End of 5.1 tests === modified file 'mysql-test/t/alter_table.test' --- a/mysql-test/t/alter_table.test 2008-06-17 14:12:21 +0000 +++ b/mysql-test/t/alter_table.test 2008-10-02 07:35:18 +0000 @@ -947,4 +947,26 @@ ALTER TABLE t1 CHANGE d c varchar(10); --disable_info DROP TABLE t1; +# +# Bug#39372 "Smart" ALTER TABLE not so smart after all. +# +create table t1(f1 int not null, f2 int not null, key (f1), key (f2)); +let $count= 50; +--disable_query_log +while ($count) +{ + EVAL insert into t1 values (1,1),(1,1),(1,1),(1,1),(1,1); + EVAL insert into t1 values (2,2),(2,2),(2,2),(2,2),(2,2); + dec $count ; +} +--enable_query_log + +select index_length into @unpaked_keys_size from +information_schema.tables where table_name='t1'; +alter table t1 pack_keys=1; +select index_length into @paked_keys_size from +information_schema.tables where table_name='t1'; +select (@unpaked_keys_size > @paked_keys_size); +drop table t1; + --echo End of 5.1 tests === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2008-09-15 09:19:56 +0000 +++ b/sql/sql_table.cc 2008-10-02 07:35:18 +0000 @@ -5279,6 +5279,7 @@ compare_tables(TABLE *table, create_info->used_fields & HA_CREATE_USED_CHARSET || create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET || create_info->used_fields & HA_CREATE_USED_ROW_FORMAT || + create_info->used_fields & HA_CREATE_USED_PACK_KEYS || (alter_info->flags & (ALTER_RECREATE | ALTER_FOREIGN_KEY)) || order_num || !table->s->mysql_version ||