1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

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)
This commit is contained in:
Sergei Golubchik
2019-03-13 12:42:42 +01:00
parent 96f8793a7a
commit 23a7693a68
3 changed files with 31 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
execute stmt;
# update table_name and timestamp fields in the innodb stat tables # 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 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"); alter table innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199);
prepare stmt from @str;
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)"; 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=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 '';