Databases Reference
In-Depth Information
Type
C type
SHOW_ARRAY
st_mysql_show_var *
SHOW_FUNC
int (*)(MYSQL_THD,
struct st_mysql_show_var*, char *)
The last two types are special. Elements of these types do not define rows in
SHOW STATUS , they define other elements of the st_mysql_show_var structure.
SHOW_ARRAY specifies that value is not really a value, but a pointer to another
zero-terminated array of status variables. The corresponding name of the SHOW_ARRAY
element will be used as a prefix added to all the names of status variables in the
referenced array. The variables beginning with Com_ in the normal SHOW STATUS
output is an example of this in action.
The SHOW_FUNC function is more interesting. The value is interpreted as a pointer to a
function that generates the st_mysql_show_var structure. This function should have
the following prototype:
int my_status_var(MYSQL_THD thd,
struct st_mysql_show_var *var, char *buff)
The first argument is a pointer to the thread object of the current connection, var
points to a st_mysql_show_var structure that we need to fill in, and buff is a
preallocated 1024-byte buffer. The function needs to set var->type and var->value
(the var->name member will be ignored by MySQL) to form a valid status variable
structure. And if needed, var->type can be set to SHOW_ARRAY or even to SHOW_FUNC
again, and MySQL will handle this situation correctly. A buffer buff is provided as
convenience storage; the function may store the value there and point var->value to
it. The return value of this function is ignored.
So, putting this together we can have something similar to the following to make our
plugin add new status variables to a server:
struct st_mysql_show_var my_status_vars[]=
{
{"data_size", (char *)&data_size, SHOW_LONG},
{"avg_text_size", (char *)&avg_text_size, SHOW_LONGLONG},
{0,0,0}
};
We would then use my_status_vars in the plugin declaration.
Search WWH ::




Custom Search