Skip to content

Commit 70b94c3

Browse files
committed
cleanup: move common test into a function
1 parent b850fc6 commit 70b94c3

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sql/sql_plugin.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin);
316316
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin);
317317
static void reap_plugins(void);
318318

319+
bool plugin_is_forced(struct st_plugin_int *p)
320+
{
321+
return p->load_option == PLUGIN_FORCE ||
322+
p->load_option == PLUGIN_FORCE_PLUS_PERMANENT;
323+
}
324+
319325
static void report_error(int where_to, uint error, ...)
320326
{
321327
va_list args;
@@ -1657,8 +1663,7 @@ int plugin_init(int *argc, char **argv, int flags)
16571663
while ((plugin_ptr= *(--reap)))
16581664
{
16591665
mysql_mutex_unlock(&LOCK_plugin);
1660-
if (plugin_ptr->load_option == PLUGIN_FORCE ||
1661-
plugin_ptr->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
1666+
if (plugin_is_forced(plugin_ptr))
16621667
reaped_mandatory_plugin= TRUE;
16631668
plugin_deinitialize(plugin_ptr, true);
16641669
mysql_mutex_lock(&LOCK_plugin);
@@ -3505,8 +3510,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
35053510
plugin_dash.length + 1);
35063511
strxmov(plugin_name_with_prefix_ptr, plugin_dash.str, plugin_name_ptr, NullS);
35073512

3508-
if (tmp->load_option != PLUGIN_FORCE &&
3509-
tmp->load_option != PLUGIN_FORCE_PLUS_PERMANENT)
3513+
if (!plugin_is_forced(tmp))
35103514
{
35113515
/* support --skip-plugin-foo syntax */
35123516
options[0].name= plugin_name_ptr;
@@ -3823,8 +3827,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
38233827
We adjust the default value to account for the hardcoded exceptions
38243828
we have set for the federated and ndbcluster storage engines.
38253829
*/
3826-
if (tmp->load_option != PLUGIN_FORCE &&
3827-
tmp->load_option != PLUGIN_FORCE_PLUS_PERMANENT)
3830+
if (!plugin_is_forced(tmp))
38283831
opts[0].def_value= opts[1].def_value= plugin_load_option;
38293832

38303833
error= handle_options(argc, &argv, opts, NULL);
@@ -3840,8 +3843,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
38403843
Set plugin loading policy from option value. First element in the option
38413844
list is always the <plugin name> option value.
38423845
*/
3843-
if (tmp->load_option != PLUGIN_FORCE &&
3844-
tmp->load_option != PLUGIN_FORCE_PLUS_PERMANENT)
3846+
if (!plugin_is_forced(tmp))
38453847
plugin_load_option= (enum_plugin_load_option) *(ulong*) opts[0].value;
38463848
}
38473849

0 commit comments

Comments
 (0)