summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2015-09-12 13:16:05 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2015-09-12 13:16:05 +0300
commit9b577edd50e29452c0ac58d3c73a871dc20dc37a (patch)
tree981a1035ff0aa4fc7de363023307735fcd54a745 /sql/sql_table.cc
parent1e9ab68e4a5944ff90b8652f5225a8a7b594753a (diff)
downloadmariadb-git-9b577edd50e29452c0ac58d3c73a871dc20dc37a.tar.gz
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;
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc11
1 files changed, 9 insertions, 2 deletions
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)