Commit 031ee043 authored by unknown's avatar unknown
Browse files

WL#2935 - SHOW STATUS support in plugins

The patch adds DYNAMIC_ARRAY all_status_vars, which is now the
sole source of status information for SHOW STATUS.  Status
variables can be added to and removed from the array dynamically.
SHOW STATUS command uses this array instead of static array
from mysqld.cc
Compatibility with the old, global list of status variables is
preserved in init_server_components(), where this global list is
simply appended to all_status_vars.


include/plugin.h:
  WL#2935 - SHOW STATUS support in plugins
plugin/fulltext/plugin_example.c:
  WL#2935 - SHOW STATUS support in plugins
  example
sql/ha_innodb.cc:
  s/struct show_var_st/SHOW_VAR/
sql/ha_innodb.h:
  s/struct show_var_st/SHOW_VAR/
sql/mysql_priv.h:
  WL#2935 - SHOW STATUS support in plugins
  add_status_vars(), remove_status_vars()
sql/mysqld.cc:
  bug: plugin_free must be called even with --skip-grants
  add_status_vars()/free_status_vars(), remove unused SHOW_xxx_CONST
  s/struct show_var_st/SHOW_VAR/
sql/set_var.cc:
  s/struct show_var_st/SHOW_VAR/
sql/sql_parse.cc:
  s/struct show_var_st/SHOW_VAR/
sql/sql_plugin.cc:
  WL#2935 - SHOW STATUS support in plugins
sql/sql_plugin.h:
  WL#2935 - SHOW STATUS support in plugins
sql/sql_show.cc:
  WL#2935 - SHOW STATUS support in plugins
  DYNAMIC_ARRAY all_status_vars, add_status_vars(), remove_status_vars()
  s/struct show_var_st/SHOW_VAR/
sql/structs.h:
  WL#2935 - SHOW STATUS support in plugins
  SHOW STATUS definitions moved to include/plugin.h and sql_plugin.h
  s/struct show_var_st/SHOW_VAR/
parent 88469c80
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -41,7 +41,26 @@
int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \
int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin); \
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0}}
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0}}

/*
  declarations for SHOW STATUS support in plugins
*/
enum enum_mysql_show_type
{
  SHOW_UNDEF, SHOW_BOOL, SHOW_MY_BOOL, SHOW_INT, SHOW_LONG,
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
  SHOW_ARRAY, SHOW_FUNC
};

struct st_mysql_show_var {
  const char *name;
  char *value;
  enum enum_mysql_show_type type;
};

#define SHOW_VAR_FUNC_BUFF_SIZE 1024
typedef int (*mysql_show_var_func)(void *, struct st_mysql_show_var*, char *);

/*
  Plugin description structure.
@@ -57,6 +76,7 @@ struct st_mysql_plugin
  int (*init)(void);    /* the function to invoke when plugin is loaded */
  int (*deinit)(void);  /* the function to invoke when plugin is unloaded */
  uint version;         /* plugin version (for SHOW PLUGINS)            */
  struct st_mysql_show_var *status_vars;
};

/*************************************************************************
+17 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include <m_ctype.h>
#include <plugin.h>

long number_of_calls= 0; /* for SHOW STATUS, see below */

/*
  Simple full-text parser plugin that acts as a replacement for the
  built-in full-text parser:
@@ -167,6 +169,8 @@ int simple_parser_parse(MYSQL_FTPARSER_PARAM *param)
{
  char *end, *start, *docend= param->doc + param->length;

  number_of_calls++;

  for (end= start= param->doc;; end++)
  {
    if (end == docend)
@@ -198,6 +202,16 @@ static struct st_mysql_ftparser simple_parser_descriptor=
  simple_parser_deinit              /* parser deinit function */
};

/*
  Plugin status variables for SHOW STATUS
*/

struct st_mysql_show_var simple_status[]=
{
  {"static",     "just a static text",     SHOW_CHAR},
  {"called",     (char *)&number_of_calls, SHOW_LONG},
  {0,0,0}
};

/*
  Plugin library descriptor
@@ -211,6 +225,8 @@ mysql_declare_plugin
  "MySQL AB",                 /* author                          */
  "Simple Full-Text Parser",  /* description                     */
  simple_parser_plugin_init,  /* init function (when loaded)     */
  simple_parser_plugin_deinit /* deinit function (when unloaded) */
  simple_parser_plugin_deinit,/* deinit function (when unloaded) */
  0x0001,                     /* version                         */
  &simple_status              /* status variables                */
}
mysql_declare_plugin_end;
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ innobase_commit_low(
/*================*/
	trx_t*	trx);	/* in: transaction handle */

struct show_var_st innodb_status_variables[]= {
SHOW_VAR innodb_status_variables[]= {
  {"buffer_pool_pages_data",
  (char*) &export_vars.innodb_buffer_pool_pages_data,     SHOW_LONG},
  {"buffer_pool_pages_dirty",
+1 −1
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ class ha_innobase: public handler
					uint table_changes);
};

extern struct show_var_st innodb_status_variables[];
extern SHOW_VAR innodb_status_variables[];
extern uint innobase_init_flags, innobase_lock_type;
extern uint innobase_flush_log_at_trx_commit;
extern ulong innobase_cache_size, innobase_fast_shutdown;
+9 −7
Original line number Diff line number Diff line
@@ -513,13 +513,11 @@ void free_items(Item *item);
void cleanup_items(Item *item);
class THD;
void close_thread_tables(THD *thd, bool locked=0, bool skip_derived=0);
bool check_one_table_access(THD *thd, ulong privilege,
			   TABLE_LIST *tables);
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
			  bool is_proc, bool no_errors);
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
bool check_merge_table_access(THD *thd, char *db,
			      TABLE_LIST *table_list);
bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list);
bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
@@ -884,6 +882,10 @@ void calc_sum_of_all_status(STATUS_VAR *to);
void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
                    const LEX_STRING *definer_host);

int add_status_vars(SHOW_VAR *list);
void remove_status_vars(SHOW_VAR *list);
void init_status_vars();
void free_status_vars();

/* information schema */
extern LEX_STRING information_schema_name;
Loading