Commit 2107e3bb authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-21258: Can't uninstall plugin if the library file doesn't exist

Removing plugin from the mysql.plugin even if the plugin is not loaded
parent 8ec877f4
......@@ -341,3 +341,16 @@ RENAME TABLE t1 TO t2;
ERROR 42S02: Table 'test.t1' doesn't exist
DROP TABLE t1;
# End of 10.1 test
#
# MDEV-21258: Can't uninstall plugin if the library file doesn't exist
#
insert into mysql.plugin values ("unexisting_plugin", "soname");
select * from mysql.plugin WHERE name='unexisting_plugin';
name dl
unexisting_plugin soname
UNINSTALL PLUGIN unexisting_plugin;
select * from mysql.plugin WHERE name='unexisting_plugin';
name dl
UNINSTALL PLUGIN unexisting_plugin;
ERROR 42000: PLUGIN unexisting_plugin does not exist
# End of 10.2 tests
......@@ -11,5 +11,6 @@ uninstall plugin audit_null;
ERROR HY000: Index for table './mysql/plugin.MYI' is corrupt; try to repair it
SET debug_dbug=@old_dbug;
uninstall plugin audit_null;
uninstall plugin audit_null;
ERROR 42000: PLUGIN audit_null does not exist
delete from mysql.plugin where name='audit_null';
......@@ -26,7 +26,8 @@ SET debug_dbug='+d,myisam_pretend_crashed_table_on_usage';
uninstall plugin audit_null;
SET debug_dbug=@old_dbug;
--error 1305
uninstall plugin audit_null;
--error ER_SP_DOES_NOT_EXIST
uninstall plugin audit_null;
delete from mysql.plugin where name='audit_null';
......
......@@ -276,3 +276,23 @@ RENAME TABLE t1 TO t2;
DROP TABLE t1;
--echo # End of 10.1 test
--echo #
--echo # MDEV-21258: Can't uninstall plugin if the library file doesn't exist
--echo #
insert into mysql.plugin values ("unexisting_plugin", "soname");
# check that we have the plugin installed
select * from mysql.plugin WHERE name='unexisting_plugin';
# make attempt to uninstall the plugin
UNINSTALL PLUGIN unexisting_plugin;
# check that we have the plugin uninstalled
select * from mysql.plugin WHERE name='unexisting_plugin';
--error ER_SP_DOES_NOT_EXIST
UNINSTALL PLUGIN unexisting_plugin;
--echo # End of 10.2 tests
......@@ -2216,26 +2216,30 @@ static bool do_uninstall(THD *thd, TABLE *table, const LEX_STRING *name)
if (!(plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)) ||
plugin->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_DYING))
{
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
return 1;
}
if (!plugin->plugin_dl)
{
my_error(ER_PLUGIN_DELETE_BUILTIN, MYF(0));
return 1;
// maybe plugin is in mysql.plugin present so postpond the error
plugin= NULL;
}
if (plugin->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
if (plugin)
{
my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
return 1;
}
if (!plugin->plugin_dl)
{
my_error(ER_PLUGIN_DELETE_BUILTIN, MYF(0));
return 1;
}
if (plugin->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
{
my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
return 1;
}
plugin->state= PLUGIN_IS_DELETED;
if (plugin->ref_count)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
WARN_PLUGIN_BUSY, ER_THD(thd, WARN_PLUGIN_BUSY));
else
reap_needed= true;
plugin->state= PLUGIN_IS_DELETED;
if (plugin->ref_count)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
WARN_PLUGIN_BUSY, ER_THD(thd, WARN_PLUGIN_BUSY));
else
reap_needed= true;
}
uchar user_key[MAX_KEY_LENGTH];
table->use_all_columns();
......@@ -2260,6 +2264,11 @@ static bool do_uninstall(THD *thd, TABLE *table, const LEX_STRING *name)
return 1;
}
}
else if (!plugin)
{
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
return 1;
}
return 0;
}
......
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