From 66612e8fd32761bf27586c03e4f28a5ac1472503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 20 Nov 2013 14:28:07 +0200 Subject: [PATCH] MDEV-5010: InnoDB errors appearing in logs with upgrade from 10.0.0 to 10.0.4. Analysis: In earlier MySQL 5.6 versions this table innodb_index_stats used to have a foreign key referencing to innodb_table_stats. However, in newer MySQL 5.6 versions this foreign key is removed and if you upgrade, your innodb_table_stats is created by the earlier mariadb version, thus a newer version will complain that the table is incorrectly defined. Added drop foreign key on mysql_system_tables_fix.sql to be executed on mysql_upgrade. --- scripts/mysql_system_tables_fix.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 768d60f9af9..f444df60a83 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -664,5 +664,12 @@ alter table tables_priv modify Grantor char(141) COLLATE utf8_bin not null # This should not be needed, but gives us some extra testing that the above # changes was correct +set @have_innodb= (select count(engine) from information_schema.engines where engine='INNODB' and support != 'NO'); +SET @innodb_index_stats_fk= (select count(*) from information_schema.referential_constraints where constraint_schema='mysql' and table_name = 'innodb_index_stats' and referenced_table_name = 'innodb_table_stats' and constraint_name = 'innodb_index_stats_ibfk_1'); +SET @str=IF(@innodb_index_stats_fk > 0 and @have_innodb > 0, "ALTER TABLE mysql.innodb_index_stats DROP FOREIGN KEY `innodb_index_stats_ibfk_1`", "SET @dummy = 0"); +PREPARE stmt FROM @str; +EXECUTE stmt; +DROP PREPARE stmt; + flush privileges;