WL#10806: Component status variables as a service for mysql_server component (sub-worklog for wl6667)

Affects: Server-8.0   —   Status: Complete

This worklog will provide the component status variables as a service to the
mysql_server component. The components can use to register, unregister and
get_variable to handle their own status variables.
1. This work will only apply to the status variables defined by components. The
status variables defined by the server component or any of the plugins it
operated are going to behave as they currently do.
2. The component status variables will be added as status variables to the
global names space of status variables.
3. The mysql_server component will provide a status variable
registration/deregistration service for components to register/deregister their
variables.
4. At component unload time we will unregister all component status variables
from the global status variables list, thus making future references to them
unresolvable
5. To display the registered status variable below command will be used.
   SHOW [ GLOBAL | SESSION ] STATUS [LIKE 'pattern' | WHERE expr] 
This service will have two methods, to register and unregister component status
variable. 

The component status variables are in the form of
.
With register_variable() api the variable is stored in the global structure
all_status_vars and with unregister_variable() api, the variable is removed from
the global structure.
 
components/mysql_server/server_component.cc
BEGIN_SERVICE_IMPLEMENTATION(mysql_server, status_variable_registration)
  status_variable_registration_imp::register_variable,
  status_variable_registration_imp::unregister_variable,
END_SERVICE_IMPLEMENTATION()

/**
  Component status variables as a service to mysql_server component
*/

/**
  Service to register variable, and unregister variable.
*/
BEGIN_SERVICE_DEFINITION(status_variable_registration)

  /**
    Register status variable.

    Note: pass the variable address as char * for all the variable types. And
    for STATUS_VAR_FUNC var_type, pass the function pointer to the char *

    @param  status_var fully constructed status variable object.
    @return Status of performed operation
    @retval false success
    @retval true failure
  */
  DECLARE_BOOL_METHOD(register_variable,
  (STATUS_VAR *status_var));

  /**
    Unregister's status variable.
    @param  status_var STATUS_VAR object with only the name of the variable,
                       which has to be removed from the global list.
    @return Status of performed operation
    @retval false success
    @retval true failure
  */
  DECLARE_BOOL_METHOD(unregister_variable,
  (STATUS_VAR *status_var));

END_SERVICE_DEFINITION(status_variable_registration)



sql/server_component/component_show_var_service.cc
/**
  Register status variable.

  Note: pass the variable address as char * for all the variable types. And
  for STATUS_VAR_FUNC var_type, pass the function pointer to the char *

  @param  status_var fully constructed status variable object.
  @return Status of performed operation
  @retval false success
  @retval true failure
*/

  DEFINE_BOOL_METHOD(mysql_status_variable_registration_imp::register_variable,
  (STATUS_VAR *status_var))
  {
     This function will get the prepared STATUS_VAR object.
     call all_status_vars, to add the status variable into the all_status_var
     object.
  }

/**
  Unregister's status variable.
  @param  status_var STATUS_VAR object with only the name of the variable,
                     which has to be removed from the global list.
  @return Status of performed operation
  @retval false success
  @retval true failure
*/

  DEFINE_BOOL_METHOD(mysql_status_variable_registration_imp::unregister_variable,
  (STATUS_VAR *status_var))
  {
     This function will get the status variable name in STATUS_VAR structure  
     objecct.
     call remove_status_vars() to remove the status variable
     from the all_status_vars
  }