MySQL 8.4.3
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 <optional>
#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_getopt.h"
#include "my_inttypes.h"
#include "my_list.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/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_memory_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/components/services/system_variable_source_type.h"
#include "mysql/my_loglevel.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/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include "nulls.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/iterators/row_iterator.h"
#include "sql/key.h"
#include "sql/lock.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/sd_notify.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_executor.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_system_table_check.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 "string_with_len.h"
#include "strxmov.h"
#include "strxnmov.h"
#include "template_utils.h"
#include "thr_lock.h"
#include "thr_mutex.h"
#include "typelib.h"
#include <dlfcn.h>
#include <algorithm>
#include <memory>
#include <new>
#include <unordered_map>
#include <utility>
#include "sql/srv_session.h"
#include "sql/sql_plugin_services.h"

Namespaces

namespace  dd
 The version of the current data dictionary table definitions.
 
namespace  dd::upgrade
 

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, bool load_early)
 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, const std::optional< enum_plugin_load_option > force_load_option)
 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 void reap_plugins ()
 
malloc_unordered_map< std::string, st_bookmark * > * get_bookmark_hash ()
 
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, bool load_early)
 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 intern_plugin_lock (LEX *lex, plugin_ref rc)
 
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, LEX_CSTRING name, const LEX_STRING *dl, int *argc, char **argv, int report, bool load_early)
 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 intern_plugin_unlock (LEX *lex, plugin_ref 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 update_persisted_plugin_sysvars (const char *name)
 Update read-write persisted plugin system variables. 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 dd::upgrade::plugin_initialize_delayed_after_upgrade ()
 Initialize delayed plugins. More...
 
void dd::upgrade::delay_initialization_of_dependent_plugins ()
 Reset state of delayed plugins to indicate that they wait for upgrade to complete. More...
 
bool plugin_register_dynamic_and_init_all (int *argc, char **argv, int flags)
 Register and initialize the dynamic plugins. More...
 
void plugin_shutdown ()
 
bool end_transaction (THD *thd, bool error)
 
bool plugin_early_load_one (int *argc, char **argv, const char *plugin)
 Initialize one plugin. More...
 
static bool mysql_install_plugin (THD *thd, LEX_CSTRING name, const LEX_STRING *dl)
 
static bool mysql_uninstall_plugin (THD *thd, LEX_CSTRING 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)
 
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 bool * mysql_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...
 
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...
 

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_CSTRING 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 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 const int MYSQL_PLUGIN_TABLE_FIELD_COUNT = 2
 
static const TABLE_FIELD_TYPE mysql_plugin_table_fields [MYSQL_PLUGIN_TABLE_FIELD_COUNT]
 
static const TABLE_FIELD_DEF mysql_plugin_table_def
 
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 []
 
constexpr const char * dd::upgrade::delayed_plugins [] = {"audit_log", "mysql_firewall"}
 

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
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 ...
Definition: sql_plugin.cc:571

◆ 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 addition to the shorter form '–<plugin-name>'. There is also space allocated for terminating NULL pointers.

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 
)

◆ finalize_schema_table()

int finalize_schema_table ( st_plugin_int plugin)

◆ 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 ( )

◆ 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()

plugin_ref intern_plugin_lock ( LEX lex,
plugin_ref  rc 
)

◆ intern_plugin_unlock()

void intern_plugin_unlock ( LEX lex,
plugin_ref  plugin 
)

◆ is_builtin_and_core_se_initialized()

bool is_builtin_and_core_se_initialized ( )

◆ mysql_install_plugin()

static bool mysql_install_plugin ( THD thd,
LEX_CSTRING  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,
LEX_CSTRING  name 
)
static

◆ plugin_add()

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

Adds a plugin to the global plugin list.

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

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

◆ 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,
bool  load_early 
)
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()
  • load_early true if loading the "early" plugins (–early-plugin-load etc)
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

◆ plugin_load_list()

static bool plugin_load_list ( MEM_ROOT tmp_root,
int *  argc,
char **  argv,
const char *  list,
bool  load_early 
)
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
  • load_early true if loading plugins via –early-plugin-load or migration
    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]

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

◆ plugin_status() [2/2]

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

◆ 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 ( )
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
Warning
Make sure all errors reported to the log here are defined in share/messages_to_error_log.txt as well as in share/messages_to_clients.txt.

◆ 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,
const std::optional< enum_plugin_load_option force_load_option 
)
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
force_load_optionempty if not specified, otherwise one of enum_plugin_load_option

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_variables()

static void unlock_variables ( struct System_variables vars)
static

◆ update_persisted_plugin_sysvars()

bool update_persisted_plugin_sysvars ( const char *  name)

Update read-write persisted plugin system variables.

Parameters
nameplugin name
Returns
Operation outcome, false means no errors

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},
}
#define PSI_DOCUMENT_ME
Definition: component_common.h:29
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_bits.h:112
static PSI_memory_key key_memory_plugin_mem_root
Definition: sql_plugin.cc:320
static PSI_memory_key key_memory_mysql_plugin_dl
Definition: sql_plugin.cc:324
static PSI_memory_key key_memory_mysql_plugin
Definition: sql_plugin.cc:323
static PSI_memory_key key_memory_plugin_init_tmp
Definition: sql_plugin.cc:321
static PSI_memory_key key_memory_plugin_int_mem_root
Definition: sql_plugin.cc:322
static PSI_memory_key key_memory_plugin_bookmark
Definition: sql_plugin.cc:325
static PSI_memory_key key_memory_plugin_ref
Definition: sql_plugin.cc:317

◆ all_plugin_mutexes

PSI_mutex_info all_plugin_mutexes[]
static
Initial value:
=
{
}
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:35
static PSI_mutex_key key_LOCK_plugin_delete
Definition: sql_plugin.cc:1356
static PSI_mutex_key key_LOCK_plugin
Definition: sql_plugin.cc:1355
static PSI_mutex_key key_LOCK_plugin_install
Definition: sql_plugin.cc:1357

◆ 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_INFORMATION_SCHEMA_INTERFACE_VERSION
Definition: plugin.h:688
#define MYSQL_DAEMON_INTERFACE_VERSION
Definition: plugin.h:672
#define MYSQL_FTPARSER_INTERFACE_VERSION
Definition: plugin.h:658
#define MYSQL_REPLICATION_INTERFACE_VERSION
Definition: plugin.h:721
#define MYSQL_HANDLERTON_INTERFACE_VERSION
Definition: plugin.h:704
#define MYSQL_AUDIT_INTERFACE_VERSION
Definition: plugin_audit.h:43
#define MYSQL_AUTHENTICATION_INTERFACE_VERSION
Definition: plugin_auth.h:37
#define MYSQL_CLONE_INTERFACE_VERSION
Clone plugin interface version.
Definition: plugin_clone.h:36
#define MYSQL_GROUP_REPLICATION_INTERFACE_VERSION
Definition: plugin_group_replication.h:33
#define MYSQL_KEYRING_INTERFACE_VERSION
API for keyring plugin.
Definition: plugin_keyring.h:32
#define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION
Definition: plugin_validate_password.h:33

◆ global_plugin_typelib

TYPELIB global_plugin_typelib
static
Initial value:
= {
const char * global_plugin_typelib_names[]
Definition: sql_plugin.cc:334
#define array_elements(A)
Definition: validate_password_imp.cc:48

◆ global_plugin_typelib_names

const char* global_plugin_typelib_names[]
Initial value:
= {"OFF", "ON", "FORCE",
"FORCE_PLUS_PERMANENT", nullptr}
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

◆ 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 unnecessary. If it must be taken together with the LOCK_system_variables_hash then LOCK_plugin must be taken after 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

◆ min_plugin_interface_version

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

◆ mysql_mandatory_plugins

st_mysql_plugin* mysql_mandatory_plugins[]
extern

◆ mysql_optional_plugins

st_mysql_plugin* mysql_optional_plugins[]
extern

◆ mysql_plugin_table_def

const TABLE_FIELD_DEF mysql_plugin_table_def
static
Initial value:
= {
static const TABLE_FIELD_TYPE mysql_plugin_table_fields[MYSQL_PLUGIN_TABLE_FIELD_COUNT]
Definition: sql_plugin.cc:495
static const int MYSQL_PLUGIN_TABLE_FIELD_COUNT
Definition: sql_plugin.cc:493

◆ MYSQL_PLUGIN_TABLE_FIELD_COUNT

const int MYSQL_PLUGIN_TABLE_FIELD_COUNT = 2
static

◆ mysql_plugin_table_fields

const TABLE_FIELD_TYPE mysql_plugin_table_fields[MYSQL_PLUGIN_TABLE_FIELD_COUNT]
static
Initial value:
= {
{{STRING_WITH_LEN("name")},
{STRING_WITH_LEN("varchar(64)")},
{nullptr, 0}},
{{STRING_WITH_LEN("dl")},
{STRING_WITH_LEN("varchar(128)")},
{nullptr, 0}}}
#define STRING_WITH_LEN(X)
Definition: string_with_len.h:29

◆ 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:
= {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
int ha_finalize_handlerton(st_plugin_int *plugin)
Definition: handler.cc:725
int finalize_audit_plugin(st_plugin_int *plugin)
Finalize an Audit plug-in.
Definition: sql_audit.cc:767
int finalize_schema_table(st_plugin_int *plugin)
Definition: sql_show.cc:5140

◆ plugin_type_initialize

Initial value:
= {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
int ha_initialize_handlerton(st_plugin_int *plugin)
Definition: handler.cc:775
int initialize_audit_plugin(st_plugin_int *plugin)
Initialize an Audit plug-in.
Definition: sql_audit.cc:708
int initialize_schema_table(st_plugin_int *plugin)
Definition: sql_show.cc:5111

◆ plugin_type_names

const LEX_CSTRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]
Initial value:
= {
{STRING_WITH_LEN("UDF")},
{STRING_WITH_LEN("STORAGE ENGINE")},
{STRING_WITH_LEN("FTPARSER")},
{STRING_WITH_LEN("DAEMON")},
{STRING_WITH_LEN("INFORMATION SCHEMA")},
{STRING_WITH_LEN("AUDIT")},
{STRING_WITH_LEN("REPLICATION")},
{STRING_WITH_LEN("AUTHENTICATION")},
{STRING_WITH_LEN("VALIDATE PASSWORD")},
{STRING_WITH_LEN("GROUP REPLICATION")},
{STRING_WITH_LEN("KEYRING")},
{STRING_WITH_LEN("CLONE")}}

◆ reap_needed

bool reap_needed = false
static

◆ sizeof_st_plugin_sym

const char* sizeof_st_plugin_sym = "_mysql_sizeof_struct_st_plugin_"
static