mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 21:25:36 +02:00
WL#2936
"Server Variables for Plugins"
Implement support for plugins to declare server variables.
Demonstrate functionality by removing InnoDB specific code from sql/*
New feature for HASH - HASH_UNIQUE flag
New feature for DYNAMIC_ARRAY - initializer accepts preallocated ptr.
Completed support for plugin reference counting.
include/hash.h:
New flag for HASH
HASH_UNIQUE
include/my_getopt.h:
New data types for options: ENUM and SET.
Use typelib to enumerate possible values.
New flag variable:
my_getopt_skip_unknown
include/my_sys.h:
change to DYNAMIC_ARRAY init functions to support pre-allocated buffers
include/mysql.h:
relocate inclusion of typelib due to longlong requirement
include/mysql/plugin.h:
wl2936
New declarations for plugin server variable support.
New functions for use by plugins
include/mysys_err.h:
new my_getopt return value: EXIT_ARGUMENT_INVALID
include/typelib.h:
new typelib function: find_typeset(), returns an int which is a SET of
the elements in the typelib
mysql-test/r/im_utils.result:
change to more specific command line settings
--skip-innodb => --skip-plugin-innodb
etc.
mysql-test/r/log_tables.result:
set default storage engine to MEMORY so that test will succeed even
when some of the other named storage engines are not present
mysql-test/r/ndb_dd_basic.result:
change in error message
mysql-test/r/partition_innodb.result:
change in results
mysql-test/r/ps_1general.result:
bdb doesn't exist, use myisam for a non-transactional engine
mysql-test/r/variables.result:
information schema doesn't sort row results for server variables.
mysql-test/t/log_tables.test:
set default storage engine to MEMORY so that test will succeed even
when some of the other named storage engines are not present
mysql-test/t/ndb_dd_basic.test:
ALTER LOGFILE GROUP no longer silently fail here
mysql-test/t/partition_innodb.test:
ALTER TABLE no longer silently fails for unknown storage engine
mysql-test/t/ps_1general.test:
remove unneccessary parts
use myisam as it is an always present non-transactional engine
mysql-test/t/variables.test:
information schema doesn't sort row results for server variables.
mysql-test/t/warnings_engine_disabled-master.opt:
use the new style command line option
mysys/array.c:
change to DYNAMIC_ARRAY init functions to support pre-allocated buffers
mysys/hash.c:
New flag for HASH
HASH_UNIQUE
Implement HASH_UNIQUE functionality by performing a hash_search
mysys/my_getopt.c:
New data types for options: ENUM and SET.
Use typelib to enumerate possible values.
New flag variable:
my_getopt_skip_unknown
mysys/typelib.c:
new typelib function: find_typeset(), returns an int which is a SET of
the elements in the typelib
sql/ha_ndbcluster.cc:
use ha_statistic_increment() method instead of
statistic_increment() function
ha_ndbcluster variable has gone away.
sql/ha_partition.cc:
fix for reference counting
sql/ha_partition.h:
fix for reference counting
sql/handler.cc:
fixes for reference counting
sql/handler.h:
fixes for reference counting
some new methods to aid storage engine writers
sql/item_func.cc:
find_sys_var() function now requires thd
sql/item_sum.cc:
fixes for ref counting
sql/mysql_priv.h:
remove unneccessary globals.
new lock: LOCK_system_variables_hash
sql/mysqld.cc:
Remove InnoBase specific code.
Support plugin command line processing.
sql/set_var.cc:
Remove InnoBase specific declarations
Remove redundant declarations
changes to permit new variables at run time
changes for ref counting
sql/set_var.h:
changes to permit new variables at run time
changes for ref counting
sql/sql_base.cc:
changes for ref counting
sql/sql_cache.cc:
mark code as needing work in the future
sql/sql_class.cc:
new functions to aid plugin authors
initialize variables for dynamic plugin variables
sql/sql_class.h:
remove InnoBase specific declarations
New declarations for plugin variables.
sql/sql_connect.cc:
initialization and cleanup of plugin variables
sql/sql_delete.cc:
change for ref counting
sql/sql_insert.cc:
change for ref counting
sql/sql_lex.cc:
changes for ref counting and plugin variables
sql/sql_lex.h:
add properties for plugin ref counting,
add to distructor to clean up
sql/sql_partition.cc:
changes for ref counting
sql/sql_plugin.cc:
WL2936
Plugin Variables
New methods and code to support server variables for plugins.
New code to complete plugin reference counting
Debug code adds further indirection so that malloc debugging can be
used to aid finding plugin ref count leaks
sql/sql_plugin.h:
WL2936
Plugin Variables
New methods and code to support server variables for plugins.
New code to complete plugin reference counting
Debug code adds further indirection so that malloc debugging can be
used to aid finding plugin ref count leaks
sql/sql_repl.cc:
replication system variables moved here from set_var.cc
sql/sql_repl.h:
new function to initialise replication server variables
sql/sql_select.cc:
changes for ref counting
sql/sql_show.cc:
changes for ref counting
sql/sql_table.cc:
changes for ref counting
sql/sql_tablespace.cc:
use supplied functions instead of digging into data structures manually
sql/sql_yacc.yy:
changes for ref counting
find_sys_var() now requires thd parameter
changes on reporting errors to keep user-visible behaviour the same.
sql/structs.h:
changes for ref counting
sql/table.cc:
changes for ref counting
sql/table.h:
changes for ref counting
storage/federated/ha_federated.cc:
use ha_statistic_increment() method instead of statistic_increment()
function
storage/heap/ha_heap.cc:
use ha_statistic_increment() method instead of statistic_increment()
function
storage/innobase/handler/ha_innodb.cc:
use ha_statistic_increment() method instead of statistic_increment()
function
WL2936
Move InnoBase specific code out of mysqld.cc and into here
Declare all required server variables for InnoBase
storage/innobase/include/trx0trx.h:
store a bit more state so that InnoBase does not have to dig into
mysqld internal data structures.
storage/myisam/ha_myisam.cc:
use ha_statistic_increment() method instead of statistic_increment()
function
storage/myisammrg/ha_myisammrg.cc:
use ha_statistic_increment() method instead of statistic_increment()
function
This commit is contained in:
parent
1eb71c68cb
commit
1fc7f2117b
62 changed files with 4555 additions and 2163 deletions
|
|
@ -77,24 +77,24 @@ append_algorithm(TABLE_LIST *table, String *buff);
|
|||
** List all table types supported
|
||||
***************************************************************************/
|
||||
|
||||
static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
|
||||
static my_bool show_handlerton(THD *thd, plugin_ref plugin,
|
||||
void *arg)
|
||||
{
|
||||
handlerton *default_type= (handlerton *) arg;
|
||||
Protocol *protocol= thd->protocol;
|
||||
handlerton *hton= (handlerton *)plugin->data;
|
||||
handlerton *hton= plugin_data(plugin, handlerton *);
|
||||
|
||||
if (!(hton->flags & HTON_HIDDEN))
|
||||
{
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(plugin->name.str, plugin->name.length,
|
||||
protocol->store(plugin_name(plugin)->str, plugin_name(plugin)->length,
|
||||
system_charset_info);
|
||||
const char *option_name= show_comp_option_name[(int) hton->state];
|
||||
|
||||
if (hton->state == SHOW_OPTION_YES && default_type == hton)
|
||||
option_name= "DEFAULT";
|
||||
protocol->store(option_name, system_charset_info);
|
||||
protocol->store(plugin->plugin->descr, system_charset_info);
|
||||
protocol->store(plugin_decl(plugin)->descr, system_charset_info);
|
||||
protocol->store(hton->commit ? "YES" : "NO", system_charset_info);
|
||||
protocol->store(hton->prepare ? "YES" : "NO", system_charset_info);
|
||||
protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info);
|
||||
|
|
@ -122,7 +122,7 @@ bool mysqld_show_storage_engines(THD *thd)
|
|||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (plugin_foreach(thd, show_handlerton,
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN, thd->variables.table_type))
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN, ha_default_handlerton(thd)))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
send_eof(thd);
|
||||
|
|
@ -134,24 +134,26 @@ static int make_version_string(char *buf, int buf_length, uint version)
|
|||
return my_snprintf(buf, buf_length, "%d.%d", version>>8,version&0xff);
|
||||
}
|
||||
|
||||
static my_bool show_plugins(THD *thd, st_plugin_int *plugin,
|
||||
static my_bool show_plugins(THD *thd, plugin_ref plugin,
|
||||
void *arg)
|
||||
{
|
||||
TABLE *table= (TABLE*) arg;
|
||||
struct st_mysql_plugin *plug= plugin->plugin;
|
||||
struct st_mysql_plugin *plug= plugin_decl(plugin);
|
||||
struct st_plugin_dl *plugin_dl= plugin_dlib(plugin);
|
||||
CHARSET_INFO *cs= system_charset_info;
|
||||
char version_buf[20];
|
||||
|
||||
restore_record(table, s->default_values);
|
||||
|
||||
table->field[0]->store(plugin->name.str, plugin->name.length, cs);
|
||||
table->field[0]->store(plugin_name(plugin)->str,
|
||||
plugin_name(plugin)->length, cs);
|
||||
|
||||
table->field[1]->store(version_buf,
|
||||
make_version_string(version_buf, sizeof(version_buf), plug->version),
|
||||
cs);
|
||||
|
||||
|
||||
switch (plugin->state) {
|
||||
switch (plugin_state(plugin)) {
|
||||
/* case PLUGIN_IS_FREED: does not happen */
|
||||
case PLUGIN_IS_DELETED:
|
||||
table->field[2]->store(STRING_WITH_LEN("DELETED"), cs);
|
||||
|
|
@ -173,14 +175,13 @@ static my_bool show_plugins(THD *thd, st_plugin_int *plugin,
|
|||
make_version_string(version_buf, sizeof(version_buf),
|
||||
*(uint *)plug->info), cs);
|
||||
|
||||
if (plugin->plugin_dl)
|
||||
if (plugin_dl)
|
||||
{
|
||||
table->field[5]->store(plugin->plugin_dl->dl.str,
|
||||
plugin->plugin_dl->dl.length, cs);
|
||||
table->field[5]->store(plugin_dl->dl.str, plugin_dl->dl.length, cs);
|
||||
table->field[5]->set_notnull();
|
||||
table->field[6]->store(version_buf,
|
||||
make_version_string(version_buf, sizeof(version_buf),
|
||||
plugin->plugin_dl->version),
|
||||
plugin_dl->version),
|
||||
cs);
|
||||
table->field[6]->set_notnull();
|
||||
}
|
||||
|
|
@ -1236,9 +1237,9 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
store_key_options(thd, packet, table, key_info);
|
||||
if (key_info->parser)
|
||||
{
|
||||
LEX_STRING *parser_name= plugin_name(key_info->parser);
|
||||
packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER "));
|
||||
append_identifier(thd, packet, key_info->parser->name.str,
|
||||
key_info->parser->name.length);
|
||||
append_identifier(thd, packet, parser_name->str, parser_name->length);
|
||||
packet->append(STRING_WITH_LEN(" */ "));
|
||||
}
|
||||
}
|
||||
|
|
@ -1933,6 +1934,18 @@ void init_status_vars()
|
|||
sort_dynamic(&all_status_vars, show_var_cmp);
|
||||
}
|
||||
|
||||
void reset_status_vars()
|
||||
{
|
||||
SHOW_VAR *ptr= (SHOW_VAR*) all_status_vars.buffer;
|
||||
SHOW_VAR *last= ptr + all_status_vars.elements;
|
||||
for (; ptr < last; ptr++)
|
||||
{
|
||||
/* Note that SHOW_LONG_NOFLUSH variables are not reset */
|
||||
if (ptr->type == SHOW_LONG)
|
||||
*(ulong*) ptr->value= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
catch-all cleanup function, cleans up everything no matter what
|
||||
|
||||
|
|
@ -2063,6 +2076,8 @@ static bool show_status_array(THD *thd, const char *wild,
|
|||
char *value=var->value;
|
||||
const char *pos, *end; // We assign a lot of const's
|
||||
|
||||
pthread_mutex_lock(&LOCK_global_system_variables);
|
||||
|
||||
if (show_type == SHOW_SYS)
|
||||
{
|
||||
show_type= ((sys_var*) value)->show_type();
|
||||
|
|
@ -2145,6 +2160,9 @@ static bool show_status_array(THD *thd, const char *wild,
|
|||
system_charset_info);
|
||||
table->field[1]->store(pos, (uint32) (end - pos), system_charset_info);
|
||||
table->field[1]->set_notnull();
|
||||
|
||||
pthread_mutex_unlock(&LOCK_global_system_variables);
|
||||
|
||||
if (schema_table_store_record(thd, table))
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
|
@ -2455,13 +2473,13 @@ struct st_add_schema_table
|
|||
const char *wild;
|
||||
};
|
||||
|
||||
static my_bool add_schema_table(THD *thd, st_plugin_int *plugin,
|
||||
static my_bool add_schema_table(THD *thd, plugin_ref plugin,
|
||||
void* p_data)
|
||||
{
|
||||
st_add_schema_table *data= (st_add_schema_table *)p_data;
|
||||
List<char> *file_list= data->files;
|
||||
const char *wild= data->wild;
|
||||
ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
|
||||
ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
|
||||
DBUG_ENTER("add_schema_table");
|
||||
|
||||
if (schema_table->hidden)
|
||||
|
|
@ -2995,7 +3013,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
|
|||
ha_row_type[(uint) share->row_type],
|
||||
NullS);
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (show_table->s->db_type == partition_hton &&
|
||||
if (show_table->s->db_type() == partition_hton &&
|
||||
show_table->part_info != NULL &&
|
||||
show_table->part_info->no_parts > 0)
|
||||
ptr= strmov(ptr, " partitioned");
|
||||
|
|
@ -3270,19 +3288,20 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
}
|
||||
|
||||
|
||||
static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
|
||||
static my_bool iter_schema_engines(THD *thd, plugin_ref plugin,
|
||||
void *ptable)
|
||||
{
|
||||
TABLE *table= (TABLE *) ptable;
|
||||
handlerton *hton= (handlerton *)plugin->data;
|
||||
handlerton *hton= plugin_data(plugin, handlerton *);
|
||||
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
|
||||
CHARSET_INFO *scs= system_charset_info;
|
||||
DBUG_ENTER("iter_schema_engines");
|
||||
|
||||
if (!(hton->flags & HTON_HIDDEN))
|
||||
{
|
||||
LEX_STRING *name= plugin_name(plugin);
|
||||
if (!(wild && wild[0] &&
|
||||
wild_case_compare(scs, plugin->name.str,wild)))
|
||||
wild_case_compare(scs, name->str,wild)))
|
||||
{
|
||||
LEX_STRING state[2]= {{ C_STRING_WITH_LEN("ENABLED") },
|
||||
{ C_STRING_WITH_LEN("DISABLED") }};
|
||||
|
|
@ -3291,11 +3310,11 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
|
|||
LEX_STRING *tmp;
|
||||
restore_record(table, s->default_values);
|
||||
|
||||
table->field[0]->store(plugin->name.str, plugin->name.length, scs);
|
||||
table->field[0]->store(name->str, name->length, scs);
|
||||
tmp= &state[test(hton->state)];
|
||||
table->field[1]->store(tmp->str, tmp->length, scs);
|
||||
table->field[2]->store(plugin->plugin->descr,
|
||||
strlen(plugin->plugin->descr), scs);
|
||||
table->field[2]->store(plugin_decl(plugin)->descr,
|
||||
strlen(plugin_decl(plugin)->descr), scs);
|
||||
tmp= &yesno[test(hton->commit)];
|
||||
table->field[3]->store(tmp->str, tmp->length, scs);
|
||||
tmp= &yesno[test(hton->prepare)];
|
||||
|
|
@ -4464,10 +4483,10 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
int res= 0;
|
||||
LEX *lex= thd->lex;
|
||||
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
|
||||
pthread_mutex_lock(&LOCK_global_system_variables);
|
||||
res= show_status_array(thd, wild, init_vars,
|
||||
rw_rdlock(&LOCK_system_variables_hash);
|
||||
res= show_status_array(thd, wild, enumerate_sys_vars(thd, TRUE),
|
||||
lex->option_type, 0, "", tables->table, 0);
|
||||
pthread_mutex_unlock(&LOCK_global_system_variables);
|
||||
rw_unlock(&LOCK_system_variables_hash);
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
|
@ -4583,12 +4602,12 @@ struct schema_table_ref
|
|||
0 table not found
|
||||
1 found the schema table
|
||||
*/
|
||||
static my_bool find_schema_table_in_plugin(THD *thd, st_plugin_int *plugin,
|
||||
static my_bool find_schema_table_in_plugin(THD *thd, plugin_ref plugin,
|
||||
void* p_table)
|
||||
{
|
||||
schema_table_ref *p_schema_table= (schema_table_ref *)p_table;
|
||||
const char* table_name= p_schema_table->table_name;
|
||||
ST_SCHEMA_TABLE *schema_table= (ST_SCHEMA_TABLE *)plugin->data;
|
||||
ST_SCHEMA_TABLE *schema_table= plugin_data(plugin, ST_SCHEMA_TABLE *);
|
||||
DBUG_ENTER("find_schema_table_in_plugin");
|
||||
|
||||
if (!my_strcasecmp(system_charset_info,
|
||||
|
|
@ -5125,12 +5144,12 @@ struct run_hton_fill_schema_files_args
|
|||
COND *cond;
|
||||
};
|
||||
|
||||
static my_bool run_hton_fill_schema_files(THD *thd, st_plugin_int *plugin,
|
||||
static my_bool run_hton_fill_schema_files(THD *thd, plugin_ref plugin,
|
||||
void *arg)
|
||||
{
|
||||
struct run_hton_fill_schema_files_args *args=
|
||||
(run_hton_fill_schema_files_args *) arg;
|
||||
handlerton *hton= (handlerton *)plugin->data;
|
||||
handlerton *hton= plugin_data(plugin, handlerton *);
|
||||
if(hton->fill_files_table && hton->state == SHOW_OPTION_YES)
|
||||
hton->fill_files_table(hton, thd, args->tables, args->cond);
|
||||
return false;
|
||||
|
|
@ -5296,10 +5315,10 @@ int fill_schema_global_variables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
int res= 0;
|
||||
DBUG_ENTER("fill_schema_global_variables");
|
||||
|
||||
pthread_mutex_lock(&LOCK_global_system_variables);
|
||||
res= show_status_array(thd, "", init_vars, OPT_GLOBAL,
|
||||
rw_rdlock(&LOCK_system_variables_hash);
|
||||
res= show_status_array(thd, "", enumerate_sys_vars(thd, FALSE), OPT_GLOBAL,
|
||||
NULL, "", tables->table, 1);
|
||||
pthread_mutex_unlock(&LOCK_global_system_variables);
|
||||
rw_unlock(&LOCK_system_variables_hash);
|
||||
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
|
@ -5309,10 +5328,10 @@ int fill_schema_session_variables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
int res= 0;
|
||||
DBUG_ENTER("fill_schema_session_variables");
|
||||
|
||||
pthread_mutex_lock(&LOCK_global_system_variables);
|
||||
res= show_status_array(thd, "", init_vars, OPT_SESSION,
|
||||
rw_rdlock(&LOCK_system_variables_hash);
|
||||
res= show_status_array(thd, "", enumerate_sys_vars(thd, FALSE), OPT_SESSION,
|
||||
NULL, "", tables->table, 1);
|
||||
pthread_mutex_unlock(&LOCK_global_system_variables);
|
||||
rw_unlock(&LOCK_system_variables_hash);
|
||||
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue