Commit 23a7693a authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-18275 Live upgrade from 5.5 does not work: InnoDB stat tables are used before creation

let mysql_upgrade to work even when innodb_index_stats or
innodb_table_stats are missing.

(mysql_upgrade knows to ignore "unknown table" errors)
parent 96f8793a
...@@ -624,3 +624,9 @@ connection default; ...@@ -624,3 +624,9 @@ connection default;
drop user user3@localhost; drop user user3@localhost;
drop table mysql.global_priv; drop table mysql.global_priv;
rename table mysql.global_priv_bak to mysql.global_priv; rename table mysql.global_priv_bak to mysql.global_priv;
drop view mysql.user_bak;
drop table mysql.innodb_index_stats, mysql.innodb_table_stats;
# mysql_upgrade --force --silent 2>&1
drop table mysql.global_priv;
rename table mysql.global_priv_bak to mysql.global_priv;
# End of 10.4 tests
...@@ -269,3 +269,17 @@ connection default; ...@@ -269,3 +269,17 @@ connection default;
drop user user3@localhost; drop user user3@localhost;
drop table mysql.global_priv; drop table mysql.global_priv;
rename table mysql.global_priv_bak to mysql.global_priv; rename table mysql.global_priv_bak to mysql.global_priv;
#
# MDEV-18275 Live upgrade from 5.5 does not work: InnoDB stat tables are used before creation
#
--source include/switch_to_mysql_user.inc
drop view mysql.user_bak;
drop table mysql.innodb_index_stats, mysql.innodb_table_stats;
--echo # mysql_upgrade --force --silent 2>&1
--exec $MYSQL_UPGRADE --force --silent 2>&1
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
drop table mysql.global_priv;
rename table mysql.global_priv_bak to mysql.global_priv;
--echo # End of 10.4 tests
...@@ -670,35 +670,19 @@ SHOW WARNINGS; ...@@ -670,35 +670,19 @@ SHOW WARNINGS;
# Convering the host name to lower case for existing users # Convering the host name to lower case for existing users
UPDATE user SET host=LOWER( host ) WHERE LOWER( host ) <> host; UPDATE user SET host=LOWER( host ) WHERE LOWER( host ) <> host;
# fix bad data when upgrading from unfixed InnoDB (MDEV-13360) DELIMITER //
set @str="delete from innodb_index_stats where length(table_name) > 64"; if @have_innodb then
set @str=if(@have_innodb <> 0, @str, "set @dummy = 0"); # fix bad data when upgrading from unfixed InnoDB (MDEV-13360)
prepare stmt from @str; delete from innodb_index_stats where length(table_name) > 64;
execute stmt; delete from innodb_table_stats where length(table_name) > 64;
set @str=replace(@str, "innodb_index_stats", "innodb_table_stats");
prepare stmt from @str; # update table_name and timestamp fields in the innodb stat tables
execute stmt; alter table innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199);
alter table innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199);
# update table_name and 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, modify table_name varchar(199)"; alter table innodb_index_stats drop foreign key if exists innodb_index_stats_ibfk_1;
set @str=if(@have_innodb <> 0, @str, "set @dummy = 0"); end if //
prepare stmt from @str; DELIMITER ;
execute stmt;
set @str="alter table mysql.innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199)";
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;
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;
# MDEV-4332 longer user names # MDEV-4332 longer user names
alter table user modify User char(80) binary not null default ''; alter table user modify User char(80) binary not null default '';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment