Skip to content

Commit 91daf88

Browse files
sjaakolavuvova
authored andcommitted
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
1 parent beabe6b commit 91daf88

File tree

5 files changed

+44
-11
lines changed

5 files changed

+44
-11
lines changed

sql/events.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
335335

336336
if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0))
337337
DBUG_RETURN(TRUE);
338+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
338339

339340
if (lock_object_name(thd, MDL_key::EVENT,
340341
parse_data->dbname.str, parse_data->name.str))
@@ -417,6 +418,10 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
417418
thd->restore_stmt_binlog_format(save_binlog_format);
418419

419420
DBUG_RETURN(ret);
421+
#ifdef WITH_WSREP
422+
error:
423+
DBUG_RETURN(true);
424+
#endif /* WITH_WSREP */
420425
}
421426

422427

@@ -457,6 +462,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
457462

458463
if (check_access(thd, EVENT_ACL, parse_data->dbname.str, NULL, NULL, 0, 0))
459464
DBUG_RETURN(TRUE);
465+
466+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
467+
460468
if (lock_object_name(thd, MDL_key::EVENT,
461469
parse_data->dbname.str, parse_data->name.str))
462470
DBUG_RETURN(TRUE);
@@ -541,6 +549,10 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
541549

542550
thd->restore_stmt_binlog_format(save_binlog_format);
543551
DBUG_RETURN(ret);
552+
#ifdef WITH_WSREP
553+
error:
554+
DBUG_RETURN(TRUE);
555+
#endif /* WITH_WSREP */
544556
}
545557

546558

@@ -581,6 +593,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
581593
if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0))
582594
DBUG_RETURN(TRUE);
583595

596+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
597+
584598
/*
585599
Turn off row binlogging of this statement and use statement-based so
586600
that all supporting tables are updated for DROP EVENT command.
@@ -602,6 +616,10 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
602616

603617
thd->restore_stmt_binlog_format(save_binlog_format);
604618
DBUG_RETURN(ret);
619+
#ifdef WITH_WSREP
620+
error:
621+
DBUG_RETURN(TRUE);
622+
#endif
605623
}
606624

607625

sql/sql_parse.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4565,7 +4565,6 @@ mysql_execute_command(THD *thd)
45654565
if (res)
45664566
break;
45674567

4568-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
45694568
switch (lex->sql_command) {
45704569
case SQLCOM_CREATE_EVENT:
45714570
{
@@ -4599,7 +4598,6 @@ mysql_execute_command(THD *thd)
45994598
lex->spname->m_name);
46004599
break;
46014600
case SQLCOM_DROP_EVENT:
4602-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
46034601
if (!(res= Events::drop_event(thd,
46044602
lex->spname->m_db, lex->spname->m_name,
46054603
lex->if_exists())))
@@ -5505,7 +5503,6 @@ mysql_execute_command(THD *thd)
55055503
Note: SQLCOM_CREATE_VIEW also handles 'ALTER VIEW' commands
55065504
as specified through the thd->lex->create_view_mode flag.
55075505
*/
5508-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
55095506
res= mysql_create_view(thd, first_table, thd->lex->create_view_mode);
55105507
break;
55115508
}
@@ -5521,15 +5518,13 @@ mysql_execute_command(THD *thd)
55215518
case SQLCOM_CREATE_TRIGGER:
55225519
{
55235520
/* Conditionally writes to binlog. */
5524-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
55255521
res= mysql_create_or_drop_trigger(thd, all_tables, 1);
55265522

55275523
break;
55285524
}
55295525
case SQLCOM_DROP_TRIGGER:
55305526
{
55315527
/* Conditionally writes to binlog. */
5532-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
55335528
res= mysql_create_or_drop_trigger(thd, all_tables, 0);
55345529
break;
55355530
}
@@ -5594,13 +5589,11 @@ mysql_execute_command(THD *thd)
55945589
my_ok(thd);
55955590
break;
55965591
case SQLCOM_INSTALL_PLUGIN:
5597-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
55985592
if (! (res= mysql_install_plugin(thd, &thd->lex->comment,
55995593
&thd->lex->ident)))
56005594
my_ok(thd);
56015595
break;
56025596
case SQLCOM_UNINSTALL_PLUGIN:
5603-
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
56045597
if (! (res= mysql_uninstall_plugin(thd, &thd->lex->comment,
56055598
&thd->lex->ident)))
56065599
my_ok(thd);

sql/sql_plugin.cc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,12 +2108,16 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
21082108
bool error;
21092109
int argc=orig_argc;
21102110
char **argv=orig_argv;
2111+
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
2112+
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
21112113
DBUG_ENTER("mysql_install_plugin");
21122114

21132115
tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
21142116
if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE))
21152117
DBUG_RETURN(TRUE);
21162118

2119+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
2120+
21172121
/* need to open before acquiring LOCK_plugin or it will deadlock */
21182122
if (! (table = open_ltable(thd, &tables, TL_WRITE,
21192123
MYSQL_LOCK_IGNORE_TIMEOUT)))
@@ -2146,8 +2150,6 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
21462150
21472151
See also mysql_uninstall_plugin() and initialize_audit_plugin()
21482152
*/
2149-
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
2150-
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
21512153
mysql_audit_acquire_plugins(thd, event_class_mask);
21522154

21532155
mysql_mutex_lock(&LOCK_plugin);
@@ -2178,6 +2180,10 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
21782180
if (argv)
21792181
free_defaults(argv);
21802182
DBUG_RETURN(error);
2183+
#ifdef WITH_WSREP
2184+
error:
2185+
DBUG_RETURN(TRUE);
2186+
#endif /* WITH_WSREP */
21812187
}
21822188

21832189

@@ -2244,13 +2250,17 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
22442250
TABLE_LIST tables;
22452251
LEX_STRING dl= *dl_arg;
22462252
bool error= false;
2253+
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
2254+
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
22472255
DBUG_ENTER("mysql_uninstall_plugin");
22482256

22492257
tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE);
22502258

22512259
if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE))
22522260
DBUG_RETURN(TRUE);
22532261

2262+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
2263+
22542264
/* need to open before acquiring LOCK_plugin or it will deadlock */
22552265
if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT)))
22562266
DBUG_RETURN(TRUE);
@@ -2276,8 +2286,6 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
22762286
22772287
See also mysql_install_plugin() and initialize_audit_plugin()
22782288
*/
2279-
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] =
2280-
{ MYSQL_AUDIT_GENERAL_CLASSMASK };
22812289
mysql_audit_acquire_plugins(thd, event_class_mask);
22822290

22832291
mysql_mutex_lock(&LOCK_plugin);
@@ -2307,6 +2315,10 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name,
23072315

23082316
mysql_mutex_unlock(&LOCK_plugin);
23092317
DBUG_RETURN(error);
2318+
#ifdef WITH_WSREP
2319+
error:
2320+
DBUG_RETURN(TRUE);
2321+
#endif /* WITH_WSREP */
23102322
}
23112323

23122324

sql/sql_trigger.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
441441
my_error(ER_BINLOG_CREATE_ROUTINE_NEED_SUPER, MYF(0));
442442
DBUG_RETURN(TRUE);
443443
}
444+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
444445

445446
if (!create)
446447
{
@@ -606,6 +607,10 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
606607
my_ok(thd);
607608

608609
DBUG_RETURN(result);
610+
#ifdef WITH_WSREP
611+
error:
612+
DBUG_RETURN(true);
613+
#endif /* WITH_WSREP */
609614
}
610615

611616
/**

sql/sql_view.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
425425

426426
if ((res= create_view_precheck(thd, tables, view, mode)))
427427
goto err;
428+
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
428429

429430
lex->link_first_table_back(view, link_to_local);
430431
view->open_type= OT_BASE_ONLY;
@@ -695,6 +696,10 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
695696
lex->link_first_table_back(view, link_to_local);
696697
unit->cleanup();
697698
DBUG_RETURN(res || thd->is_error());
699+
#ifdef WITH_WSREP
700+
error:
701+
DBUG_RETURN(true);
702+
#endif /* WITH_WSREP */
698703
}
699704

700705

0 commit comments

Comments
 (0)