1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Add information_schema.spider_wrapper_protocols for knowing available wrappers of Spider

This commit is contained in:
Kentoku SHIBA
2020-06-06 07:37:05 +09:00
parent c9f262ee0d
commit 0af1b0bd21
11 changed files with 262 additions and 12 deletions

View File

@@ -33,6 +33,7 @@ DROP FUNCTION spider_copy_tables;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_direct_sql;
UNINSTALL PLUGIN spider_wrapper_protocols;
UNINSTALL PLUGIN spider_alloc_mem;
UNINSTALL PLUGIN spider;
DROP TABLE IF EXISTS mysql.spider_xa;

View File

@@ -0,0 +1,22 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
connection master_1;
SELECT * FROM information_schema.spider_wrapper_protocols;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test

View File

@@ -0,0 +1,16 @@
--disable_warnings
--disable_query_log
--disable_result_log
--source test_init.inc
--enable_query_log
--connection master_1
SELECT * FROM information_schema.spider_wrapper_protocols;
--disable_query_log
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--echo
--echo end of test

View File

@@ -127,7 +127,10 @@ SPIDER_DBTON spider_dbton_handlersocket = {
NULL,
spider_handlersocket_create_conn,
spider_handlersocket_support_direct_join,
&spider_db_handlersocket_utility
&spider_db_handlersocket_utility,
"For communicating using the handlersocket protocol",
"0.1.0",
SPIDER_MATURITY_BETA
};
#ifndef HANDLERSOCKET_MYSQL_UTIL

View File

@@ -1923,6 +1923,23 @@ enum spider_db_access_type
SPIDER_DB_ACCESS_TYPE_NOSQL
};
#define SPIDER_MATURITY_UNKNOWN 0
#define SPIDER_MATURITY_EXPERIMENTAL 1
#define SPIDER_MATURITY_ALPHA 2
#define SPIDER_MATURITY_BETA 3
#define SPIDER_MATURITY_GAMMA 4
#define SPIDER_MATURITY_STABLE 5
static const LEX_CSTRING maturity_name[] =
{
{ STRING_WITH_LEN("Unknown") },
{ STRING_WITH_LEN("Experimental") },
{ STRING_WITH_LEN("Alpha") },
{ STRING_WITH_LEN("Beta") },
{ STRING_WITH_LEN("Gamma") },
{ STRING_WITH_LEN("Stable") }
};
typedef struct st_spider_dbton
{
uint dbton_id;
@@ -1938,6 +1955,9 @@ typedef struct st_spider_dbton
SPIDER_DB_CONN *(*create_db_conn)(SPIDER_CONN *conn);
bool (*support_direct_join)();
spider_db_util *db_util;
const char *descr;
const char *version_info;
unsigned int maturity;
} SPIDER_DBTON;
typedef struct st_spider_position

View File

@@ -329,7 +329,10 @@ SPIDER_DBTON spider_dbton_mysql = {
spider_mysql_create_copy_table,
spider_mysql_create_conn,
spider_mysql_support_direct_join,
&spider_db_mysql_utility
&spider_db_mysql_utility,
"For communicating to MySQL using native protocol",
"3.4.0",
SPIDER_MATURITY_STABLE
};
SPIDER_DBTON spider_dbton_mariadb = {
@@ -343,7 +346,10 @@ SPIDER_DBTON spider_dbton_mariadb = {
spider_mariadb_create_copy_table,
spider_mariadb_create_conn,
spider_mariadb_support_direct_join,
&spider_db_mariadb_utility
&spider_db_mariadb_utility,
"For communicating to MariaDB using native protocol",
"3.4.0",
SPIDER_MATURITY_STABLE
};
spider_db_mbase_row::spider_db_mbase_row(

View File

@@ -336,7 +336,10 @@ SPIDER_DBTON spider_dbton_oracle = {
spider_oracle_create_copy_table,
spider_oracle_create_conn,
spider_oracle_support_direct_join,
&spider_db_oracle_utility
&spider_db_oracle_utility,
"For communicating Oracle using native protocol",
"1.0.0",
SPIDER_MATURITY_BETA
};
spider_db_oracle_row::spider_db_oracle_row() :

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2008-2019 Kentoku Shiba
Copyright (C) 2017-2019 MariaDB corp
/* Copyright (C) 2008-2020 Kentoku Shiba
Copyright (C) 2017-2020 MariaDB corp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,4 +54,8 @@
#define SPIDER_LIKE_FUNC_HAS_GET_NEGATED
#define HA_HAS_CHECKSUM_EXTENDED
#endif
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100500
#define SPIDER_I_S_USE_SHOW_FOR_COLUMN
#endif
#endif /* SPD_ENVIRON_INCLUDED */

View File

@@ -1,4 +1,5 @@
/* Copyright (C) 2012-2018 Kentoku Shiba
/* Copyright (C) 2012-2020 Kentoku Shiba
Copyright (C) 2020 MariaDB corp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -45,7 +46,7 @@ static struct st_mysql_storage_engine spider_i_s_info =
{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
namespace Show {
#ifdef SPIDER_I_S_USE_SHOW_FOR_COLUMN
static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] =
{
Column("ID", ULong(10), NOT_NULL, "id"),
@@ -58,6 +59,27 @@ static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] =
Column("FREE_MEM_COUNT", ULonglong(20), NULLABLE, "free_mem_count"),
CEnd()
};
#else
static ST_FIELD_INFO spider_i_s_alloc_mem_fields_info[] =
{
{"ID", 10, MYSQL_TYPE_LONG, 0, MY_I_S_UNSIGNED, "id", SKIP_OPEN_TABLE},
{"FUNC_NAME", 64, MYSQL_TYPE_STRING, 0,
MY_I_S_MAYBE_NULL, "func_name", SKIP_OPEN_TABLE},
{"FILE_NAME", 64, MYSQL_TYPE_STRING, 0,
MY_I_S_MAYBE_NULL, "file_name", SKIP_OPEN_TABLE},
{"LINE_NO", 10, MYSQL_TYPE_LONG, 0,
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "line_no", SKIP_OPEN_TABLE},
{"TOTAL_ALLOC_MEM", 20, MYSQL_TYPE_LONGLONG, 0,
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "total_alloc_mem", SKIP_OPEN_TABLE},
{"CURRENT_ALLOC_MEM", 20, MYSQL_TYPE_LONGLONG, 0,
MY_I_S_MAYBE_NULL, "current_alloc_mem", SKIP_OPEN_TABLE},
{"ALLOC_MEM_COUNT", 20, MYSQL_TYPE_LONGLONG, 0,
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "alloc_mem_count", SKIP_OPEN_TABLE},
{"FREE_MEM_COUNT", 20, MYSQL_TYPE_LONGLONG, 0,
MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL, "free_mem_count", SKIP_OPEN_TABLE},
{NULL, 0, MYSQL_TYPE_STRING, 0, 0, NULL, 0}
};
#endif
} // namespace Show
static int spider_i_s_alloc_mem_fill_table(
@@ -163,3 +185,127 @@ struct st_maria_plugin spider_i_s_alloc_mem_maria =
MariaDB_PLUGIN_MATURITY_STABLE,
};
#endif
extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE];
namespace Show {
#ifdef SPIDER_I_S_USE_SHOW_FOR_COLUMN
static ST_FIELD_INFO spider_i_s_wrapper_protocols_fields_info[] =
{
Column("WRAPPER_NAME", Varchar(NAME_CHAR_LEN), NOT_NULL, ""),
Column("WRAPPER_VERSION", Varchar(20), NOT_NULL, ""),
Column("WRAPPER_DESCRIPTION", Longtext(65535), NULLABLE, ""),
Column("WRAPPER_MATURITY", Varchar(12), NOT_NULL, ""),
CEnd()
};
#else
static ST_FIELD_INFO spider_i_s_wrapper_protocols_fields_info[] =
{
{"WRAPPER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
{"WRAPPER_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
{"WRAPPER_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
{"WRAPPER_MATURITY", 12, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
};
#endif
} // namespace Show
static int spider_i_s_wrapper_protocols_fill_table(
THD *thd,
TABLE_LIST *tables,
COND *cond
) {
uint roop_count;
SPIDER_DBTON *dbton;
TABLE *table = tables->table;
DBUG_ENTER("spider_i_s_wrapper_protocols_fill_table");
for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++)
{
dbton = &spider_dbton[roop_count];
if (!dbton->wrapper)
{
continue;
}
table->field[0]->store(dbton->wrapper,
strlen(dbton->wrapper), system_charset_info);
table->field[1]->store(dbton->version_info,
strlen(dbton->version_info), system_charset_info);
if (dbton->descr)
{
table->field[2]->set_notnull();
table->field[2]->store(dbton->descr,
strlen(dbton->descr), system_charset_info);
} else {
table->field[2]->set_null();
}
if (dbton->maturity <= SPIDER_MATURITY_STABLE)
{
table->field[3]->store(maturity_name[dbton->maturity].str,
maturity_name[dbton->maturity].length, system_charset_info);
} else {
table->field[3]->store(maturity_name[0].str,
maturity_name[0].length, system_charset_info);
}
if (schema_table_store_record(thd, table))
{
DBUG_RETURN(1);
}
}
DBUG_RETURN(0);
}
static int spider_i_s_wrapper_protocols_init(
void *p
) {
ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p;
DBUG_ENTER("spider_i_s_wrapper_protocols_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;
DBUG_RETURN(0);
}
static int spider_i_s_wrapper_protocols_deinit(
void *p
) {
DBUG_ENTER("spider_i_s_wrapper_protocols_deinit");
DBUG_RETURN(0);
}
struct st_mysql_plugin spider_i_s_wrapper_protocols =
{
MYSQL_INFORMATION_SCHEMA_PLUGIN,
&spider_i_s_info,
"SPIDER_WRAPPER_PROTOCOLS",
"Kentoku Shiba, MariaDB Corp",
"Available wrapper protocols of Spider",
PLUGIN_LICENSE_GPL,
spider_i_s_wrapper_protocols_init,
spider_i_s_wrapper_protocols_deinit,
0x0001,
NULL,
NULL,
NULL,
#if MYSQL_VERSION_ID >= 50600
0,
#endif
};
#ifdef MARIADB_BASE_VERSION
struct st_maria_plugin spider_i_s_wrapper_protocols_maria =
{
MYSQL_INFORMATION_SCHEMA_PLUGIN,
&spider_i_s_info,
"SPIDER_WRAPPER_PROTOCOLS",
"Kentoku Shiba, MariaDB Corp",
"Available wrapper protocols of Spider",
PLUGIN_LICENSE_GPL,
spider_i_s_wrapper_protocols_init,
spider_i_s_wrapper_protocols_deinit,
0x0100,
NULL,
NULL,
"1.0",
MariaDB_PLUGIN_MATURITY_STABLE,
};
#endif

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2010-2019 Kentoku Shiba
Copyright (C) 2019 MariaDB corp
/* Copyright (C) 2010-2020 Kentoku Shiba
Copyright (C) 2019-2020 MariaDB corp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -686,6 +686,31 @@ static LEX_STRING spider_init_queries[] = {
" install plugin spider_alloc_mem soname 'ha_spider.dll';"
" end if;"
" end if;"
/*
Install spider_wrapper_protocols plugin
*/
" set @have_spider_i_s_wrapper_protocols_plugin := 0;"
" select @have_spider_i_s_wrapper_protocols_plugin := 1"
" from INFORMATION_SCHEMA.plugins"
" where PLUGIN_NAME = 'SPIDER_WRAPPER_PROTOCOLS';"
" set @have_spider_wrapper_protocols_plugin := 0;"
" select @have_spider_wrapper_protocols_plugin := 1 from mysql.plugin"
" where name = 'spider_wrapper_protocols';"
" if @have_spider_i_s_wrapper_protocols_plugin = 0 then"
" if @have_spider_wrapper_protocols_plugin = 1 then"
" /*"
" spider_wrapper_protocols plugin is present in mysql.plugin but not in"
" information_schema.plugins. Remove spider_wrapper_protocols plugin entry"
" in mysql.plugin first."
" */"
" delete from mysql.plugin where name = 'spider_wrapper_protocols';"
" end if;"
" if @win_plugin = 0 then "
" install plugin spider_wrapper_protocols soname 'ha_spider.so';"
" else"
" install plugin spider_wrapper_protocols 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';"

View File

@@ -35,8 +35,10 @@
#include "spd_trx.h"
extern struct st_mysql_plugin spider_i_s_alloc_mem;
extern struct st_mysql_plugin spider_i_s_wrapper_protocols;
#ifdef MARIADB_BASE_VERSION
extern struct st_maria_plugin spider_i_s_alloc_mem_maria;
extern struct st_maria_plugin spider_i_s_wrapper_protocols_maria;
#endif
extern volatile ulonglong spider_mon_table_cache_version;
@@ -3652,7 +3654,8 @@ mysql_declare_plugin(spider)
0,
#endif
},
spider_i_s_alloc_mem
spider_i_s_alloc_mem,
spider_i_s_wrapper_protocols
mysql_declare_plugin_end;
#ifdef MARIADB_BASE_VERSION
@@ -3672,6 +3675,7 @@ maria_declare_plugin(spider)
SPIDER_DETAIL_VERSION,
MariaDB_PLUGIN_MATURITY_BETA
},
spider_i_s_alloc_mem_maria
spider_i_s_alloc_mem_maria,
spider_i_s_wrapper_protocols_maria
maria_declare_plugin_end;
#endif