diff --git a/sql/handler.cc b/sql/handler.cc index 8b299ae1b9e..7f5cb343824 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -641,13 +641,6 @@ int ha_initialize_handlerton(st_plugin_int *plugin) hton->slot= HA_SLOT_UNDEF; /* Historical Requirement */ plugin->data= hton; // shortcut for the future - /* [remove after merge] notes on merge conflict (MDEV-31400): - 10.6-10.11: 13ba00ff4933cfc1712676f323587504e453d1b5 - 11.0-11.2: 42f8be10f18163c4025710cf6a212e82bddb2f62 - The 10.11->11.0 conflict is trivial, but the reference commit also - contains different non-conflict changes needs to be applied to 11.0 - (and beyond). - */ if (plugin->plugin->init && (ret= plugin->plugin->init(hton))) goto err; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 63c00f8614e..a6b307ac8a4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9942,6 +9942,7 @@ ST_SCHEMA_TABLE schema_tables[]= int initialize_schema_table(st_plugin_int *plugin) { ST_SCHEMA_TABLE *schema_table; + int err; DBUG_ENTER("initialize_schema_table"); if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(key_memory_ST_SCHEMA_TABLE, @@ -9958,12 +9959,15 @@ int initialize_schema_table(st_plugin_int *plugin) /* Make the name available to the init() function. */ schema_table->table_name= plugin->name.str; - if (plugin->plugin->init(schema_table)) + if ((err= plugin->plugin->init(schema_table))) { - sql_print_error("Plugin '%s' init function returned error.", - plugin->name.str); + if (err != HA_ERR_RETRY_INIT) + sql_print_error("Plugin '%s' init function returned error.", + plugin->name.str); plugin->data= NULL; my_free(schema_table); + if (err == HA_ERR_RETRY_INIT) + DBUG_RETURN(err); DBUG_RETURN(1); } diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result new file mode 100644 index 00000000000..6597e457101 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result @@ -0,0 +1,12 @@ +show create table information_schema.SPIDER_ALLOC_MEM; +Table Create Table +SPIDER_ALLOC_MEM CREATE TEMPORARY TABLE `SPIDER_ALLOC_MEM` ( + `ID` int(10) unsigned NOT NULL, + `FUNC_NAME` varchar(64), + `FILE_NAME` varchar(64), + `LINE_NO` int(10) unsigned, + `TOTAL_ALLOC_MEM` bigint(20) unsigned, + `CURRENT_ALLOC_MEM` bigint(20), + `ALLOC_MEM_COUNT` bigint(20) unsigned, + `FREE_MEM_COUNT` bigint(20) unsigned +) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result new file mode 100644 index 00000000000..4b914710f18 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result @@ -0,0 +1,8 @@ +call mtr.add_suppression("\\[ERROR\\] SPIDER plugin initialization failed"); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_WRAPPER_PROTOCOLS' registration as a INFORMATION SCHEMA failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_ALLOC_MEM' registration as a INFORMATION SCHEMA failed."); +create table mysql.spider_tables (c int); +# restart: --plugin-load-add=ha_spider +SELECT * FROM information_schema.SPIDER_ALLOC_MEM; +ERROR 42S02: Unknown table 'SPIDER_ALLOC_MEM' in information_schema diff --git a/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result b/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result index 04e5ed6da68..4d161a2f7fb 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result +++ b/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result @@ -3,5 +3,9 @@ # select * from mysql.plugin; name dl +select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = "information_schema" and TABLE_NAME like "SPIDER_%"; +TABLE_NAME +SPIDER_ALLOC_MEM +SPIDER_WRAPPER_PROTOCOLS create table t (c int) Engine=SPIDER; drop table t; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt new file mode 100644 index 00000000000..a90c3a39413 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt @@ -0,0 +1,2 @@ +--plugin-load-add=ha_spider +--transaction-read-only=on diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test new file mode 100644 index 00000000000..e2d4d8b46e4 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test @@ -0,0 +1,2 @@ +# we check that information_schema.SPIDER_ALLOC_MEM exists +show create table information_schema.SPIDER_ALLOC_MEM; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test new file mode 100644 index 00000000000..1218e1db719 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test @@ -0,0 +1,17 @@ +call mtr.add_suppression("\\[ERROR\\] SPIDER plugin initialization failed"); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_WRAPPER_PROTOCOLS' registration as a INFORMATION SCHEMA failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_ALLOC_MEM' registration as a INFORMATION SCHEMA failed."); +# We create a table with identical name of the spider system table, to +# fail the spider init query ([ERROR] SPIDER plugin initialization +# failed at 'alter table mysql.spider_tables add column if not exists +# link_id int not null default 0 after table_name, drop primary key, +# add primary key (db_name, table_name, link_id), algorithm=copy, +# lock=shared;' by 'Unknown column 'table_name' in 'spider_tables'') +# This will cause the init of spider_alloc_mem to fail because it +# depends on the main spider plugin. +create table mysql.spider_tables (c int); +--let $restart_parameters= --plugin-load-add=ha_spider +--source include/restart_mysqld.inc +--error ER_UNKNOWN_TABLE +SELECT * FROM information_schema.SPIDER_ALLOC_MEM; diff --git a/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test b/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test index 396145fba2e..35242b2092b 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test +++ b/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test @@ -3,5 +3,6 @@ --echo # # A simple test that tests plugin-load-add=ha_spider select * from mysql.plugin; +select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = "information_schema" and TABLE_NAME like "SPIDER_%"; create table t (c int) Engine=SPIDER; drop table t; diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc index 22cd8eb0f15..8f828939aeb 100644 --- a/storage/spider/spd_i_s.cc +++ b/storage/spider/spd_i_s.cc @@ -129,7 +129,10 @@ static int spider_i_s_alloc_mem_init( void *p ) { ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; + const LEX_CSTRING spider_name={STRING_WITH_LEN("SPIDER")}; DBUG_ENTER("spider_i_s_alloc_mem_init"); + if (!plugin_is_ready(&spider_name, MYSQL_STORAGE_ENGINE_PLUGIN)) + DBUG_RETURN(HA_ERR_RETRY_INIT); schema->fields_info = Show::spider_i_s_alloc_mem_fields_info; schema->fill_table = spider_i_s_alloc_mem_fill_table; schema->idx_field1 = 0; @@ -249,7 +252,10 @@ static int spider_i_s_wrapper_protocols_init( void *p ) { ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; + const LEX_CSTRING spider_name={STRING_WITH_LEN("SPIDER")}; DBUG_ENTER("spider_i_s_wrapper_protocols_init"); + if (!plugin_is_ready(&spider_name, MYSQL_STORAGE_ENGINE_PLUGIN)) + DBUG_RETURN(HA_ERR_RETRY_INIT); schema->fields_info = Show::spider_i_s_wrapper_protocols_fields_info; schema->fill_table = spider_i_s_wrapper_protocols_fill_table; schema->idx_field1 = 0; diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index b493104f095..bdf42ddc3ef 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -25,6 +25,9 @@ static LEX_STRING spider_init_queries[] = { "SET @@SQL_MODE = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO," "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';" )}, + {C_STRING_WITH_LEN( + "SET tx_read_only = off;" + )}, {C_STRING_WITH_LEN( "create table if not exists mysql.spider_xa(" " format_id int not null default 0," diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 3485ce07eea..5eedda46523 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -7230,7 +7230,7 @@ int spider_db_init( spider_param_table_crd_thread_count()), NullS)) ) - goto error_alloc_mon_mutxes; + goto error_alloc_table_sts_crd_threads; for (roop_count = 0; roop_count < (int) spider_param_table_sts_thread_count(); @@ -7305,9 +7305,11 @@ error_init_table_sts_threads: { spider_free_sts_threads(&spider_table_sts_threads[roop_count]); } +error_alloc_table_sts_crd_threads: spider_free(NULL, spider_table_sts_threads, MYF(0)); - roop_count = spider_param_udf_table_mon_mutex_count() - 1; #endif +error_system_table_creation: + roop_count = spider_param_udf_table_mon_mutex_count() - 1; error_init_udf_table_mon_list_hash: for (; roop_count >= 0; roop_count--) { @@ -7321,7 +7323,6 @@ error_init_udf_table_mon_list_hash: error_init_udf_table_mon_cond: for (; roop_count >= 0; roop_count--) pthread_cond_destroy(&spider_udf_table_mon_conds[roop_count]); -error_system_table_creation: roop_count = spider_param_udf_table_mon_mutex_count() - 1; error_init_udf_table_mon_mutex: for (; roop_count >= 0; roop_count--)