Commit 1841ef1c authored by sjaakola's avatar sjaakola Committed by Jan Lindström

MW-416

Moved TOI replication to happen after ACL checking for commands:
SQLCOM_CREATE_EVENT
SQLCOM_ALTER_EVENT
SQLCOM_DROP_EVENT
SQLCOM_CREATE_VIEW
SQLCOM_CREATE_TRIGGER
SQLCOM_DROP_TRIGGER
SQLCOM_INSTALL_PLUGIN
SQLCOM_UNINSTALL_PLUGIN
parent e1d9a237
...@@ -334,6 +334,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data) ...@@ -334,6 +334,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (lock_object_name(thd, MDL_key::EVENT, if (lock_object_name(thd, MDL_key::EVENT,
parse_data->dbname.str, parse_data->name.str)) parse_data->dbname.str, parse_data->name.str))
...@@ -416,6 +417,10 @@ Events::create_event(THD *thd, Event_parse_data *parse_data) ...@@ -416,6 +417,10 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
thd->restore_stmt_binlog_format(save_binlog_format); thd->restore_stmt_binlog_format(save_binlog_format);
DBUG_RETURN(ret); DBUG_RETURN(ret);
#ifdef WITH_WSREP
error:
DBUG_RETURN(true);
#endif /* WITH_WSREP */
} }
...@@ -456,6 +461,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, ...@@ -456,6 +461,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0)) if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (lock_object_name(thd, MDL_key::EVENT, if (lock_object_name(thd, MDL_key::EVENT,
parse_data->dbname.str, parse_data->name.str)) parse_data->dbname.str, parse_data->name.str))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
...@@ -540,6 +548,10 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, ...@@ -540,6 +548,10 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
thd->restore_stmt_binlog_format(save_binlog_format); thd->restore_stmt_binlog_format(save_binlog_format);
DBUG_RETURN(ret); DBUG_RETURN(ret);
#ifdef WITH_WSREP
error:
DBUG_RETURN(TRUE);
#endif /* WITH_WSREP */
} }
...@@ -580,6 +592,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) ...@@ -580,6 +592,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
/* /*
Turn off row binlogging of this statement and use statement-based so Turn off row binlogging of this statement and use statement-based so
that all supporting tables are updated for DROP EVENT command. that all supporting tables are updated for DROP EVENT command.
...@@ -601,6 +615,10 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) ...@@ -601,6 +615,10 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
thd->restore_stmt_binlog_format(save_binlog_format); thd->restore_stmt_binlog_format(save_binlog_format);
DBUG_RETURN(ret); DBUG_RETURN(ret);
#ifdef WITH_WSREP
error:
DBUG_RETURN(TRUE);
#endif
} }
......
...@@ -5072,7 +5072,6 @@ mysql_execute_command(THD *thd) ...@@ -5072,7 +5072,6 @@ mysql_execute_command(THD *thd)
if (res) if (res)
break; break;
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
switch (lex->sql_command) { switch (lex->sql_command) {
case SQLCOM_CREATE_EVENT: case SQLCOM_CREATE_EVENT:
{ {
...@@ -5106,7 +5105,6 @@ mysql_execute_command(THD *thd) ...@@ -5106,7 +5105,6 @@ mysql_execute_command(THD *thd)
lex->spname->m_name); lex->spname->m_name);
break; break;
case SQLCOM_DROP_EVENT: case SQLCOM_DROP_EVENT:
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (!(res= Events::drop_event(thd, if (!(res= Events::drop_event(thd,
lex->spname->m_db, lex->spname->m_name, lex->spname->m_db, lex->spname->m_name,
lex->if_exists()))) lex->if_exists())))
...@@ -6019,7 +6017,6 @@ mysql_execute_command(THD *thd) ...@@ -6019,7 +6017,6 @@ mysql_execute_command(THD *thd)
Note: SQLCOM_CREATE_VIEW also handles 'ALTER VIEW' commands Note: SQLCOM_CREATE_VIEW also handles 'ALTER VIEW' commands
as specified through the thd->lex->create_view_mode flag. as specified through the thd->lex->create_view_mode flag.
*/ */
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
res= mysql_create_view(thd, first_table, thd->lex->create_view_mode); res= mysql_create_view(thd, first_table, thd->lex->create_view_mode);
break; break;
} }
...@@ -6035,7 +6032,6 @@ mysql_execute_command(THD *thd) ...@@ -6035,7 +6032,6 @@ mysql_execute_command(THD *thd)
case SQLCOM_CREATE_TRIGGER: case SQLCOM_CREATE_TRIGGER:
{ {
/* Conditionally writes to binlog. */ /* Conditionally writes to binlog. */
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
res= mysql_create_or_drop_trigger(thd, all_tables, 1); res= mysql_create_or_drop_trigger(thd, all_tables, 1);
break; break;
...@@ -6043,7 +6039,6 @@ mysql_execute_command(THD *thd) ...@@ -6043,7 +6039,6 @@ mysql_execute_command(THD *thd)
case SQLCOM_DROP_TRIGGER: case SQLCOM_DROP_TRIGGER:
{ {
/* Conditionally writes to binlog. */ /* Conditionally writes to binlog. */
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
res= mysql_create_or_drop_trigger(thd, all_tables, 0); res= mysql_create_or_drop_trigger(thd, all_tables, 0);
break; break;
} }
...@@ -6108,13 +6103,11 @@ mysql_execute_command(THD *thd) ...@@ -6108,13 +6103,11 @@ mysql_execute_command(THD *thd)
my_ok(thd); my_ok(thd);
break; break;
case SQLCOM_INSTALL_PLUGIN: case SQLCOM_INSTALL_PLUGIN:
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (! (res= mysql_install_plugin(thd, &thd->lex->comment, if (! (res= mysql_install_plugin(thd, &thd->lex->comment,
&thd->lex->ident))) &thd->lex->ident)))
my_ok(thd); my_ok(thd);
break; break;
case SQLCOM_UNINSTALL_PLUGIN: case SQLCOM_UNINSTALL_PLUGIN:
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (! (res= mysql_uninstall_plugin(thd, &thd->lex->comment, if (! (res= mysql_uninstall_plugin(thd, &thd->lex->comment,
&thd->lex->ident))) &thd->lex->ident)))
my_ok(thd); my_ok(thd);
......
...@@ -2122,12 +2122,16 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, ...@@ -2122,12 +2122,16 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
bool error; bool error;
int argc=orig_argc; int argc=orig_argc;
char **argv=orig_argv; char **argv=orig_argv;
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
DBUG_ENTER("mysql_install_plugin"); DBUG_ENTER("mysql_install_plugin");
tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
/* need to open before acquiring LOCK_plugin or it will deadlock */ /* need to open before acquiring LOCK_plugin or it will deadlock */
if (! (table = open_ltable(thd, &tables, TL_WRITE, if (! (table = open_ltable(thd, &tables, TL_WRITE,
MYSQL_LOCK_IGNORE_TIMEOUT))) MYSQL_LOCK_IGNORE_TIMEOUT)))
...@@ -2160,8 +2164,6 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, ...@@ -2160,8 +2164,6 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
See also mysql_uninstall_plugin() and initialize_audit_plugin() See also mysql_uninstall_plugin() and initialize_audit_plugin()
*/ */
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
if (mysql_audit_general_enabled()) if (mysql_audit_general_enabled())
mysql_audit_acquire_plugins(thd, event_class_mask); mysql_audit_acquire_plugins(thd, event_class_mask);
...@@ -2193,6 +2195,10 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, ...@@ -2193,6 +2195,10 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
if (argv) if (argv)
free_defaults(argv); free_defaults(argv);
DBUG_RETURN(error); DBUG_RETURN(error);
#ifdef WITH_WSREP
error:
DBUG_RETURN(TRUE);
#endif /* WITH_WSREP */
} }
...@@ -2259,6 +2265,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, ...@@ -2259,6 +2265,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
TABLE_LIST tables; TABLE_LIST tables;
LEX_STRING dl= *dl_arg; LEX_STRING dl= *dl_arg;
bool error= false; bool error= false;
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
DBUG_ENTER("mysql_uninstall_plugin"); DBUG_ENTER("mysql_uninstall_plugin");
tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
...@@ -2266,6 +2274,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, ...@@ -2266,6 +2274,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
/* need to open before acquiring LOCK_plugin or it will deadlock */ /* need to open before acquiring LOCK_plugin or it will deadlock */
if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
...@@ -2291,8 +2301,6 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, ...@@ -2291,8 +2301,6 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
See also mysql_install_plugin() and initialize_audit_plugin() See also mysql_install_plugin() and initialize_audit_plugin()
*/ */
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
if (mysql_audit_general_enabled()) if (mysql_audit_general_enabled())
mysql_audit_acquire_plugins(thd, event_class_mask); mysql_audit_acquire_plugins(thd, event_class_mask);
...@@ -2323,6 +2331,10 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name, ...@@ -2323,6 +2331,10 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
mysql_mutex_unlock(&LOCK_plugin); mysql_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(error); DBUG_RETURN(error);
#ifdef WITH_WSREP
error:
DBUG_RETURN(TRUE);
#endif /* WITH_WSREP */
} }
......
...@@ -452,6 +452,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) ...@@ -452,6 +452,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
my_error(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER, MYF(0)); my_error(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
if (!create) if (!create)
{ {
...@@ -615,6 +616,10 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) ...@@ -615,6 +616,10 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
my_ok(thd); my_ok(thd);
DBUG_RETURN(result); DBUG_RETURN(result);
#ifdef WITH_WSREP
error:
DBUG_RETURN(true);
#endif /* WITH_WSREP */
} }
/** /**
......
...@@ -426,6 +426,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, ...@@ -426,6 +426,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
if ((res= create_view_precheck(thd, tables, view, mode))) if ((res= create_view_precheck(thd, tables, view, mode)))
goto err; goto err;
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
lex->link_first_table_back(view, link_to_local); lex->link_first_table_back(view, link_to_local);
view->open_type= OT_BASE_ONLY; view->open_type= OT_BASE_ONLY;
...@@ -702,6 +703,10 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, ...@@ -702,6 +703,10 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
lex->link_first_table_back(view, link_to_local); lex->link_first_table_back(view, link_to_local);
unit->cleanup(); unit->cleanup();
DBUG_RETURN(res || thd->is_error()); DBUG_RETURN(res || thd->is_error());
#ifdef WITH_WSREP
error:
DBUG_RETURN(true);
#endif /* WITH_WSREP */
} }
......
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