Skip to content

Commit

Permalink
MDEV-18788 Live upgrade from MySQL 5.6/5.7 to MariaDB 10.4 fails with…
Browse files Browse the repository at this point in the history
… "Event Scheduler: An error occurred when initializing system tables"

if columns or indexes are modified/renamed/dropped in an ALTER TABLE,
stat tables must be updated accordingly (e.g. all statistics for a column
should be dropped). But if a stat table doesn't exist, it's not a reason
to fail the whole ALTER TABLE operation - such an error should be ignored.
  • Loading branch information
vuvova committed Jun 7, 2019
1 parent 06291c3 commit 973b281
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions mysql-test/main/stat_tables_missing.result
@@ -0,0 +1,11 @@
create table t1 (a int);
alter table mysql.column_stats rename to mysql.column_stats1;
flush tables;
alter table t1 change a b varchar(100);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`b` varchar(100) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table mysql.column_stats1 rename to mysql.column_stats;
drop table t1;
10 changes: 10 additions & 0 deletions mysql-test/main/stat_tables_missing.test
@@ -0,0 +1,10 @@
#
# MDEV-18788 Live upgrade from MySQL 5.6/5.7 to MariaDB 10.4 fails with "Event Scheduler: An error occurred when initializing system tables"
#
create table t1 (a int);
alter table mysql.column_stats rename to mysql.column_stats1;
flush tables;
alter table t1 change a b varchar(100);
show create table t1;
alter table mysql.column_stats1 rename to mysql.column_stats;
drop table t1;
6 changes: 5 additions & 1 deletion sql/sql_statistics.cc
Expand Up @@ -273,7 +273,11 @@ static inline int open_stat_table_for_ddl(THD *thd, TABLE_LIST *table,
Open_tables_backup *backup)
{
table->init_one_table(&MYSQL_SCHEMA_NAME, stat_tab_name, NULL, TL_WRITE);
return open_system_tables_for_read(thd, table, backup);
No_such_table_error_handler nst_handler;
thd->push_internal_handler(&nst_handler);
int res= open_system_tables_for_read(thd, table, backup);
thd->pop_internal_handler();
return res;
}


Expand Down

0 comments on commit 973b281

Please sign in to comment.