put status variables in the proper pluginname_ scope

(but support the scopeless mysql style too).
always output status/system variables in the correct lettercase
This commit is contained in:
Sergei Golubchik 2013-04-09 23:27:33 +02:00
parent c7eead7a96
commit 775e82638b
12 changed files with 49 additions and 118 deletions

View File

@ -44,7 +44,7 @@ set global example_ulong_var=500;
set global example_enum_var= e1;
show status like 'example%';
Variable_name Value
example_func_example enum_var is 0, ulong_var is 500, really
Example_func_example enum_var is 0, ulong_var is 500, really
show variables like 'example%';
Variable_name Value
example_enum_var e1

View File

@ -9,8 +9,8 @@ ERROR 42S22: Unknown column 'foobar' in 'field list'
show status like 'audit_null%';
Variable_name Value
Audit_null_called 9
Audit_null_general_error 1
Audit_null_general_log 3
Audit_null_general_error 1
Audit_null_general_result 2
create procedure au1(x char(16)) select concat("test1", x);
call au1("-12");
@ -19,8 +19,8 @@ test1-12
show status like 'audit_null%';
Variable_name Value
Audit_null_called 19
Audit_null_general_error 1
Audit_null_general_log 7
Audit_null_general_error 1
Audit_null_general_result 5
uninstall plugin audit_null;
Warnings:

View File

@ -127,12 +127,10 @@ static struct st_mysql_audit audit_null_descriptor=
static struct st_mysql_show_var simple_status[]=
{
{ "Audit_null_called", (char *) &number_of_calls, SHOW_INT },
{ "Audit_null_general_log", (char *) &number_of_calls_general_log, SHOW_INT },
{ "Audit_null_general_error", (char *) &number_of_calls_general_error,
SHOW_INT },
{ "Audit_null_general_result", (char *) &number_of_calls_general_result,
SHOW_INT },
{ "called", (char *) &number_of_calls, SHOW_INT },
{ "general_log", (char *) &number_of_calls_general_log, SHOW_INT },
{ "general_error", (char *) &number_of_calls_general_error, SHOW_INT },
{ "general_result", (char *) &number_of_calls_general_result, SHOW_INT },
{ 0, 0, 0}
};

View File

@ -85,23 +85,6 @@ static struct st_mysql_auth socket_auth_handler=
socket_auth
};
mysql_declare_plugin(socket_auth)
{
MYSQL_AUTHENTICATION_PLUGIN,
&socket_auth_handler,
"unix_socket",
"Sergei Golubchik",
"Unix Socket based authentication",
PLUGIN_LICENSE_GPL,
NULL,
NULL,
0x0100,
NULL,
NULL,
NULL,
0,
}
mysql_declare_plugin_end;
maria_declare_plugin(socket_auth)
{
MYSQL_AUTHENTICATION_PLUGIN,

View File

@ -188,23 +188,6 @@ struct st_mysql_daemon daemon_example_plugin=
Plugin library descriptor
*/
mysql_declare_plugin(daemon_example)
{
MYSQL_DAEMON_PLUGIN,
&daemon_example_plugin,
"daemon_example",
"Brian Aker",
"Daemon example, creates a heartbeat beat file in mysql-heartbeat.log",
PLUGIN_LICENSE_GPL,
daemon_example_plugin_init, /* Plugin Init */
daemon_example_plugin_deinit, /* Plugin Deinit */
0x0100 /* 1.0 */,
NULL, /* status variables */
NULL, /* system variables */
NULL, /* config options */
0, /* flags */
}
mysql_declare_plugin_end;
maria_declare_plugin(daemon_example)
{
MYSQL_DAEMON_PLUGIN,

View File

@ -254,24 +254,6 @@ static struct st_mysql_sys_var* simple_system_variables[]= {
Plugin library descriptor
*/
mysql_declare_plugin(ftexample)
{
MYSQL_FTPARSER_PLUGIN, /* type */
&simple_parser_descriptor, /* descriptor */
"simple_parser", /* name */
"Sergei Golubchik", /* author */
"Simple Full-Text Parser", /* description */
PLUGIN_LICENSE_GPL,
simple_parser_plugin_init, /* init function (when loaded) */
simple_parser_plugin_deinit,/* deinit function (when unloaded) */
0x0001, /* version */
simple_status, /* status variables */
simple_system_variables, /* system variables */
NULL,
0,
}
mysql_declare_plugin_end;
maria_declare_plugin(ftexample)
{
MYSQL_FTPARSER_PLUGIN, /* type */

View File

@ -144,24 +144,6 @@ static struct st_mysql_audit descriptor =
{ MYSQL_AUDIT_GENERAL_CLASSMASK }
};
mysql_declare_plugin(sql_errlog)
{
MYSQL_AUDIT_PLUGIN,
&descriptor,
"SQL_ERROR_LOG",
"Alexey Botchkov",
"Log SQL level errors to a file with rotation",
PLUGIN_LICENSE_GPL,
sql_error_log_init,
sql_error_log_deinit,
0x0100,
NULL,
vars,
NULL,
0
}
mysql_declare_plugin_end;
maria_declare_plugin(sql_errlog)
{
MYSQL_AUDIT_PLUGIN,

View File

@ -1133,22 +1133,21 @@ static void plugin_deinitialize(struct st_plugin_int *plugin, bool ref_check)
if (plugin->plugin->status_vars)
{
#ifdef FIX_LATER
/**
@todo
unfortunately, status variables were introduced without a
pluginname_ namespace, that is pluginname_ was not added automatically
to status variable names. It should be fixed together with the next
incompatible API change.
/*
historical ndb behavior caused MySQL plugins to specify
status var names in full, with the plugin name prefix.
this was never fixed in MySQL.
MariaDB fixes that but support MySQL style too.
*/
SHOW_VAR array[2]= {
SHOW_VAR *show_vars= plugin->plugin->status_vars;
SHOW_VAR tmp_array[2]= {
{plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},
{0, 0, SHOW_UNDEF}
};
remove_status_vars(array);
#else
remove_status_vars(plugin->plugin->status_vars);
#endif /* FIX_LATER */
if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length))
show_vars= tmp_array;
remove_status_vars(show_vars);
}
if (plugin_type_deinitialize[plugin->plugin->type])
@ -1358,24 +1357,22 @@ static int plugin_initialize(struct st_plugin_int *plugin)
if (plugin->plugin->status_vars)
{
#ifdef FIX_LATER
/*
We have a problem right now where we can not prepend without
breaking backwards compatibility. We will fix this shortly so
that engines have "use names" and we wil use those for
CREATE TABLE, and use the plugin name then for adding automatic
variable names.
historical ndb behavior caused MySQL plugins to specify
status var names in full, with the plugin name prefix.
this was never fixed in MySQL.
MariaDB fixes that, but supports MySQL style too.
*/
SHOW_VAR array[2]= {
SHOW_VAR *show_vars= plugin->plugin->status_vars;
SHOW_VAR tmp_array[2]= {
{plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY},
{0, 0, SHOW_UNDEF}
};
if (add_status_vars(array)) // add_status_vars makes a copy
if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length))
show_vars= tmp_array;
if (add_status_vars(show_vars))
goto err;
#else
if (add_status_vars(plugin->plugin->status_vars))
goto err;
#endif /* FIX_LATER */
}
/*

View File

@ -2626,7 +2626,7 @@ static bool status_vars_inited= 0;
C_MODE_START
static int show_var_cmp(const void *var1, const void *var2)
{
return strcmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name);
return strcasecmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name);
}
C_MODE_END
@ -2831,6 +2831,17 @@ static bool show_status_array(THD *thd, const char *wild,
name_buffer[sizeof(name_buffer)-1]=0; /* Safety */
if (ucase_names)
my_caseup_str(system_charset_info, name_buffer);
else
{
my_casedn_str(system_charset_info, name_buffer);
DBUG_ASSERT(name_buffer[0] >= 'a');
DBUG_ASSERT(name_buffer[0] <= 'z');
/* traditionally status variables have a first letter uppercased */
if (status_var)
name_buffer[0]-= 'a' - 'A';
}
restore_record(table, s->default_values);
table->field[0]->store(name_buffer, strlen(name_buffer),

View File

@ -2568,21 +2568,21 @@ struct st_mysql_storage_engine cassandra_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
static SHOW_VAR cassandra_status_variables[]= {
{"Cassandra_row_inserts",
{"row_inserts",
(char*) &cassandra_counters.row_inserts, SHOW_LONG},
{"Cassandra_row_insert_batches",
{"row_insert_batches",
(char*) &cassandra_counters.row_insert_batches, SHOW_LONG},
{"Cassandra_multiget_keys_scanned",
{"multiget_keys_scanned",
(char*) &cassandra_counters.multiget_keys_scanned, SHOW_LONG},
{"Cassandra_multiget_reads",
{"multiget_reads",
(char*) &cassandra_counters.multiget_reads, SHOW_LONG},
{"Cassandra_multiget_rows_read",
{"multiget_rows_read",
(char*) &cassandra_counters.multiget_rows_read, SHOW_LONG},
{"Cassandra_timeout_exceptions",
{"timeout_exceptions",
(char*) &cassandra_counters.timeout_exceptions, SHOW_LONG},
{"Cassandra_unavailable_exceptions",
{"unavailable_exceptions",
(char*) &cassandra_counters.unavailable_exceptions, SHOW_LONG},
{NullS, NullS, SHOW_LONG}
};

View File

@ -1117,7 +1117,7 @@ static int show_func_example(MYSQL_THD thd, struct st_mysql_show_var *var,
static struct st_mysql_show_var func_status[]=
{
{"example_func_example", (char *)show_func_example, SHOW_SIMPLE_FUNC},
{"func_example", (char *)show_func_example, SHOW_SIMPLE_FUNC},
{0,0,SHOW_UNDEF}
};

View File

@ -3753,11 +3753,6 @@ SHOW_VAR status_variables[]= {
{NullS, NullS, SHOW_LONG}
};
static struct st_mysql_show_var aria_status_variables[]= {
{"Aria", (char*) &status_variables, SHOW_ARRAY},
{NullS, NullS, SHOW_LONG}
};
/****************************************************************************
* Maria MRR implementation: use DS-MRR
***************************************************************************/
@ -3832,7 +3827,7 @@ maria_declare_plugin(aria)
ha_maria_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0105, /* 1.5 */
aria_status_variables, /* status variables */
status_variables, /* status variables */
system_variables, /* system variables */
"1.5", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */