summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-07-28 10:39:05 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-07-28 14:06:56 +0200
commit14affeb70b66552ec83340ff67cbf48492edd96b (patch)
tree5e06e7834e6ae7589cd5a2cd9e7296ffd79aa52a
parentdb87a9cddab2600cefd822e9ecacff5736645c2d (diff)
downloadmariadb-git-bb-10.2-MDEV-21258.tar.gz
MDEV-21258: (p1) Can't uninstall plugin if the library file doesn't existbb-10.2-MDEV-21258
Part 1: removing plugin from the mysql.plugin even if the plugin is not loaded
-rw-r--r--mysql-test/r/plugin.result13
-rw-r--r--mysql-test/suite/plugins/r/audit_null_debug.result1
-rw-r--r--mysql-test/suite/plugins/t/audit_null_debug.test3
-rw-r--r--mysql-test/t/plugin.test20
-rw-r--r--sql/sql_plugin.cc43
5 files changed, 62 insertions, 18 deletions
diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result
index 93a150ae424..04931001901 100644
--- a/mysql-test/r/plugin.result
+++ b/mysql-test/r/plugin.result
@@ -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
diff --git a/mysql-test/suite/plugins/r/audit_null_debug.result b/mysql-test/suite/plugins/r/audit_null_debug.result
index 9d5c7c4a02c..e70de36a2ec 100644
--- a/mysql-test/suite/plugins/r/audit_null_debug.result
+++ b/mysql-test/suite/plugins/r/audit_null_debug.result
@@ -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';
diff --git a/mysql-test/suite/plugins/t/audit_null_debug.test b/mysql-test/suite/plugins/t/audit_null_debug.test
index 0534108b107..f3c88d24c0c 100644
--- a/mysql-test/suite/plugins/t/audit_null_debug.test
+++ b/mysql-test/suite/plugins/t/audit_null_debug.test
@@ -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';
diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test
index e1a17d49174..d2e828b2589 100644
--- a/mysql-test/t/plugin.test
+++ b/mysql-test/t/plugin.test
@@ -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
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 42d2d110f2b..968ec6ac7d4 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -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;
}