| 2440 | |
| 2441 | |
| 2442 | bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name, |
| 2443 | const LEX_CSTRING *dl_arg) |
| 2444 | { |
| 2445 | TABLE *table; |
| 2446 | TABLE_LIST tables; |
| 2447 | LEX_CSTRING dl= *dl_arg; |
| 2448 | bool error= false; |
| 2449 | unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] = |
| 2450 | { MYSQL_AUDIT_GENERAL_CLASSMASK }; |
| 2451 | DBUG_ENTER("mysql_uninstall_plugin"); |
| 2452 | |
| 2453 | tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_PLUGIN_NAME, 0, TL_WRITE); |
| 2454 | |
| 2455 | if (!opt_noacl && check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) |
| 2456 | DBUG_RETURN(TRUE); |
| 2457 | |
| 2458 | WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); |
| 2459 | |
| 2460 | /* need to open before acquiring LOCK_plugin or it will deadlock */ |
| 2461 | table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT); |
| 2462 | if (!table || !plugin_table_is_valid(table)) |
| 2463 | DBUG_RETURN(TRUE); |
| 2464 | |
| 2465 | /* |
| 2466 | Pre-acquire audit plugins for events that may potentially occur |
| 2467 | during [UN]INSTALL PLUGIN. |
| 2468 | |
| 2469 | When audit event is triggered, audit subsystem acquires interested |
| 2470 | plugins by walking through plugin list. Evidently plugin list |
| 2471 | iterator protects plugin list by acquiring LOCK_plugin, see |
| 2472 | plugin_foreach_with_mask(). |
| 2473 | |
| 2474 | On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin |
| 2475 | rather for a long time. |
| 2476 | |
| 2477 | When audit event is triggered during [UN]INSTALL PLUGIN, plugin |
| 2478 | list iterator acquires the same lock (within the same thread) |
| 2479 | second time. |
| 2480 | |
| 2481 | This hack should be removed when LOCK_plugin is fixed so it |
| 2482 | protects only what it supposed to protect. |
| 2483 | |
| 2484 | See also mysql_install_plugin() and initialize_audit_plugin() |
| 2485 | */ |
| 2486 | if (mysql_audit_general_enabled()) |
| 2487 | mysql_audit_acquire_plugins(thd, event_class_mask); |
| 2488 | |
| 2489 | mysql_mutex_lock(&LOCK_plugin); |
| 2490 | |
| 2491 | if (name->str) |
| 2492 | error= do_uninstall(thd, table, name); |
| 2493 | else |
| 2494 | { |
| 2495 | fix_dl_name(thd->mem_root, &dl); |
| 2496 | st_plugin_dl *plugin_dl= plugin_dl_find(&dl); |
| 2497 | if (plugin_dl) |
| 2498 | { |
| 2499 | for (struct st_maria_plugin *plugin= plugin_dl->plugins; |
no test coverage detected