From 9b577edd50e29452c0ac58d3c73a871dc20dc37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Sat, 12 Sep 2015 13:16:05 +0300 Subject: MDEV-8577: With enforce-storage-engine mysql_upgrade corrupts the schema: ALTER TABLE should either bypass enforce-storage-engine, or mysql_upgrade should refuse to run Allow user to alter contents of existing table without enforcing storage engine. However, enforce storage engine on ALTER TABLE x ENGINE=y; --- sql/sql_table.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sql/sql_table.cc') diff --git a/sql/sql_table.cc b/sql/sql_table.cc index da7d144f3d8..61120970ecb 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9818,14 +9818,21 @@ static bool check_engine(THD *thd, const char *db_name, DBUG_ENTER("check_engine"); handlerton **new_engine= &create_info->db_type; handlerton *req_engine= *new_engine; - handlerton *enf_engine= thd->variables.enforced_table_plugin ? - plugin_hton(thd->variables.enforced_table_plugin) : NULL; + handlerton *enf_engine= NULL; bool no_substitution= thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION; *new_engine= ha_checktype(thd, req_engine, no_substitution); DBUG_ASSERT(*new_engine); if (!*new_engine) DBUG_RETURN(true); + /* Enforced storage engine should not be used in + ALTER TABLE that does not use explicit ENGINE = x to + avoid unwanted unrelated changes.*/ + if (!(thd->lex->sql_command == SQLCOM_ALTER_TABLE && + !(create_info->used_fields & HA_CREATE_USED_ENGINE))) + enf_engine= thd->variables.enforced_table_plugin ? + plugin_hton(thd->variables.enforced_table_plugin) : NULL; + if (enf_engine && enf_engine != *new_engine) { if (no_substitution) -- cgit v1.2.1