MySQL  8.0.16
Source Code Documentation
sql_plugin.cc File Reference
#include "sql/sql_plugin.h"
#include "my_config.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "m_ctype.h"
#include "m_string.h"
#include "map_helpers.h"
#include "mutex_lock.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_default.h"
#include "my_getopt.h"
#include "my_inttypes.h"
#include "my_list.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sharedlib.h"
#include "my_sys.h"
#include "my_thread_local.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/components/services/psi_memory_bits.h"
#include "mysql/components/services/psi_mutex_bits.h"
#include "mysql/components/services/system_variable_source_type.h"
#include "mysql/plugin_audit.h"
#include "mysql/plugin_auth.h"
#include "mysql/plugin_clone.h"
#include "mysql/plugin_group_replication.h"
#include "mysql/plugin_keyring.h"
#include "mysql/plugin_validate_password.h"
#include "mysql/psi/mysql_memory.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql/psi/mysql_system.h"
#include "mysql/psi/mysql_thread.h"
#include "mysql/psi/psi_base.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql_com.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/auto_thd.h"
#include "sql/current_thd.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd_schema.h"
#include "sql/dd/info_schema/metadata.h"
#include "sql/dd/string_type.h"
#include "sql/dd_sql_view.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/key.h"
#include "sql/log.h"
#include "sql/mdl.h"
#include "sql/mysqld.h"
#include "sql/persisted_variable.h"
#include "sql/protocol_classic.h"
#include "sql/psi_memory_key.h"
#include "sql/records.h"
#include "sql/row_iterator.h"
#include "sql/set_var.h"
#include "sql/sql_audit.h"
#include "sql/sql_backup_lock.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_parse.h"
#include "sql/sql_plugin_var.h"
#include "sql/sql_show.h"
#include "sql/sql_table.h"
#include "sql/sys_vars_resource_mgr.h"
#include "sql/sys_vars_shared.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql/thr_malloc.h"
#include "sql/transaction.h"
#include "sql_string.h"
#include "template_utils.h"
#include "thr_lock.h"
#include "thr_mutex.h"
#include "typelib.h"
#include <algorithm>
#include <memory>
#include <new>
#include <unordered_map>
#include <utility>
#include "sql/srv_session.h"
#include "sql/sql_plugin_services.h"

Macros

#define REPORT_TO_LOG   1
 
#define REPORT_TO_USER   2
 
#define my_intern_plugin_lock(A, B)   intern_plugin_lock(A, B)
 
#define my_intern_plugin_lock_ci(A, B)   intern_plugin_lock(A, B)
 

Functions

int initialize_schema_table (st_plugin_int *plugin)
 
int finalize_schema_table (st_plugin_int *plugin)
 
static void plugin_load (MEM_ROOT *tmp_root, int *argc, char **argv)
 Reads the plugins from mysql.plugin and loads them. More...
 
static bool plugin_load_list (MEM_ROOT *tmp_root, int *argc, char **argv, const char *list)
 Load a list of plugins. More...
 
static bool check_if_option_is_deprecated (int optid, const struct my_option *opt, char *argument)
 Check option being used and raise deprecation warning if required. More...
 
static int test_plugin_options (MEM_ROOT *tmp_root, st_plugin_int *tmp, int *argc, char **argv)
 Create and register system variables supplied from the plugin and assigns initial values from corresponding command line arguments. More...
 
static bool register_builtin (st_mysql_plugin *, st_plugin_int *, st_plugin_int **)
 
static void unlock_variables (struct System_variables *vars)
 
static void cleanup_variables (THD *thd, struct System_variables *vars)
 
static void plugin_vars_free_values (sys_var *vars)
 Free values of thread variables of a plugin. More...
 
static void plugin_var_memalloc_free (struct System_variables *vars)
 Free all elements allocated by plugin_var_memalloc_session_update(). More...
 
static void restore_pluginvar_names (sys_var *first)
 
static plugin_ref intern_plugin_lock (LEX *lex, plugin_ref plugin)
 
static void intern_plugin_unlock (LEX *lex, plugin_ref plugin)
 
static void reap_plugins (void)
 
malloc_unordered_map< std::string, st_bookmark * > * get_bookmark_hash (void)
 
static void report_error (int where_to, uint error,...)
 
bool check_valid_path (const char *path, size_t len)
 Check if the provided path is valid in the sense that it does cause a relative reference outside the directory. More...
 
static st_plugin_dlplugin_dl_find (const LEX_STRING *dl)
 
static st_plugin_dlplugin_dl_insert_or_reuse (st_plugin_dl *plugin_dl)
 
static void free_plugin_mem (st_plugin_dl *p)
 
static st_plugin_dlplugin_dl_add (const LEX_STRING *dl, int report)
 Loads a dynamic plugin. More...
 
static void plugin_dl_del (const LEX_STRING *dl)
 
static st_plugin_intplugin_find_internal (const LEX_CSTRING &name, int type)
 
static SHOW_COMP_OPTION plugin_status (const LEX_CSTRING &name, int type)
 
bool plugin_is_ready (const LEX_CSTRING &name, int type)
 
SHOW_COMP_OPTION plugin_status (const char *name, size_t len, int type)
 
plugin_ref plugin_lock (THD *thd, plugin_ref *ptr)
 
plugin_ref plugin_lock_by_name (THD *thd, const LEX_CSTRING &name, int type)
 
static st_plugin_intplugin_insert_or_reuse (st_plugin_int *plugin)
 
static bool plugin_add (MEM_ROOT *tmp_root, const LEX_STRING *name, const LEX_STRING *dl, int *argc, char **argv, int report)
 Adds a plugin to the global plugin list. More...
 
static void plugin_deinitialize (st_plugin_int *plugin, bool ref_check)
 
static void plugin_del (st_plugin_int *plugin)
 
void plugin_unlock (THD *thd, plugin_ref plugin)
 
void plugin_unlock_list (THD *thd, plugin_ref *list, size_t count)
 
static int plugin_initialize (st_plugin_int *plugin)
 
static void convert_dash_to_underscore (char *str, size_t len)
 
static void init_plugin_psi_keys (void)
 
static bool plugin_init_internals ()
 Initialize the internals of the plugin system. More...
 
static bool plugin_init_initialize_and_reap ()
 Initialize the plugins. More...
 
bool plugin_register_early_plugins (int *argc, char **argv, int flags)
 Register and initialize early plugins. More...
 
bool plugin_register_builtin_and_init_core_se (int *argc, char **argv)
 Register the builtin plugins. More...
 
bool is_builtin_and_core_se_initialized ()
 
bool plugin_register_dynamic_and_init_all (int *argc, char **argv, int flags)
 Register and initialize the dynamic plugins. More...
 
void memcached_shutdown (void)
 
void plugin_shutdown (void)
 
bool end_transaction (THD *thd, bool error)
 Helper function to do rollback or commit, depending on error. More...
 
bool plugin_early_load_one (int *argc, char **argv, const char *plugin)
 Initialize one plugin. More...
 
static bool mysql_install_plugin (THD *thd, const LEX_STRING *name, const LEX_STRING *dl)
 
static bool mysql_uninstall_plugin (THD *thd, const LEX_STRING *name)
 
bool plugin_foreach_with_mask (THD *thd, plugin_foreach_func **funcs, int type, uint state_mask, void *arg)
 
bool plugin_foreach_with_mask (THD *thd, plugin_foreach_func *func, int type, uint state_mask, void *arg)
 
void lock_plugin_mutex ()
 
void unlock_plugin_mutex ()
 
sys_varfind_sys_var_ex (THD *thd, const char *str, size_t length, bool throw_error, bool locked)
 
sys_varfind_sys_var (THD *thd, const char *str, size_t length)
 
static st_bookmarkregister_var (const char *plugin, const char *name, int flags)
 
void alloc_and_copy_thd_dynamic_variables (THD *thd, bool global_lock)
 Allocate memory and copy dynamic variables from global system variables to per-thread system variables copy. More...
 
static boolmysql_sys_var_bool (THD *thd, int offset)
 For correctness and simplicity's sake, a pointer to a function must be compatible with pointed-to type, that is, the return and parameters types must be the same. More...
 
static int * mysql_sys_var_int (THD *thd, int offset)
 
static unsigned int * mysql_sys_var_uint (THD *thd, int offset)
 
static unsigned long * mysql_sys_var_ulong (THD *thd, int offset)
 
static unsigned long long * mysql_sys_var_ulonglong (THD *thd, int offset)
 
static char ** mysql_sys_var_str (THD *thd, int offset)
 
static double * mysql_sys_var_double (THD *thd, int offset)
 
void plugin_thdvar_init (THD *thd, bool enable_plugins)
 
void plugin_thdvar_cleanup (THD *thd, bool enable_plugins)
 
void plugin_thdvar_safe_update (THD *thd, SYS_VAR *var, char **dest, const char *value)
 Set value for a thread local variable. More...
 
bool get_one_plugin_option (int, const struct my_option *, char *)
 
static int construct_options (MEM_ROOT *mem_root, st_plugin_int *tmp, my_option *options)
 Creates a set of my_option objects associated with a specified plugin- handle. More...
 
static my_optionconstruct_help_options (MEM_ROOT *mem_root, st_plugin_int *p)
 
void add_plugin_options (std::vector< my_option > *options, MEM_ROOT *mem_root)
 
st_plugin_intplugin_find_by_type (const LEX_CSTRING &plugin, int type)
 Searches for a correctly loaded plugin of a particular type by name. More...
 
int lock_plugin_data ()
 Locks the plugin strucutres so calls to plugin_find_inner can be issued. More...
 
int unlock_plugin_data ()
 Unlocks the plugin strucutres as locked by lock_plugin_data() More...
 

Variables

static PSI_memory_key key_memory_plugin_ref
 
static PSI_memory_key key_memory_plugin_mem_root
 
static PSI_memory_key key_memory_plugin_init_tmp
 
static PSI_memory_key key_memory_plugin_int_mem_root
 
static PSI_memory_key key_memory_mysql_plugin
 
static PSI_memory_key key_memory_mysql_plugin_dl
 
static PSI_memory_key key_memory_plugin_bookmark
 
st_mysql_pluginmysql_optional_plugins []
 
st_mysql_pluginmysql_mandatory_plugins []
 
const char * global_plugin_typelib_names []
 
static TYPELIB global_plugin_typelib
 
static I_List< i_stringopt_plugin_load_list
 
I_List< i_string > * opt_plugin_load_list_ptr = &opt_plugin_load_list
 
static I_List< i_stringopt_early_plugin_load_list
 
I_List< i_string > * opt_early_plugin_load_list_ptr = &opt_early_plugin_load_list
 
char * opt_plugin_dir_ptr
 
char opt_plugin_dir [FN_REFLEN]
 
const LEX_STRING plugin_type_names [MYSQL_MAX_PLUGIN_TYPE_NUM]
 
plugin_type_init plugin_type_initialize [MYSQL_MAX_PLUGIN_TYPE_NUM]
 
plugin_type_init plugin_type_deinitialize [MYSQL_MAX_PLUGIN_TYPE_NUM]
 
static const char * plugin_interface_version_sym
 
static const char * sizeof_st_plugin_sym = "_mysql_sizeof_struct_st_plugin_"
 
static const char * plugin_declarations_sym = "_mysql_plugin_declarations_"
 
static int min_plugin_interface_version
 
static void * innodb_callback_data
 
static int min_plugin_info_interface_version [MYSQL_MAX_PLUGIN_TYPE_NUM]
 
static int cur_plugin_info_interface_version [MYSQL_MAX_PLUGIN_TYPE_NUM]
 
mysql_mutex_t LOCK_plugin_delete
 
mysql_mutex_t LOCK_plugin
 Serializes access to the global plugin memory list. More...
 
mysql_mutex_t LOCK_plugin_install
 Serializes the INSTALL and UNINSTALL PLUGIN commands. More...
 
static Prealloced_array< st_plugin_dl *, 16 > * plugin_dl_array
 
static Prealloced_array< st_plugin_int *, 16 > * plugin_array
 
static collation_unordered_map< std::string, st_plugin_int * > * plugin_hash [MYSQL_MAX_PLUGIN_TYPE_NUM] = {nullptr}
 
static bool reap_needed = false
 
static int plugin_array_version = 0
 
static bool initialized = false
 
static MEM_ROOT plugin_mem_root
 
static uint global_variables_dynamic_size = 0
 
static malloc_unordered_map< std::string, st_bookmark * > * bookmark_hash
 
static malloc_unordered_map< std::string, st_bookmark * > * malloced_string_type_sysvars_bookmark_hash
 Hash for system variables of string type with MEMALLOC flag. More...
 
static PSI_mutex_key key_LOCK_plugin
 
static PSI_mutex_key key_LOCK_plugin_delete
 
static PSI_mutex_key key_LOCK_plugin_install
 
static PSI_mutex_info all_plugin_mutexes []
 
static PSI_memory_info all_plugin_memory []
 

Macro Definition Documentation

◆ my_intern_plugin_lock

#define my_intern_plugin_lock (   A,
 
)    intern_plugin_lock(A, B)

◆ my_intern_plugin_lock_ci

#define my_intern_plugin_lock_ci (   A,
 
)    intern_plugin_lock(A, B)

◆ REPORT_TO_LOG

#define REPORT_TO_LOG   1

◆ REPORT_TO_USER

#define REPORT_TO_USER   2

Function Documentation

◆ add_plugin_options()

void add_plugin_options ( std::vector< my_option > *  options,
MEM_ROOT mem_root 
)

◆ alloc_and_copy_thd_dynamic_variables()

void alloc_and_copy_thd_dynamic_variables ( THD thd,
bool  global_lock 
)

Allocate memory and copy dynamic variables from global system variables to per-thread system variables copy.

Parameters
thdthread context
global_lockIf true LOCK_global_system_variables should be acquired while copying variables from global variables copy.

◆ check_if_option_is_deprecated()

static bool check_if_option_is_deprecated ( int  optid,
const struct my_option opt,
char *  argument 
)
static

Check option being used and raise deprecation warning if required.

Parameters
optidID of the option that was passed through command line
optList of options
argumentunused

A deprecation warning will be raised if –plugin-xxx type of option is used.

Returns
Always returns success as purpose of the function is to raise warning only.
Return values
0Success

◆ check_valid_path()

bool check_valid_path ( const char *  path,
size_t  len 
)

Check if the provided path is valid in the sense that it does cause a relative reference outside the directory.

Note
Currently, this function only check if there are any characters in FN_DIRSEP in the string, but it might change in the future.
check_valid_path("../foo.so") -> true
check_valid_path("foo.so") -> false

◆ cleanup_variables()

static void cleanup_variables ( THD thd,
struct System_variables vars 
)
static

◆ construct_help_options()

static my_option* construct_help_options ( MEM_ROOT mem_root,
st_plugin_int p 
)
static

some plugin variables (those that don't have PLUGIN_VAR_EXPERIMENTAL flag) have their names prefixed with the plugin name. Restore the names here to get the correct (not double-prefixed) help text. We won't need @sysvars anymore and don't care about their proper names.

◆ construct_options()

static int construct_options ( MEM_ROOT mem_root,
st_plugin_int tmp,
my_option options 
)
static

Creates a set of my_option objects associated with a specified plugin- handle.

Parameters
mem_rootMemory allocator to be used.
tmpA pointer to a plugin handle
[out]optionsA pointer to a pre-allocated static array

The set is stored in the pre-allocated static array supplied to the function. The size of the array is calculated as (number_of_plugin_varaibles*2+3). The reason is that each option can have a prefix '–plugin-' in addtion to the shorter form '–<plugin-name>'. There is also space allocated for terminating NULL pointers.

Returns
Return values
-1An error occurred
0Success

Used to circumvent the const attribute on my_option::name

◆ convert_dash_to_underscore()

static void convert_dash_to_underscore ( char *  str,
size_t  len 
)
inlinestatic

◆ end_transaction()

bool end_transaction ( THD thd,
bool  error 
)

Helper function to do rollback or commit, depending on error.

Also closes tables and releases transactional locks, regardless of error.

Parameters
thdThread
errorIf true, the transaction will be rolledback. otherwise, it is committed.
Returns
false on success, otherwise true.

◆ finalize_schema_table()

int finalize_schema_table ( st_plugin_int plugin)

◆ find_sys_var()

sys_var* find_sys_var ( THD thd,
const char *  str,
size_t  length 
)

◆ find_sys_var_ex()

sys_var* find_sys_var_ex ( THD thd,
const char *  str,
size_t  length,
bool  throw_error,
bool  locked 
)

◆ free_plugin_mem()

static void free_plugin_mem ( st_plugin_dl p)
inlinestatic

◆ get_bookmark_hash()

malloc_unordered_map<std::string, st_bookmark *>* get_bookmark_hash ( void  )

◆ get_one_plugin_option()

bool get_one_plugin_option ( int  ,
const struct my_option ,
char *   
)

◆ init_plugin_psi_keys()

static void init_plugin_psi_keys ( void  )
static

◆ initialize_schema_table()

int initialize_schema_table ( st_plugin_int plugin)

◆ intern_plugin_lock()

static plugin_ref intern_plugin_lock ( LEX lex,
plugin_ref  plugin 
)
static

◆ intern_plugin_unlock()

static void intern_plugin_unlock ( LEX lex,
plugin_ref  plugin 
)
static

◆ is_builtin_and_core_se_initialized()

bool is_builtin_and_core_se_initialized ( )

◆ lock_plugin_data()

int lock_plugin_data ( )

Locks the plugin strucutres so calls to plugin_find_inner can be issued.

Must be followed by unlock_plugin_data.

◆ lock_plugin_mutex()

void lock_plugin_mutex ( )

◆ memcached_shutdown()

void memcached_shutdown ( void  )

◆ mysql_install_plugin()

static bool mysql_install_plugin ( THD thd,
const LEX_STRING name,
const LEX_STRING dl 
)
static

◆ mysql_sys_var_bool()

static bool* mysql_sys_var_bool ( THD thd,
int  offset 
)
static

For correctness and simplicity's sake, a pointer to a function must be compatible with pointed-to type, that is, the return and parameters types must be the same.

Thus, a callback function is defined for each scalar type. The functions are assigned in construct_options to their respective types.

◆ mysql_sys_var_double()

static double* mysql_sys_var_double ( THD thd,
int  offset 
)
static

◆ mysql_sys_var_int()

static int* mysql_sys_var_int ( THD thd,
int  offset 
)
static

◆ mysql_sys_var_str()

static char** mysql_sys_var_str ( THD thd,
int  offset 
)
static

◆ mysql_sys_var_uint()

static unsigned int* mysql_sys_var_uint ( THD thd,
int  offset 
)
static

◆ mysql_sys_var_ulong()

static unsigned long* mysql_sys_var_ulong ( THD thd,
int  offset 
)
static

◆ mysql_sys_var_ulonglong()

static unsigned long long* mysql_sys_var_ulonglong ( THD thd,
int  offset 
)
static

◆ mysql_uninstall_plugin()

static bool mysql_uninstall_plugin ( THD thd,
const LEX_STRING name 
)
static

◆ plugin_add()

static bool plugin_add ( MEM_ROOT tmp_root,
const LEX_STRING name,
const LEX_STRING dl,
int *  argc,
char **  argv,
int  report 
)
static

Adds a plugin to the global plugin list.

Also installs the plugin variables. In case of error releases LOCK_system_variables_hash and LOCK_plugin and reports the error.

Note
Requires that a write-lock is held on LOCK_plugin and LOCK_system_variables_hash

◆ plugin_deinitialize()

static void plugin_deinitialize ( st_plugin_int plugin,
bool  ref_check 
)
static

◆ plugin_del()

static void plugin_del ( st_plugin_int plugin)
static

◆ plugin_dl_add()

static st_plugin_dl* plugin_dl_add ( const LEX_STRING dl,
int  report 
)
static

Loads a dynamic plugin.

Fills in a st_plugin_dl structure. Initializes the plugin services pointer inside the plugin. Does not initialize the individual plugins. Must have LOCK_plugin and LOCK_system_variables locked(write). On error releases LOCK_system_variables and LOCK_plugin.

  • dl The path to the plugin binary to load
  • report a bitmask that's passed down to report_error()
Returns
A plugin reference.
Return values
NULLfailed to load the plugin

◆ plugin_dl_del()

static void plugin_dl_del ( const LEX_STRING dl)
static

◆ plugin_dl_find()

static st_plugin_dl* plugin_dl_find ( const LEX_STRING dl)
static

◆ plugin_dl_insert_or_reuse()

static st_plugin_dl* plugin_dl_insert_or_reuse ( st_plugin_dl plugin_dl)
static

◆ plugin_early_load_one()

bool plugin_early_load_one ( int *  argc,
char **  argv,
const char *  plugin 
)

Initialize one plugin.

This function is used to early load one single plugin. This function is used by key migration tool.

Parameters
[in]argcCommand line argument counter
[in]argvCommand line arguments
[in]pluginlibrary file name
Returns
Operation status
Return values
0OK
1ERROR

◆ plugin_find_by_type()

st_plugin_int* plugin_find_by_type ( const LEX_CSTRING plugin,
int  type 
)

Searches for a correctly loaded plugin of a particular type by name.

Parameters
pluginthe name of the plugin we're looking for
typetype of the plugin (0-MYSQL_MAX_PLUGIN_TYPE_NUM)
Returns
plugin, or NULL if not found

◆ plugin_find_internal()

static st_plugin_int* plugin_find_internal ( const LEX_CSTRING name,
int  type 
)
static

◆ plugin_foreach_with_mask() [1/2]

bool plugin_foreach_with_mask ( THD thd,
plugin_foreach_func **  funcs,
int  type,
uint  state_mask,
void *  arg 
)

◆ plugin_foreach_with_mask() [2/2]

bool plugin_foreach_with_mask ( THD thd,
plugin_foreach_func func,
int  type,
uint  state_mask,
void *  arg 
)

◆ plugin_init_initialize_and_reap()

static bool plugin_init_initialize_and_reap ( )
static

Initialize the plugins.

Reap those that fail to initialize.

Returns
Operation outcome, false means no errors

◆ plugin_init_internals()

static bool plugin_init_internals ( )
static

Initialize the internals of the plugin system.

Allocate required resources, initialize mutex, etc.

Returns
Operation outcome, false means no errors

◆ plugin_initialize()

static int plugin_initialize ( st_plugin_int plugin)
static

◆ plugin_insert_or_reuse()

static st_plugin_int* plugin_insert_or_reuse ( st_plugin_int plugin)
static

◆ plugin_is_ready()

bool plugin_is_ready ( const LEX_CSTRING name,
int  type 
)

◆ plugin_load()

static void plugin_load ( MEM_ROOT tmp_root,
int *  argc,
char **  argv 
)
static

Reads the plugins from mysql.plugin and loads them.

Called only by plugin_register_dynamic_and_init_all() a.k.a. the bootstrap sequence.

  • tmp_root memory root to use for plugin_add()
  • argc number of command line arguments to process
  • argv array of command line argument to read values from
    Return values
    truefailure
    falsesuccess

◆ plugin_load_list()

static bool plugin_load_list ( MEM_ROOT tmp_root,
int *  argc,
char **  argv,
const char *  list 
)
static

Load a list of plugins.

Called by plugin_register_early_plugins() and plugin_register_dynamic_and_init_all(), a.k.a. the bootstrap sequence.

  • tmp_root memory root to use for plugin_add()
  • argc number of command line arguments to process
  • argv array of command line argument to read values from
  • list list of plugins to load. Ends with a NULL pointer
    Return values
    truefailure
    falsesuccess

◆ plugin_lock()

plugin_ref plugin_lock ( THD thd,
plugin_ref ptr 
)

◆ plugin_lock_by_name()

plugin_ref plugin_lock_by_name ( THD thd,
const LEX_CSTRING name,
int  type 
)

◆ plugin_register_builtin_and_init_core_se()

bool plugin_register_builtin_and_init_core_se ( int *  argc,
char **  argv 
)

Register the builtin plugins.

Some of the plugins (MyISAM, CSV and InnoDB) are also initialized.

Parameters
argcnumber of arguments, propagated to the plugin
argvactual arguments, propagated to the plugin
Returns
Operation outcome, false means no errors

◆ plugin_register_dynamic_and_init_all()

bool plugin_register_dynamic_and_init_all ( int *  argc,
char **  argv,
int  flags 
)

Register and initialize the dynamic plugins.

Also initialize the remaining builtin plugins that are not initialized already.

Parameters
argcCommand line argument counter
argvCommand line arguments
flagsFlags to control whether dynamic loading and plugin initialization should be skipped
Returns
Operation outcome, false if no errors

◆ plugin_register_early_plugins()

bool plugin_register_early_plugins ( int *  argc,
char **  argv,
int  flags 
)

Register and initialize early plugins.

Parameters
argcCommand line argument counter
argvCommand line arguments
flagsFlags to control whether dynamic loading and plugin initialization should be skipped
Returns
Operation outcome, false if no errors

◆ plugin_shutdown()

void plugin_shutdown ( void  )

◆ plugin_status() [1/2]

static SHOW_COMP_OPTION plugin_status ( const LEX_CSTRING name,
int  type 
)
static

◆ plugin_status() [2/2]

SHOW_COMP_OPTION plugin_status ( const char *  name,
size_t  len,
int  type 
)

◆ plugin_thdvar_cleanup()

void plugin_thdvar_cleanup ( THD thd,
bool  enable_plugins 
)

◆ plugin_thdvar_init()

void plugin_thdvar_init ( THD thd,
bool  enable_plugins 
)

◆ plugin_thdvar_safe_update()

void plugin_thdvar_safe_update ( THD thd,
SYS_VAR var,
char **  dest,
const char *  value 
)

Set value for a thread local variable.

Parameters
[in]thdThread context.
[in]varPlugin variable.
[in,out]destDestination memory pointer.
[in]valueNew value.

Note: new value should be '\0'-terminated for string variables.

Used in plugin.h:THDVAR_SET(thd, name, value) macro.

◆ plugin_unlock()

void plugin_unlock ( THD thd,
plugin_ref  plugin 
)

◆ plugin_unlock_list()

void plugin_unlock_list ( THD thd,
plugin_ref list,
size_t  count 
)

◆ plugin_var_memalloc_free()

static void plugin_var_memalloc_free ( struct System_variables vars)
static

Free all elements allocated by plugin_var_memalloc_session_update().

Parameters
[in]varssystem variables structure
See also
plugin_var_memalloc_session_update

◆ plugin_vars_free_values()

static void plugin_vars_free_values ( sys_var vars)
static

Free values of thread variables of a plugin.

This must be called before a plugin is deleted. Otherwise its variables are no longer accessible and the value space is lost. Note that only string values with PLUGIN_VAR_MEMALLOC are allocated and must be freed.

Parameters
[in]varsChain of system variables of a plugin

◆ reap_plugins()

static void reap_plugins ( void  )
static

◆ register_builtin()

static bool register_builtin ( st_mysql_plugin plugin,
st_plugin_int tmp,
st_plugin_int **  ptr 
)
static

◆ register_var()

static st_bookmark* register_var ( const char *  plugin,
const char *  name,
int  flags 
)
static

◆ report_error()

static void report_error ( int  where_to,
uint  error,
  ... 
)
static

◆ restore_pluginvar_names()

static void restore_pluginvar_names ( sys_var first)
static

◆ test_plugin_options()

static int test_plugin_options ( MEM_ROOT tmp_root,
st_plugin_int tmp,
int *  argc,
char **  argv 
)
static

Create and register system variables supplied from the plugin and assigns initial values from corresponding command line arguments.

Parameters
tmp_rootTemporary scratch space
[out]tmpInternal plugin structure
argcNumber of command line arguments
argvCommand line argument vector

The plugin will be updated with a policy on how to handle errors during initialization.

Note
Requires that a write-lock is held on LOCK_system_variables_hash
Returns
How initialization of the plugin should be handled.
Return values
0Initialization should proceed.
1Plugin is disabled.
-1An error has occurred.

◆ unlock_plugin_data()

int unlock_plugin_data ( )

Unlocks the plugin strucutres as locked by lock_plugin_data()

◆ unlock_plugin_mutex()

void unlock_plugin_mutex ( )

◆ unlock_variables()

static void unlock_variables ( struct System_variables vars)
static

Variable Documentation

◆ all_plugin_memory

PSI_memory_info all_plugin_memory[]
static
Initial value:
=
{
{ &key_memory_plugin_init_tmp, "plugin_init_tmp", 0, 0, PSI_DOCUMENT_ME},
{ &key_memory_plugin_int_mem_root, "plugin_int_mem_root", 0, 0, PSI_DOCUMENT_ME},
}
static PSI_memory_key key_memory_plugin_bookmark
Definition: sql_plugin.cc:318
static PSI_memory_key key_memory_plugin_int_mem_root
Definition: sql_plugin.cc:315
static PSI_memory_key key_memory_mysql_plugin_dl
Definition: sql_plugin.cc:317
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_base.h:105
static PSI_memory_key key_memory_plugin_ref
Definition: sql_plugin.cc:310
static PSI_memory_key key_memory_mysql_plugin
Definition: sql_plugin.cc:316
static PSI_memory_key key_memory_plugin_init_tmp
Definition: sql_plugin.cc:314
#define PSI_DOCUMENT_ME
Definition: psi_base.h:46
static PSI_memory_key key_memory_plugin_mem_root
Definition: sql_plugin.cc:313

◆ all_plugin_mutexes

PSI_mutex_info all_plugin_mutexes[]
static
Initial value:
=
{
}
static PSI_mutex_key key_LOCK_plugin_install
Definition: sql_plugin.cc:1299
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: psi_base.h:54
#define PSI_DOCUMENT_ME
Definition: psi_base.h:46
static PSI_mutex_key key_LOCK_plugin
Definition: sql_plugin.cc:1297
static PSI_mutex_key key_LOCK_plugin_delete
Definition: sql_plugin.cc:1298

◆ bookmark_hash

malloc_unordered_map<std::string, st_bookmark *>* bookmark_hash
static

◆ cur_plugin_info_interface_version

int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]
static
Initial value:
= {
0x0000,
#define MYSQL_REPLICATION_INTERFACE_VERSION
Definition: plugin.h:721
#define MYSQL_CLONE_INTERFACE_VERSION
Clone plugin interface version.
Definition: plugin_clone.h:35
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
Definition: plugin.h:688
#define MYSQL_GROUP_REPLICATION_INTERFACE_VERSION
Definition: plugin_group_replication.h:32
#define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION
Definition: plugin_validate_password.h:32
#define MYSQL_DAEMON_INTERFACE_VERSION
Definition: plugin.h:672
#define MYSQL_AUTHENTICATION_INTERFACE_VERSION
Definition: plugin_auth.h:36
#define MYSQL_AUDIT_INTERFACE_VERSION
Definition: plugin_audit.h:39
#define MYSQL_KEYRING_INTERFACE_VERSION
API for keyring plugin.
Definition: plugin_keyring.h:31
#define MYSQL_FTPARSER_INTERFACE_VERSION
Definition: plugin.h:658
#define MYSQL_HANDLERTON_INTERFACE_VERSION
Definition: plugin.h:704

◆ global_plugin_typelib

TYPELIB global_plugin_typelib
static
Initial value:
= {
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
constexpr size_t array_elements(T(&)[N]) noexcept
Definition: my_macros.h:77
const char * global_plugin_typelib_names[]
Definition: sql_plugin.cc:327

◆ global_plugin_typelib_names

const char* global_plugin_typelib_names[]
Initial value:
= {"OFF", "ON", "FORCE",
"FORCE_PLUS_PERMANENT", NULL}
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
Note
The order of the enumeration is critical.
See also
construct_options

◆ global_variables_dynamic_size

uint global_variables_dynamic_size = 0
static

◆ initialized

bool initialized = false
static

◆ innodb_callback_data

void* innodb_callback_data
static

◆ key_LOCK_plugin

PSI_mutex_key key_LOCK_plugin
static

◆ key_LOCK_plugin_delete

PSI_mutex_key key_LOCK_plugin_delete
static

◆ key_LOCK_plugin_install

PSI_mutex_key key_LOCK_plugin_install
static

◆ key_memory_mysql_plugin

PSI_memory_key key_memory_mysql_plugin
static

◆ key_memory_mysql_plugin_dl

PSI_memory_key key_memory_mysql_plugin_dl
static

◆ key_memory_plugin_bookmark

PSI_memory_key key_memory_plugin_bookmark
static

◆ key_memory_plugin_init_tmp

PSI_memory_key key_memory_plugin_init_tmp
static

◆ key_memory_plugin_int_mem_root

PSI_memory_key key_memory_plugin_int_mem_root
static

◆ key_memory_plugin_mem_root

PSI_memory_key key_memory_plugin_mem_root
static

◆ key_memory_plugin_ref

PSI_memory_key key_memory_plugin_ref
static

◆ LOCK_plugin

mysql_mutex_t LOCK_plugin

Serializes access to the global plugin memory list.

LOCK_plugin must be acquired before accessing plugin_dl_array, plugin_array and plugin_hash. We are always manipulating ref count, so a rwlock here is unneccessary. If it must be taken together with the LOCK_system_variables_hash then LOCK_plugin must be taken before LOCK_system_variables_hash.

◆ LOCK_plugin_delete

mysql_mutex_t LOCK_plugin_delete

◆ LOCK_plugin_install

mysql_mutex_t LOCK_plugin_install

Serializes the INSTALL and UNINSTALL PLUGIN commands.

Must be taken before LOCK_plugin.

◆ malloced_string_type_sysvars_bookmark_hash

malloc_unordered_map<std::string, st_bookmark *>* malloced_string_type_sysvars_bookmark_hash
static

Hash for system variables of string type with MEMALLOC flag.

◆ min_plugin_info_interface_version

int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]
static
Initial value:
= {
0x0000,
#define MYSQL_REPLICATION_INTERFACE_VERSION
Definition: plugin.h:721
#define MYSQL_CLONE_INTERFACE_VERSION
Clone plugin interface version.
Definition: plugin_clone.h:35
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
Definition: plugin.h:688
#define MYSQL_GROUP_REPLICATION_INTERFACE_VERSION
Definition: plugin_group_replication.h:32
#define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION
Definition: plugin_validate_password.h:32
#define MYSQL_DAEMON_INTERFACE_VERSION
Definition: plugin.h:672
#define MYSQL_AUTHENTICATION_INTERFACE_VERSION
Definition: plugin_auth.h:36
#define MYSQL_AUDIT_INTERFACE_VERSION
Definition: plugin_audit.h:39
#define MYSQL_KEYRING_INTERFACE_VERSION
API for keyring plugin.
Definition: plugin_keyring.h:31
#define MYSQL_FTPARSER_INTERFACE_VERSION
Definition: plugin.h:658
#define MYSQL_HANDLERTON_INTERFACE_VERSION
Definition: plugin.h:704

◆ min_plugin_interface_version

int min_plugin_interface_version
static
Initial value:
=
#define MYSQL_PLUGIN_INTERFACE_VERSION
Definition: plugin.h:99

◆ mysql_mandatory_plugins

st_mysql_plugin* mysql_mandatory_plugins[]

◆ mysql_optional_plugins

st_mysql_plugin* mysql_optional_plugins[]

◆ opt_early_plugin_load_list

I_List<i_string> opt_early_plugin_load_list
static

◆ opt_early_plugin_load_list_ptr

I_List<i_string>* opt_early_plugin_load_list_ptr = &opt_early_plugin_load_list

◆ opt_plugin_dir

char opt_plugin_dir[FN_REFLEN]

◆ opt_plugin_dir_ptr

char* opt_plugin_dir_ptr

◆ opt_plugin_load_list

I_List<i_string> opt_plugin_load_list
static

◆ opt_plugin_load_list_ptr

I_List<i_string>* opt_plugin_load_list_ptr = &opt_plugin_load_list

◆ plugin_array

Prealloced_array<st_plugin_int *, 16>* plugin_array
static

◆ plugin_array_version

int plugin_array_version = 0
static

◆ plugin_declarations_sym

const char* plugin_declarations_sym = "_mysql_plugin_declarations_"
static

◆ plugin_dl_array

Prealloced_array<st_plugin_dl *, 16>* plugin_dl_array
static

◆ plugin_hash

collation_unordered_map<std::string, st_plugin_int *>* plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM] = {nullptr}
static

◆ plugin_interface_version_sym

const char* plugin_interface_version_sym
static
Initial value:
=
"_mysql_plugin_interface_version_"

◆ plugin_mem_root

MEM_ROOT plugin_mem_root
static

◆ plugin_type_deinitialize

plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]
Initial value:
= {
0,
0,
0,
0,
0,
0}
int ha_finalize_handlerton(st_plugin_int *plugin)
Definition: handler.cc:697
int finalize_schema_table(st_plugin_int *plugin)
Definition: sql_show.cc:4055
int finalize_audit_plugin(st_plugin_int *plugin)
Finalize an Audit plug-in.
Definition: sql_audit.cc:1268

◆ plugin_type_initialize

Initial value:
= {
0,
0,
0,
0,
0,
0}
int ha_initialize_handlerton(st_plugin_int *plugin)
Definition: handler.cc:747
int initialize_schema_table(st_plugin_int *plugin)
Definition: sql_show.cc:4024
int initialize_audit_plugin(st_plugin_int *plugin)
Initialize an Audit plug-in.
Definition: sql_audit.cc:1209

◆ plugin_type_names

const LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]
Initial value:
= {
{C_STRING_WITH_LEN("STORAGE ENGINE")},
{C_STRING_WITH_LEN("FTPARSER")},
{C_STRING_WITH_LEN("DAEMON")},
{C_STRING_WITH_LEN("INFORMATION SCHEMA")},
{C_STRING_WITH_LEN("AUDIT")},
{C_STRING_WITH_LEN("REPLICATION")},
{C_STRING_WITH_LEN("AUTHENTICATION")},
{C_STRING_WITH_LEN("VALIDATE PASSWORD")},
{C_STRING_WITH_LEN("GROUP REPLICATION")},
{C_STRING_WITH_LEN("KEYRING")},
{C_STRING_WITH_LEN("CLONE")}}
#define C_STRING_WITH_LEN(X)
Definition: m_string.h:316

◆ reap_needed

bool reap_needed = false
static

◆ sizeof_st_plugin_sym

const char* sizeof_st_plugin_sym = "_mysql_sizeof_struct_st_plugin_"
static