Skip to content

Commit 75f0f17

Browse files
author
Sergei Golubchik
committed
MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa
INSTALL SONAME ignores attempts to load the same plugin twice, it's not an error (because one can load one plugin by name and then install soname for the rest). But Federated and FederatedX are different plugins, despite having the same name. Now plugin_add() only considers two plugins identical if their names are the same string (compared as pointers). Otherwise it reports an error.,
1 parent 071a14c commit 75f0f17

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
install soname 'ha_federated';
2+
install soname 'ha_federated';
3+
install soname 'ha_federatedx';
4+
ERROR HY000: Function 'FEDERATED' already exists
5+
uninstall soname 'ha_federated';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa
3+
#
4+
if(!$HA_FEDERATED_SO) {
5+
skip Needs ha_federated.so;
6+
}
7+
if(!$HA_FEDERATEDX_SO) {
8+
skip Needs ha_federatedx.so;
9+
}
10+
11+
install soname 'ha_federated';
12+
# note: no error below! install soname ignores already loaded plugins
13+
install soname 'ha_federated';
14+
# note: an error here, even though plugin name is the same!
15+
--error ER_UDF_EXISTS
16+
install soname 'ha_federatedx';
17+
uninstall soname 'ha_federated';
18+

sql/sql_plugin.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
10401040
static bool plugin_add(MEM_ROOT *tmp_root,
10411041
const LEX_STRING *name, LEX_STRING *dl, int report)
10421042
{
1043-
struct st_plugin_int tmp;
1043+
struct st_plugin_int tmp, *maybe_dupe;
10441044
struct st_maria_plugin *plugin;
10451045
uint oks= 0, errs= 0, dupes= 0;
10461046
DBUG_ENTER("plugin_add");
@@ -1070,8 +1070,14 @@ static bool plugin_add(MEM_ROOT *tmp_root,
10701070
(const uchar *)tmp.name.str, tmp.name.length))
10711071
continue; // plugin name doesn't match
10721072

1073-
if (!name->str && plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN))
1073+
if (!name->str &&
1074+
(maybe_dupe= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)))
10741075
{
1076+
if (plugin->name != maybe_dupe->plugin->name)
1077+
{
1078+
report_error(report, ER_UDF_EXISTS, plugin->name);
1079+
DBUG_RETURN(TRUE);
1080+
}
10751081
dupes++;
10761082
continue; // already installed
10771083
}

0 commit comments

Comments
 (0)