1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-21618 CREATE UNIQUE INDEX fails with "ERROR 1286 (42000): Unknown storage engine 'partition'"

The server doesn't use the enforced storage engine in ALTER TABLE
without ENGINE clause to avoid an unwanted engine change.

However, the server tries to use the enforced engine in CREATE
INDEX. As a result, the false positive error is raised. The server
should not apply the enforced engine in CREATE INDEX too.
This commit is contained in:
Nayuta Yanagisawa
2022-03-31 22:38:54 +09:00
committed by Alexey Botchkov
parent 2c1345ab27
commit 4cf3a1b1ad
3 changed files with 32 additions and 9 deletions

View File

@ -11528,13 +11528,18 @@ bool check_engine(THD *thd, const char *db_name,
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;
/*
Enforced storage engine should not be used in ALTER TABLE that does not
use explicit ENGINE = x to avoid unwanted unrelated changes. It should not
be used in CREATE INDEX too.
*/
if (!((thd->lex->sql_command == SQLCOM_ALTER_TABLE &&
!(create_info->used_fields & HA_CREATE_USED_ENGINE)) ||
thd->lex->sql_command == SQLCOM_CREATE_INDEX))
{
plugin_ref enf_plugin= thd->variables.enforced_table_plugin;
enf_engine= enf_plugin ? plugin_hton(enf_plugin) : NULL;
}
if (enf_engine && enf_engine != *new_engine)
{