NOTE Requires that a write-lock is held on LOCK_system_variables_hash */
| 1119 | Requires that a write-lock is held on LOCK_system_variables_hash |
| 1120 | */ |
| 1121 | static enum install_status plugin_add(MEM_ROOT *tmp_root, bool if_not_exists, |
| 1122 | const LEX_CSTRING *name, LEX_CSTRING *dl, myf MyFlags) |
| 1123 | { |
| 1124 | struct st_plugin_int tmp, *maybe_dupe; |
| 1125 | struct st_maria_plugin *plugin; |
| 1126 | uint oks= 0, errs= 0, dupes= 0; |
| 1127 | DBUG_ENTER("plugin_add"); |
| 1128 | DBUG_PRINT("enter", ("name: %s dl: %s", name->str, dl->str)); |
| 1129 | |
| 1130 | if (name->str && plugin_find_internal(name, MYSQL_ANY_PLUGIN)) |
| 1131 | { |
| 1132 | if (if_not_exists) |
| 1133 | MyFlags|= ME_NOTE; |
| 1134 | my_error(ER_PLUGIN_INSTALLED, MyFlags, name->str); |
| 1135 | DBUG_RETURN(if_not_exists ? INSTALL_FAIL_WARN_OK : INSTALL_FAIL_NOT_OK); |
| 1136 | } |
| 1137 | /* Clear the whole struct to catch future extensions. */ |
| 1138 | bzero((char*) &tmp, sizeof(tmp)); |
| 1139 | fix_dl_name(tmp_root, dl); |
| 1140 | if (! (tmp.plugin_dl= plugin_dl_add(dl, MyFlags))) |
| 1141 | DBUG_RETURN(INSTALL_FAIL_NOT_OK); |
| 1142 | /* Find plugin by name */ |
| 1143 | for (plugin= tmp.plugin_dl->plugins; plugin->info; plugin++) |
| 1144 | { |
| 1145 | tmp.name.str= (char *)plugin->name; |
| 1146 | tmp.name.length= strlen(plugin->name); |
| 1147 | |
| 1148 | if (plugin->type < 0 || plugin->type >= MYSQL_MAX_PLUGIN_TYPE_NUM) |
| 1149 | continue; // invalid plugin type |
| 1150 | |
| 1151 | if (plugin->type == MYSQL_UDF_PLUGIN || |
| 1152 | (plugin->type == MariaDB_PASSWORD_VALIDATION_PLUGIN && |
| 1153 | tmp.plugin_dl->mariaversion == 0)) |
| 1154 | continue; // unsupported plugin type |
| 1155 | |
| 1156 | if (name->str && !Lex_ident_plugin(*name).streq(tmp.name)) |
| 1157 | continue; // plugin name doesn't match |
| 1158 | |
| 1159 | if (!name->str && |
| 1160 | (maybe_dupe= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN))) |
| 1161 | { |
| 1162 | if (plugin->name != maybe_dupe->plugin->name && !opt_silent_startup) |
| 1163 | { |
| 1164 | my_error(ER_UDF_EXISTS, MyFlags, plugin->name); |
| 1165 | DBUG_RETURN(INSTALL_FAIL_NOT_OK); |
| 1166 | } |
| 1167 | dupes++; |
| 1168 | continue; // already installed |
| 1169 | } |
| 1170 | struct st_plugin_int *tmp_plugin_ptr; |
| 1171 | if (*(int*)plugin->info < |
| 1172 | min_plugin_info_interface_version[plugin->type] || |
| 1173 | ((*(int*)plugin->info) >> 8) > |
| 1174 | (cur_plugin_info_interface_version[plugin->type] >> 8)) |
| 1175 | { |
| 1176 | char buf[256]; |
| 1177 | strxnmov(buf, sizeof(buf) - 1, "API version for ", |
| 1178 | plugin_type_names[plugin->type].str, |
no test coverage detected