diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 9ba5344fad0..565423be624 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -464,4 +464,25 @@ even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@loca even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost DROP USER very_long_user_name_number_1, very_long_user_name_number_2, even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost; DROP PROCEDURE test.pr; -End of tests +use test; +alter table mysql.innodb_table_stats modify last_update int not null; +create table extralongname_extralongname_extralongname_extralongname_ext ( +id int(10) unsigned not null, +created_date date not null, +created timestamp not null, +primary key (created,id,created_date) +) engine=innodb stats_persistent=1 default charset=latin1 +partition by range (year(created_date)) +subpartition by hash (month(created_date)) +subpartitions 2 ( +partition p2007 values less than (2008), +partition p2008 values less than (2009) +); +select length(table_name) from mysql.innodb_table_stats; +length(table_name) +79 +79 +79 +79 +drop table extralongname_extralongname_extralongname_extralongname_ext; +End of 10.0 tests diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 2ef469ba7c5..f8026df8770 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -1,6 +1,7 @@ -- source include/mysql_upgrade_preparation.inc -- source include/have_working_dns.inc -- source include/have_innodb.inc +-- source include/have_partition.inc # # Basic test that we can run mysql_upgrde and that it finds the @@ -166,4 +167,26 @@ SELECT grantor FROM mysql.tables_priv WHERE db = 'mysql' AND table_name = 'user' DROP USER very_long_user_name_number_1, very_long_user_name_number_2, even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost; DROP PROCEDURE test.pr; ---echo End of tests +# +# MDEV-13274 mysql_upgrade fails if dbname+tablename+partioname > 64 chars +# +use test; +alter table mysql.innodb_table_stats modify last_update int not null; + +create table extralongname_extralongname_extralongname_extralongname_ext ( + id int(10) unsigned not null, + created_date date not null, + created timestamp not null, + primary key (created,id,created_date) +) engine=innodb stats_persistent=1 default charset=latin1 + partition by range (year(created_date)) + subpartition by hash (month(created_date)) + subpartitions 2 ( + partition p2007 values less than (2008), + partition p2008 values less than (2009) + ); +--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1 +select length(table_name) from mysql.innodb_table_stats; +drop table extralongname_extralongname_extralongname_extralongname_ext; + +--echo End of 10.0 tests diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index f034af4f898..1bb601ef5f9 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -667,6 +667,15 @@ DROP PROCEDURE mysql.count_duplicate_host_names; # Convering the host name to lower case for existing users UPDATE user SET host=LOWER( host ) WHERE LOWER( host ) <> host; +# fix bad data when upgrading from unfixed InnoDB (MDEV-13360) +set @str="delete from innodb_index_stats where length(table_name) > 64"; +set @str=if(@have_innodb <> 0, @str, "set @dummy = 0"); +prepare stmt from @str; +execute stmt; +set @str=replace(@str, "innodb_index_stats", "innodb_table_stats"); +prepare stmt from @str; +execute stmt; + # update timestamp fields in the innodb stat tables set @str="alter table mysql.innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp"; set @str=if(@have_innodb <> 0, @str, "set @dummy = 0");