Commit 38f3b99d authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-8831 : enforce_storage_engine doesn't block table creation on other nodes

Check if the engine is supported/allowed before replicating the
statement.
parent accf9b56
#
# MDEV-8831 : enforce_storage_engine doesn't block table creation on
# other nodes (galera cluster)
#
SET @@enforce_storage_engine=INNODB;
CREATE TABLE t1(i INT) ENGINE=INNODB;
CREATE TABLE t2(i INT) ENGINE=MYISAM;
ERROR 42000: Unknown storage engine 'MyISAM'
INSERT INTO t1 VALUES(1);
SHOW TABLES;
Tables_in_test
t1
SELECT COUNT(*)=1 FROM t1;
COUNT(*)=1
1
CREATE TABLE t2(i INT) ENGINE=MYISAM;
SHOW TABLES;
Tables_in_test
t1
t2
DROP TABLE t1, t2;
# End of tests
--source include/galera_cluster.inc
--source include/have_innodb.inc
# enforce_storage_engine should prevent the creation of tables with
# non-enforced storage engines on the master node and the command
# should also not replicate to other nodes.
--echo #
--echo # MDEV-8831 : enforce_storage_engine doesn't block table creation on
--echo # other nodes (galera cluster)
--echo #
--connection node_1
SET @@enforce_storage_engine=INNODB;
CREATE TABLE t1(i INT) ENGINE=INNODB;
--error ER_UNKNOWN_STORAGE_ENGINE
CREATE TABLE t2(i INT) ENGINE=MYISAM;
INSERT INTO t1 VALUES(1);
--connection node_2
SHOW TABLES;
SELECT COUNT(*)=1 FROM t1;
CREATE TABLE t2(i INT) ENGINE=MYISAM;
--connection node_1
SHOW TABLES;
# Cleanup
DROP TABLE t1, t2;
--echo # End of tests
......@@ -3440,11 +3440,16 @@ mysql_execute_command(THD *thd)
}
else
{
/* in STATEMENT format, we probably have to replicate also temporary
tables, like mysql replication does
/*
In STATEMENT format, we probably have to replicate also temporary
tables, like mysql replication does. Also check if the requested
engine is allowed/supported.
*/
if (WSREP(thd) && (!thd->is_current_stmt_binlog_format_row() ||
!create_info.tmp_table()))
if (WSREP(thd) &&
!check_engine(thd, create_table->db, create_table->table_name,
&create_info) &&
(!thd->is_current_stmt_binlog_format_row() ||
!create_info.tmp_table()))
{
WSREP_TO_ISOLATION_BEGIN(create_table->db, create_table->table_name, NULL)
}
......
......@@ -72,7 +72,6 @@ static int copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
Alter_table_ctx *alter_ctx);
static bool prepare_blob_field(THD *thd, Create_field *sql_field);
static bool check_engine(THD *, const char *, const char *, HA_CREATE_INFO *);
static int mysql_prepare_create_table(THD *, HA_CREATE_INFO *, Alter_info *,
uint *, handler *, KEY **, uint *, int);
static uint blob_length_by_type(enum_field_types type);
......@@ -9816,8 +9815,8 @@ err:
@retval true Engine not available/supported, error has been reported.
@retval false Engine available/supported.
*/
static bool check_engine(THD *thd, const char *db_name,
const char *table_name, HA_CREATE_INFO *create_info)
bool check_engine(THD *thd, const char *db_name,
const char *table_name, HA_CREATE_INFO *create_info)
{
DBUG_ENTER("check_engine");
handlerton **new_engine= &create_info->db_type;
......
......@@ -284,4 +284,6 @@ uint explain_filename(THD* thd, const char *from, char *to, uint to_length,
extern MYSQL_PLUGIN_IMPORT const char *primary_key_name;
extern mysql_mutex_t LOCK_gdl;
bool check_engine(THD *, const char *, const char *, HA_CREATE_INFO *);
#endif /* SQL_TABLE_INCLUDED */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment