MDEV-14990 mysql_upgrade fails with ERROR 1408 (HY000) at line 566: Event Scheduler: An error occurred when initializing system tables

Don't check mysql.db and mysql.user from event schedule on startup.

Event schedule should only check its own mysql.event table, it has
no business checking other system tables. In particular, it's ridiculous
for event schedule to fail when privilege tables are not the newest,
because sql_acl.cc supports old privilege tables just fine.
This commit is contained in:
Sergei Golubchik 2018-02-13 00:23:57 +01:00
parent f7621f17bd
commit 3c87973235
4 changed files with 5 additions and 161 deletions

View file

@ -581,7 +581,7 @@ CREATE USER 'user3'@'%';
GRANT USAGE ON *.* TO 'user3'@'%';
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
alter table mysql.user drop column Delete_history_priv;
flush privileges;
alter table mysql.db drop column Delete_history_priv;
Run mysql_upgrade with all privileges on a user
flush privileges;
SHOW GRANTS FOR 'user3'@'%';
@ -589,3 +589,4 @@ Grants for user3@%
GRANT USAGE ON *.* TO 'user3'@'%'
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
DROP USER 'user3'@'%';
update mysql.db set Delete_history_priv='Y' where db like 'test%';

View file

@ -232,10 +232,12 @@ CREATE USER 'user3'@'%';
GRANT USAGE ON *.* TO 'user3'@'%';
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
alter table mysql.user drop column Delete_history_priv;
flush privileges;
alter table mysql.db drop column Delete_history_priv;
--source include/restart_mysqld.inc
--echo Run mysql_upgrade with all privileges on a user
--exec $MYSQL_UPGRADE --force --silent 2>&1
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info
flush privileges;
SHOW GRANTS FOR 'user3'@'%';
DROP USER 'user3'@'%';
update mysql.db set Delete_history_priv='Y' where db like 'test%';

View file

@ -1186,46 +1186,9 @@ Event_db_repository::check_system_tables(THD *thd)
{
TABLE_LIST tables;
int ret= FALSE;
const unsigned int event_priv_column_position= 29;
DBUG_ENTER("Event_db_repository::check_system_tables");
DBUG_PRINT("enter", ("thd: %p", thd));
/* Check mysql.db */
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_DB_NAME, 0, TL_READ);
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{
ret= 1;
sql_print_error("Cannot open mysql.db");
}
else
{
if (table_intact.check(tables.table, &mysql_db_table_def))
ret= 1;
close_mysql_tables(thd);
}
/* Check mysql.user */
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_USER_NAME, 0, TL_READ);
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
{
ret= 1;
sql_print_error("Cannot open mysql.user");
}
else
{
if (tables.table->s->fields < event_priv_column_position ||
strncmp(tables.table->field[event_priv_column_position]->field_name.str,
STRING_WITH_LEN("Event_priv")))
{
sql_print_error("mysql.user has no `Event_priv` column at position %d",
event_priv_column_position);
ret= 1;
}
close_mysql_tables(thd);
}
/* Check mysql.event */
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, TL_READ);

View file

@ -59,128 +59,6 @@
bool mysql_user_table_is_in_short_password_format= false;
static const
TABLE_FIELD_TYPE mysql_db_table_fields[MYSQL_DB_FIELD_COUNT] = {
{
{ STRING_WITH_LEN("Host") },
{ STRING_WITH_LEN("char(60)") },
{NULL, 0}
},
{
{ STRING_WITH_LEN("Db") },
{ STRING_WITH_LEN("char(64)") },
{NULL, 0}
},
{
{ STRING_WITH_LEN("User") },
{ STRING_WITH_LEN("char(") },
{NULL, 0}
},
{
{ STRING_WITH_LEN("Select_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Insert_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Update_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Delete_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Create_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Drop_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Grant_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("References_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Index_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Alter_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Create_tmp_table_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Lock_tables_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Create_view_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Show_view_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Create_routine_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Alter_routine_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Execute_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Event_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Trigger_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
},
{
{ STRING_WITH_LEN("Truncate_versioning_priv") },
{ STRING_WITH_LEN("enum('N','Y')") },
{ STRING_WITH_LEN("utf8") }
}
};
const TABLE_FIELD_DEF
mysql_db_table_def= {MYSQL_DB_FIELD_COUNT, mysql_db_table_fields, 0, (uint*) 0 };
static LEX_CSTRING native_password_plugin_name= {
STRING_WITH_LEN("mysql_native_password")
};