From f0af56be01591e593c875d63656e287c829c0073 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 14 Nov 2023 16:09:07 +1100 Subject: [PATCH] MDEV-27095 installing one spider plugin should not trigger others There are several plugins in ha_spider: spider, spider_alloc_mem, spider_wrapper_protocols, spider_rewrite etc. INSTALL PLUGIN foo SONAME ha_spider causes all the other ones to be installed by the init queries where foo is any of the plugins. This introduces unnecessary complexiy. For example it reads mysql.plugins to find all other plugins, causing the hack of moving spider plugin init to a separate thread. To install all spider related plugins, install soname ha_spider should be used instead. This also fixes spurious rows in mysql.plugin when installing say only the spider plugin with `plugin-load-add=SPIDER=ha_spider.so`: select * from mysql.plugin; name dl spider_alloc_mem ha_spider.so # should not be here spider_wrapper_protocols ha_spider.so # should not be here Adapted from part of the reverted commit c160a115b8b6dcd54bb3daf1a751ee9c68b7ee47. --- .../mysql-test/spider/include/init_spider.inc | 4 +- storage/spider/spd_init_query.h | 98 ------------------- 2 files changed, 2 insertions(+), 100 deletions(-) diff --git a/storage/spider/mysql-test/spider/include/init_spider.inc b/storage/spider/mysql-test/spider/include/init_spider.inc index d2d1c03494c..e5fe7862534 100644 --- a/storage/spider/mysql-test/spider/include/init_spider.inc +++ b/storage/spider/mysql-test/spider/include/init_spider.inc @@ -2,7 +2,7 @@ let $VERSION_COMPILE_OS_WIN= `SELECT IF(@@version_compile_os like 'Win%', 1, 0)`; if ($VERSION_COMPILE_OS_WIN) { - INSTALL PLUGIN spider SONAME 'ha_spider.dll'; + INSTALL SONAME 'ha_spider'; if ($CHILD2_1_MYPORT) { eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( @@ -66,7 +66,7 @@ if ($VERSION_COMPILE_OS_WIN) } if (!$VERSION_COMPILE_OS_WIN) { - INSTALL PLUGIN spider SONAME 'ha_spider.so'; + INSTALL SONAME 'ha_spider'; if ($CHILD2_1_MYSOCK) { eval CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index 4c58f8d80a4..7bb47fc4378 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -612,57 +612,6 @@ static LEX_STRING spider_init_queries[] = { "create procedure mysql.spider_plugin_installer()" "begin" " set @win_plugin := IF(@@version_compile_os like 'Win%', 1, 0);" -/* - Install spider plugin -*/ -/* - " set @have_spider_i_s_plugin := 0;" - " select @have_spider_i_s_plugin := 1 from INFORMATION_SCHEMA.plugins" - " where PLUGIN_NAME = 'SPIDER';" - " set @have_spider_plugin := 0;" - " select @have_spider_plugin := 1 from mysql.plugin" - " where name = 'spider';" - " if @have_spider_i_s_plugin = 0 then" - " if @have_spider_plugin = 1 then" - " / *" - " spider plugin is present in mysql.plugin but not in" - " information_schema.plugins. Remove spider plugin entry" - " in mysql.plugin first." - " * /" - " delete from mysql.plugin where name = 'spider';" - " end if;" - " if @win_plugin = 0 then " - " install plugin spider soname 'ha_spider.so';" - " else" - " install plugin spider soname 'ha_spider.dll';" - " end if;" - " end if;" -*/ -/* - Install spider_alloc_mem plugin -*/ - " set @have_spider_i_s_alloc_mem_plugin := 0;" - " select @have_spider_i_s_alloc_mem_plugin := 1" - " from INFORMATION_SCHEMA.plugins" - " where PLUGIN_NAME = 'SPIDER_ALLOC_MEM';" - " set @have_spider_alloc_mem_plugin := 0;" - " select @have_spider_alloc_mem_plugin := 1 from mysql.plugin" - " where name = 'spider_alloc_mem';" - " if @have_spider_i_s_alloc_mem_plugin = 0 then" - " if @have_spider_alloc_mem_plugin = 1 then" - " /*" - " spider_alloc_mem plugin is present in mysql.plugin but not in" - " information_schema.plugins. Remove spider_alloc_mem plugin entry" - " in mysql.plugin first." - " */" - " delete from mysql.plugin where name = 'spider_alloc_mem';" - " end if;" - " if @win_plugin = 0 then " - " install plugin spider_alloc_mem soname 'ha_spider.so';" - " else" - " install plugin spider_alloc_mem soname 'ha_spider.dll';" - " end if;" - " end if;" " set @have_spider_direct_sql_udf := 0;" " select @have_spider_direct_sql_udf := 1 from mysql.func" " where name = 'spider_direct_sql';" @@ -723,53 +672,6 @@ static LEX_STRING spider_init_queries[] = { " soname 'ha_spider.dll';" " end if;" " end if;" - " if @server_name = 'MariaDB' and" - " (" - " @server_major_version > 10 or" - " (" - " @server_major_version = 10 and" - " @server_minor_version >= 6" - " )" - " )" - " then" -/* - Install spider_rewrite plugin -*/ - " set @have_spider_i_s_rewrite_plugin := 0;" - " select @have_spider_i_s_rewrite_plugin := 1" - " from INFORMATION_SCHEMA.plugins" - " where PLUGIN_NAME = 'SPIDER_REWRITE';" - " set @have_spider_rewrite_plugin := 0;" - " select @have_spider_rewrite_plugin := 1 from mysql.plugin" - " where name = 'spider_rewrite';" - " if @have_spider_i_s_rewrite_plugin = 0 then" - " if @have_spider_rewrite_plugin = 1 then" - " /*" - " spider_rewrite plugin is present in mysql.plugin but not in" - " information_schema.plugins. Remove spider_rewrite plugin entry" - " in mysql.plugin first." - " */" - " delete from mysql.plugin where name = 'spider_rewrite';" - " end if;" - " if @win_plugin = 0 then " - " install plugin spider_rewrite soname 'ha_spider.so';" - " else" - " install plugin spider_rewrite soname 'ha_spider.dll';" - " end if;" - " end if;" - " set @have_spider_flush_rewrite_cache_udf := 0;" - " select @have_spider_flush_rewrite_cache_udf := 1 from mysql.func" - " where name = 'spider_flush_rewrite_cache';" - " if @have_spider_flush_rewrite_cache_udf = 0 then" - " if @win_plugin = 0 then " - " create function spider_flush_rewrite_cache returns int" - " soname 'ha_spider.so';" - " else" - " create function spider_flush_rewrite_cache returns int" - " soname 'ha_spider.dll';" - " end if;" - " end if;" - " end if;" "end;" )}, {C_STRING_WITH_LEN(