MySQL 8.4.3
Source Code Documentation
sql_plugin.h File Reference
#include <stddef.h>
#include <sys/types.h>
#include <vector>
#include "lex_string.h"
#include "my_io.h"
#include "my_sqlcommand.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "sql/sql_cmd.h"
#include "sql/sql_plugin_ref.h"

Go to the source code of this file.

Classes

struct  st_plugin_dl
 
class  Sql_cmd_install_plugin
 This class implements the INSTALL PLUGIN statement. More...
 
class  Sql_cmd_uninstall_plugin
 This class implements the UNINSTALL PLUGIN statement. More...
 

Namespaces

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

Macros

#define plugin_ref_to_int(A)   (A ? A[0] : NULL)
 
#define plugin_int_to_ref(A)   &(A)
 
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING   1
 
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE   2
 
#define PLUGIN_INIT_SKIP_INITIALIZATION   4
 
#define PLUGIN_INIT_DELAY_UNTIL_AFTER_UPGRADE   8
 
#define MYSQL_ANY_PLUGIN   -1
 
#define PLUGIN_IS_FREED   1
 
#define PLUGIN_IS_DELETED   2
 
#define PLUGIN_IS_UNINITIALIZED   4
 
#define PLUGIN_IS_READY   8
 
#define PLUGIN_IS_DYING   16
 
#define PLUGIN_IS_DISABLED   32
 
#define PLUGIN_IS_WAITING_FOR_UPGRADE   64
 
#define my_plugin_lock_by_name(A, B, C)   plugin_lock_by_name(A, B, C)
 
#define my_plugin_lock_by_name_ci(A, B, C)   plugin_lock_by_name(A, B, C)
 
#define my_plugin_lock(A, B)   plugin_lock(A, B)
 
#define my_plugin_lock_ci(A, B)   plugin_lock(A, B)
 
#define plugin_foreach(A, B, C, D)    plugin_foreach_with_mask(A, B, C, PLUGIN_IS_READY, D)
 

Typedefs

typedef int(* plugin_type_init) (struct st_plugin_int *)
 
typedef bool() plugin_foreach_func(THD *thd, plugin_ref plugin, void *arg)
 

Functions

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 plugin_register_dynamic_and_init_all (int *argc, char **argv, int init_flags)
 Register and initialize the dynamic plugins. More...
 
bool update_persisted_plugin_sysvars (const char *name)
 Update read-write persisted plugin system variables. More...
 
bool dd::upgrade::plugin_initialize_delayed_after_upgrade ()
 Initialize delayed plugins. More...
 
bool is_builtin_and_core_se_initialized ()
 
void plugin_shutdown (void)
 
void add_plugin_options (std::vector< my_option > *options, MEM_ROOT *mem_root)
 
bool plugin_is_ready (const LEX_CSTRING &name, 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)
 
void plugin_unlock (THD *thd, plugin_ref plugin)
 
void plugin_unlock_list (THD *thd, plugin_ref *list, size_t count)
 
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 check_valid_path (const char *path, size_t length)
 Check if the provided path is valid in the sense that it does cause a relative reference outside the directory. More...
 
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...
 
bool plugin_foreach_with_mask (THD *thd, plugin_foreach_func *func, int type, uint state_mask, void *arg)
 
bool plugin_foreach_with_mask (THD *thd, plugin_foreach_func **funcs, int type, uint state_mask, void *arg)
 
bool end_transaction (THD *thd, bool error)
 
bool plugin_early_load_one (int *argc, char **argv, const char *plugin)
 Initialize one plugin. More...
 

Variables

const char * global_plugin_typelib_names []
 
mysql_mutex_t LOCK_plugin
 Serializes access to the global plugin memory list. More...
 
mysql_mutex_t LOCK_plugin_delete
 
I_List< i_string > * opt_plugin_load_list_ptr
 
I_List< i_string > * opt_early_plugin_load_list_ptr
 
char * opt_plugin_dir_ptr
 
char opt_plugin_dir [FN_REFLEN]
 
const LEX_CSTRING plugin_type_names []
 

Macro Definition Documentation

◆ my_plugin_lock

#define my_plugin_lock (   A,
 
)    plugin_lock(A, B)

◆ my_plugin_lock_by_name

#define my_plugin_lock_by_name (   A,
  B,
 
)    plugin_lock_by_name(A, B, C)

◆ my_plugin_lock_by_name_ci

#define my_plugin_lock_by_name_ci (   A,
  B,
 
)    plugin_lock_by_name(A, B, C)

◆ my_plugin_lock_ci

#define my_plugin_lock_ci (   A,
 
)    plugin_lock(A, B)

◆ MYSQL_ANY_PLUGIN

#define MYSQL_ANY_PLUGIN   -1

◆ plugin_foreach

#define plugin_foreach (   A,
  B,
  C,
 
)     plugin_foreach_with_mask(A, B, C, PLUGIN_IS_READY, D)

◆ PLUGIN_INIT_DELAY_UNTIL_AFTER_UPGRADE

#define PLUGIN_INIT_DELAY_UNTIL_AFTER_UPGRADE   8

◆ PLUGIN_INIT_SKIP_DYNAMIC_LOADING

#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING   1

◆ PLUGIN_INIT_SKIP_INITIALIZATION

#define PLUGIN_INIT_SKIP_INITIALIZATION   4

◆ PLUGIN_INIT_SKIP_PLUGIN_TABLE

#define PLUGIN_INIT_SKIP_PLUGIN_TABLE   2

◆ plugin_int_to_ref

#define plugin_int_to_ref (   A)    &(A)

◆ PLUGIN_IS_DELETED

#define PLUGIN_IS_DELETED   2

◆ PLUGIN_IS_DISABLED

#define PLUGIN_IS_DISABLED   32

◆ PLUGIN_IS_DYING

#define PLUGIN_IS_DYING   16

◆ PLUGIN_IS_FREED

#define PLUGIN_IS_FREED   1

◆ PLUGIN_IS_READY

#define PLUGIN_IS_READY   8

◆ PLUGIN_IS_UNINITIALIZED

#define PLUGIN_IS_UNINITIALIZED   4

◆ PLUGIN_IS_WAITING_FOR_UPGRADE

#define PLUGIN_IS_WAITING_FOR_UPGRADE   64

◆ plugin_ref_to_int

#define plugin_ref_to_int (   A)    (A ? A[0] : NULL)

Typedef Documentation

◆ plugin_foreach_func

typedef bool() plugin_foreach_func(THD *thd, plugin_ref plugin, void *arg)

◆ plugin_type_init

typedef int(* plugin_type_init) (struct st_plugin_int *)

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_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

◆ end_transaction()

bool end_transaction ( THD thd,
bool  error 
)

◆ is_builtin_and_core_se_initialized()

bool is_builtin_and_core_se_initialized ( )

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

bool plugin_is_ready ( const LEX_CSTRING name,
int  type 
)

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

◆ 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

◆ global_plugin_typelib_names

const char* global_plugin_typelib_names[]
extern
Note
The order of the enumeration is critical.
See also
construct_options

◆ LOCK_plugin

mysql_mutex_t LOCK_plugin
extern

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
extern

◆ opt_early_plugin_load_list_ptr

I_List<i_string>* opt_early_plugin_load_list_ptr
extern

◆ opt_plugin_dir

char opt_plugin_dir[FN_REFLEN]
extern

◆ opt_plugin_dir_ptr

char* opt_plugin_dir_ptr
extern

◆ opt_plugin_load_list_ptr

I_List<i_string>* opt_plugin_load_list_ptr
extern

◆ plugin_type_names

const LEX_CSTRING plugin_type_names[]
extern