26 #if defined(MYSQL_DYNAMIC_PLUGIN) 
   28     #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport) 
   30     #define MYSQL_PLUGIN_EXPORT __declspec(dllexport) 
   34     #define  MYSQL_PLUGIN_EXPORT extern "C" 
   36     #define MYSQL_PLUGIN_EXPORT  
   40 #define MYSQL_PLUGIN_EXPORT 
   46 #define MYSQL_THD THD* 
   48 #define MYSQL_THD void* 
   51 typedef void * MYSQL_PLUGIN;
 
   53 #include <mysql/services.h> 
   55 #define MYSQL_XIDDATASIZE 128 
   68   char data[MYSQL_XIDDATASIZE];  
 
   76 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104 
   81 #define MYSQL_UDF_PLUGIN             0   
   82 #define MYSQL_STORAGE_ENGINE_PLUGIN  1   
   83 #define MYSQL_FTPARSER_PLUGIN        2   
   84 #define MYSQL_DAEMON_PLUGIN          3   
   85 #define MYSQL_INFORMATION_SCHEMA_PLUGIN  4   
   86 #define MYSQL_AUDIT_PLUGIN           5   
   87 #define MYSQL_REPLICATION_PLUGIN     6   
   88 #define MYSQL_AUTHENTICATION_PLUGIN  7   
   89 #define MYSQL_VALIDATE_PASSWORD_PLUGIN  8    
   90 #define MYSQL_MAX_PLUGIN_TYPE_NUM    9   
   93 #define PLUGIN_LICENSE_PROPRIETARY 0 
   94 #define PLUGIN_LICENSE_GPL 1 
   95 #define PLUGIN_LICENSE_BSD 2 
   97 #define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY" 
   98 #define PLUGIN_LICENSE_GPL_STRING "GPL" 
   99 #define PLUGIN_LICENSE_BSD_STRING "BSD" 
  108 #ifndef MYSQL_DYNAMIC_PLUGIN 
  109 #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \ 
  110 MYSQL_PLUGIN_EXPORT int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION;                                  \ 
  111 MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_mysql_plugin);                                    \ 
  112 MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[]= { 
  114 #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \ 
  115 MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION;         \ 
  116 MYSQL_PLUGIN_EXPORT int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin);          \ 
  117 MYSQL_PLUGIN_EXPORT struct st_mysql_plugin _mysql_plugin_declarations_[]= { 
  120 #define mysql_declare_plugin(NAME) \ 
  121 __MYSQL_DECLARE_PLUGIN(NAME, \ 
  122                  builtin_ ## NAME ## _plugin_interface_version, \ 
  123                  builtin_ ## NAME ## _sizeof_struct_st_plugin, \ 
  124                  builtin_ ## NAME ## _plugin) 
  126 #define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}} 
  131 enum enum_mysql_show_type
 
  133   SHOW_UNDEF, SHOW_BOOL,
 
  137   SHOW_CHAR, SHOW_CHAR_PTR,
 
  138   SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
 
  145   enum enum_mysql_show_type type;
 
  148 #define SHOW_VAR_FUNC_BUFF_SIZE 1024 
  149 typedef int (*mysql_show_var_func)(MYSQL_THD, 
struct st_mysql_show_var*, 
char *);
 
  156 #define PLUGIN_OPT_NO_INSTALL   1UL    
  157 #define PLUGIN_OPT_NO_UNINSTALL 2UL    
  165 #define PLUGIN_VAR_BOOL         0x0001 
  166 #define PLUGIN_VAR_INT          0x0002 
  167 #define PLUGIN_VAR_LONG         0x0003 
  168 #define PLUGIN_VAR_LONGLONG     0x0004 
  169 #define PLUGIN_VAR_STR          0x0005 
  170 #define PLUGIN_VAR_ENUM         0x0006 
  171 #define PLUGIN_VAR_SET          0x0007 
  172 #define PLUGIN_VAR_DOUBLE       0x0008 
  173 #define PLUGIN_VAR_UNSIGNED     0x0080 
  174 #define PLUGIN_VAR_THDLOCAL     0x0100  
  175 #define PLUGIN_VAR_READONLY     0x0200  
  176 #define PLUGIN_VAR_NOSYSVAR     0x0400  
  177 #define PLUGIN_VAR_NOCMDOPT     0x0800  
  178 #define PLUGIN_VAR_NOCMDARG     0x1000  
  179 #define PLUGIN_VAR_RQCMDARG     0x0000  
  180 #define PLUGIN_VAR_OPCMDARG     0x2000  
  181 #define PLUGIN_VAR_MEMALLOC     0x8000  
  205 typedef int (*mysql_var_check_func)(MYSQL_THD thd,
 
  223 typedef void (*mysql_var_update_func)(MYSQL_THD thd,
 
  225                                       void *var_ptr, 
const void *save);
 
  231 #define PLUGIN_VAR_MASK \ 
  232         (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \ 
  233          PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \ 
  234          PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC) 
  236 #define MYSQL_PLUGIN_VAR_HEADER \ 
  239   const char *comment;          \ 
  240   mysql_var_check_func check;   \ 
  241   mysql_var_update_func update 
  243 #define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name 
  244 #define MYSQL_SYSVAR(name) \ 
  245   ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name))) 
  255 #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \ 
  256   MYSQL_PLUGIN_VAR_HEADER;      \ 
  258   const type def_val;           \ 
  259 } MYSQL_SYSVAR_NAME(name) 
  261 #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \ 
  262   MYSQL_PLUGIN_VAR_HEADER;      \ 
  263   type *value; type def_val;    \ 
  264   type min_val; type max_val;   \ 
  266 } MYSQL_SYSVAR_NAME(name) 
  268 #define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \ 
  269   MYSQL_PLUGIN_VAR_HEADER;      \ 
  270   type *value; type def_val;    \ 
  272 } MYSQL_SYSVAR_NAME(name) 
  274 #define DECLARE_THDVAR_FUNC(type) \ 
  275   type *(*resolve)(MYSQL_THD thd, int offset) 
  277 #define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \ 
  278   MYSQL_PLUGIN_VAR_HEADER;      \ 
  280   const type def_val;           \ 
  281   DECLARE_THDVAR_FUNC(type);    \ 
  282 } MYSQL_SYSVAR_NAME(name) 
  284 #define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \ 
  285   MYSQL_PLUGIN_VAR_HEADER;      \ 
  287   type def_val; type min_val;   \ 
  288   type max_val; type blk_sz;    \ 
  289   DECLARE_THDVAR_FUNC(type);    \ 
  290 } MYSQL_SYSVAR_NAME(name) 
  292 #define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \ 
  293   MYSQL_PLUGIN_VAR_HEADER;      \ 
  296   DECLARE_THDVAR_FUNC(type);    \ 
  298 } MYSQL_SYSVAR_NAME(name) 
  305 #define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \ 
  306 DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \ 
  307   PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \ 
  308   #name, comment, check, update, &varname, def} 
  310 #define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \ 
  311 DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \ 
  312   PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \ 
  313   #name, comment, check, update, &varname, def} 
  315 #define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  316 DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \ 
  317   PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \ 
  318   #name, comment, check, update, &varname, def, min, max, blk } 
  320 #define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  321 DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \ 
  322   PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ 
  323   #name, comment, check, update, &varname, def, min, max, blk } 
  325 #define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  326 DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \ 
  327   PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \ 
  328   #name, comment, check, update, &varname, def, min, max, blk } 
  330 #define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  331 DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \ 
  332   PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ 
  333   #name, comment, check, update, &varname, def, min, max, blk } 
  335 #define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  336 DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \ 
  337   PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \ 
  338   #name, comment, check, update, &varname, def, min, max, blk } 
  340 #define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  341 DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \ 
  342   PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ 
  343   #name, comment, check, update, &varname, def, min, max, blk } 
  345 #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \ 
  346 DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \ 
  347   PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \ 
  348   #name, comment, check, update, &varname, def, typelib } 
  350 #define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \ 
  351 DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \ 
  352   PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \ 
  353   #name, comment, check, update, &varname, def, typelib } 
  355 #define MYSQL_SYSVAR_DOUBLE(name, varname, opt, comment, check, update, def, min, max, blk) \ 
  356 DECLARE_MYSQL_SYSVAR_SIMPLE(name, double) = { \ 
  357   PLUGIN_VAR_DOUBLE | ((opt) & PLUGIN_VAR_MASK), \ 
  358   #name, comment, check, update, &varname, def, min, max, blk } 
  360 #define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \ 
  361 DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \ 
  362   PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  363   #name, comment, check, update, -1, def, NULL} 
  365 #define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \ 
  366 DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \ 
  367   PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  368   #name, comment, check, update, -1, def, NULL} 
  370 #define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \ 
  371 DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \ 
  372   PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  373   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  375 #define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \ 
  376 DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \ 
  377   PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ 
  378   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  380 #define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \ 
  381 DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \ 
  382   PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  383   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  385 #define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \ 
  386 DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \ 
  387   PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ 
  388   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  390 #define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \ 
  391 DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \ 
  392   PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  393   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  395 #define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \ 
  396 DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \ 
  397   PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ 
  398   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  400 #define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \ 
  401 DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \ 
  402   PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  403   #name, comment, check, update, -1, def, NULL, typelib } 
  405 #define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \ 
  406 DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \ 
  407   PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  408   #name, comment, check, update, -1, def, NULL, typelib } 
  410 #define MYSQL_THDVAR_DOUBLE(name, opt, comment, check, update, def, min, max, blk) \ 
  411 DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \ 
  412   PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ 
  413   #name, comment, check, update, -1, def, min, max, blk, NULL } 
  417 #define SYSVAR(name) \ 
  418   (*(MYSQL_SYSVAR_NAME(name).value)) 
  421 #define THDVAR(thd, name) \ 
  422   (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset))) 
  437   int (*init)(MYSQL_PLUGIN);  
 
  438   int (*deinit)(MYSQL_PLUGIN);
 
  439   unsigned int version; 
 
  449 #include "plugin_ftparser.h" 
  456 #define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8) 
  465   int interface_version;
 
  474 #define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8) 
  483   int interface_version;
 
  492 #define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8) 
  502   int interface_version;
 
  511  #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0200 
  517    int interface_version;
 
  530 #define MYSQL_VALUE_TYPE_STRING 0 
  531 #define MYSQL_VALUE_TYPE_REAL   1 
  532 #define MYSQL_VALUE_TYPE_INT    2 
  537   const char *(*val_str)(
struct st_mysql_value *, 
char *buffer, 
int *length);
 
  552 int thd_in_lock_tables(
const MYSQL_THD thd);
 
  553 int thd_tablespace_op(
const MYSQL_THD thd);
 
  554 long long thd_test_options(
const MYSQL_THD thd, 
long long test_options);
 
  555 int thd_sql_command(
const MYSQL_THD thd);
 
  556 const char *thd_proc_info(MYSQL_THD thd, 
const char *info);
 
  557 void **thd_ha_data(
const MYSQL_THD thd, 
const struct handlerton *hton);
 
  558 void thd_storage_lock_wait(MYSQL_THD thd, 
long long value);
 
  559 int thd_tx_isolation(
const MYSQL_THD thd);
 
  560 int thd_tx_is_read_only(
const MYSQL_THD thd);
 
  561 char *thd_security_context(MYSQL_THD thd, 
char *buffer, 
unsigned int length,
 
  562                            unsigned int max_query_len);
 
  564 void thd_inc_row_count(MYSQL_THD thd);
 
  565 int thd_allow_batch(MYSQL_THD thd);
 
  579 int mysql_tmpfile(
const char *prefix);
 
  595 int thd_killed(
const MYSQL_THD thd);
 
  609 void thd_binlog_pos(
const MYSQL_THD thd,
 
  610                     const char **file_var,
 
  611                     unsigned long long *pos_var);
 
  619 unsigned long thd_get_thread_id(
const MYSQL_THD thd);
 
  627 void thd_get_xid(
const MYSQL_THD thd, 
MYSQL_XID *xid);
 
  637 void mysql_query_cache_invalidate4(MYSQL_THD thd,
 
  638                                    const char *key, 
unsigned int key_length,
 
  645 void *thd_get_ha_data(
const MYSQL_THD thd, 
const struct handlerton *hton);
 
  669 void thd_set_ha_data(MYSQL_THD thd, 
const struct handlerton *hton,
 
  670                      const void *ha_data);