123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752 |
- #ifndef _my_plugin_h
- #define _my_plugin_h
- #ifndef MYSQL_ABI_CHECK
- #include <stddef.h>
- #include "mysql_version.h"
- #endif
- #if defined(_MSC_VER)
- #if defined(MYSQL_DYNAMIC_PLUGIN)
- #ifdef __cplusplus
- #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
- #else
- #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
- #endif
- #else
- #ifdef __cplusplus
- #define MYSQL_PLUGIN_EXPORT extern "C"
- #else
- #define MYSQL_PLUGIN_EXPORT
- #endif
- #endif
- #else
- #define MYSQL_PLUGIN_EXPORT
- #endif
- #ifdef __cplusplus
- class THD;
- class Item;
- #define MYSQL_THD THD*
- #else
- #define MYSQL_THD void*
- #endif
- typedef void * MYSQL_PLUGIN;
- #ifndef MYSQL_ABI_CHECK
- #include <mysql/services.h>
- #endif
- #define MYSQL_XIDDATASIZE 128
- struct st_mysql_xid {
- long formatID;
- long gtrid_length;
- long bqual_length;
- char data[MYSQL_XIDDATASIZE];
- };
- typedef struct st_mysql_xid MYSQL_XID;
- #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0107
- #define MYSQL_UDF_PLUGIN 0
- #define MYSQL_STORAGE_ENGINE_PLUGIN 1
- #define MYSQL_FTPARSER_PLUGIN 2
- #define MYSQL_DAEMON_PLUGIN 3
- #define MYSQL_INFORMATION_SCHEMA_PLUGIN 4
- #define MYSQL_AUDIT_PLUGIN 5
- #define MYSQL_REPLICATION_PLUGIN 6
- #define MYSQL_AUTHENTICATION_PLUGIN 7
- #define MYSQL_VALIDATE_PASSWORD_PLUGIN 8
- #define MYSQL_GROUP_REPLICATION_PLUGIN 9
- #define MYSQL_KEYRING_PLUGIN 10
- #define MYSQL_MAX_PLUGIN_TYPE_NUM 11
- #define PLUGIN_LICENSE_PROPRIETARY 0
- #define PLUGIN_LICENSE_GPL 1
- #define PLUGIN_LICENSE_BSD 2
- #define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
- #define PLUGIN_LICENSE_GPL_STRING "GPL"
- #define PLUGIN_LICENSE_BSD_STRING "BSD"
- #ifndef MYSQL_DYNAMIC_PLUGIN
- #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
- MYSQL_PLUGIN_EXPORT int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \
- MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_mysql_plugin); \
- MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[]= {
- #else
- #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
- MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \
- MYSQL_PLUGIN_EXPORT int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin); \
- MYSQL_PLUGIN_EXPORT struct st_mysql_plugin _mysql_plugin_declarations_[]= {
- #endif
- #define mysql_declare_plugin(NAME) \
- __MYSQL_DECLARE_PLUGIN(NAME, \
- builtin_ ## NAME ## _plugin_interface_version, \
- builtin_ ## NAME ## _sizeof_struct_st_plugin, \
- builtin_ ## NAME ## _plugin)
- #define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}}
- enum enum_mysql_show_type
- {
- SHOW_UNDEF, SHOW_BOOL,
- SHOW_INT,
- SHOW_LONG,
- SHOW_LONGLONG,
- SHOW_CHAR, SHOW_CHAR_PTR,
- SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
- #ifdef MYSQL_SERVER
-
- #include "sql_plugin_enum.h"
- #endif
- };
- enum enum_mysql_show_scope
- {
- SHOW_SCOPE_UNDEF,
- SHOW_SCOPE_GLOBAL
- #ifdef MYSQL_SERVER
-
- ,
- SHOW_SCOPE_SESSION,
- SHOW_SCOPE_ALL
- #endif
- };
- struct st_mysql_show_var
- {
- const char *name;
- char *value;
- enum enum_mysql_show_type type;
- enum enum_mysql_show_scope scope;
- };
- #define SHOW_VAR_MAX_NAME_LEN 64
- #define SHOW_VAR_FUNC_BUFF_SIZE 1024
- typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *);
- #define PLUGIN_OPT_NO_INSTALL 1UL
- #define PLUGIN_OPT_NO_UNINSTALL 2UL
- #define PLUGIN_VAR_BOOL 0x0001
- #define PLUGIN_VAR_INT 0x0002
- #define PLUGIN_VAR_LONG 0x0003
- #define PLUGIN_VAR_LONGLONG 0x0004
- #define PLUGIN_VAR_STR 0x0005
- #define PLUGIN_VAR_ENUM 0x0006
- #define PLUGIN_VAR_SET 0x0007
- #define PLUGIN_VAR_DOUBLE 0x0008
- #define PLUGIN_VAR_UNSIGNED 0x0080
- #define PLUGIN_VAR_THDLOCAL 0x0100
- #define PLUGIN_VAR_READONLY 0x0200
- #define PLUGIN_VAR_NOSYSVAR 0x0400
- #define PLUGIN_VAR_NOCMDOPT 0x0800
- #define PLUGIN_VAR_NOCMDARG 0x1000
- #define PLUGIN_VAR_RQCMDARG 0x0000
- #define PLUGIN_VAR_OPCMDARG 0x2000
- #define PLUGIN_VAR_NODEFAULT 0x4000
- #define PLUGIN_VAR_MEMALLOC 0x8000
- #define PLUGIN_VAR_INVISIBLE 0x10000
- struct st_mysql_sys_var;
- struct st_mysql_value;
- typedef int (*mysql_var_check_func)(MYSQL_THD thd,
- struct st_mysql_sys_var *var,
- void *save, struct st_mysql_value *value);
- typedef void (*mysql_var_update_func)(MYSQL_THD thd,
- struct st_mysql_sys_var *var,
- void *var_ptr, const void *save);
- #define PLUGIN_VAR_MASK \
- (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
- PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
- PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC | \
- PLUGIN_VAR_NODEFAULT | PLUGIN_VAR_INVISIBLE)
- #define MYSQL_PLUGIN_VAR_HEADER \
- int flags; \
- const char *name; \
- const char *comment; \
- mysql_var_check_func check; \
- mysql_var_update_func update
- #define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
- #define MYSQL_SYSVAR(name) \
- ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
-
- #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
- MYSQL_PLUGIN_VAR_HEADER; \
- type *value; \
- const type def_val; \
- } MYSQL_SYSVAR_NAME(name)
- #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
- MYSQL_PLUGIN_VAR_HEADER; \
- type *value; type def_val; \
- type min_val; type max_val; \
- type blk_sz; \
- } MYSQL_SYSVAR_NAME(name)
- #define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
- MYSQL_PLUGIN_VAR_HEADER; \
- type *value; type def_val; \
- TYPELIB *typelib; \
- } MYSQL_SYSVAR_NAME(name)
- #define DECLARE_THDVAR_FUNC(type) \
- type *(*resolve)(MYSQL_THD thd, int offset)
- #define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
- MYSQL_PLUGIN_VAR_HEADER; \
- int offset; \
- const type def_val; \
- DECLARE_THDVAR_FUNC(type); \
- } MYSQL_SYSVAR_NAME(name)
- #define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
- MYSQL_PLUGIN_VAR_HEADER; \
- int offset; \
- type def_val; type min_val; \
- type max_val; type blk_sz; \
- DECLARE_THDVAR_FUNC(type); \
- } MYSQL_SYSVAR_NAME(name)
- #define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
- MYSQL_PLUGIN_VAR_HEADER; \
- int offset; \
- type def_val; \
- DECLARE_THDVAR_FUNC(type); \
- TYPELIB *typelib; \
- } MYSQL_SYSVAR_NAME(name)
- #define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
- DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \
- PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def}
- #define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
- DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
- PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def}
- #define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
- PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
- PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
- PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
- PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \
- PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
- PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
- DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
- PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, typelib }
- #define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
- DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \
- PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, typelib }
- #define MYSQL_SYSVAR_DOUBLE(name, varname, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_SYSVAR_SIMPLE(name, double) = { \
- PLUGIN_VAR_DOUBLE | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, &varname, def, min, max, blk }
- #define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
- DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \
- PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, NULL}
- #define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
- DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
- PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, NULL}
- #define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
- PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
- PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
- PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
- PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \
- PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \
- PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
- DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
- PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, NULL, typelib }
- #define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
- DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \
- PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, NULL, typelib }
- #define MYSQL_THDVAR_DOUBLE(name, opt, comment, check, update, def, min, max, blk) \
- DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \
- PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
- #name, comment, check, update, -1, def, min, max, blk, NULL }
- #define SYSVAR(name) \
- (*(MYSQL_SYSVAR_NAME(name).value))
- #define THDVAR(thd, name) \
- (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
- struct st_mysql_plugin
- {
- int type;
- void *info;
- const char *name;
- const char *author;
- const char *descr;
- int license;
- int (*init)(MYSQL_PLUGIN);
- int (*deinit)(MYSQL_PLUGIN);
- unsigned int version;
- struct st_mysql_show_var *status_vars;
- struct st_mysql_sys_var **system_vars;
- void * __reserved1;
- unsigned long flags;
- };
- #define MYSQL_FTPARSER_INTERFACE_VERSION 0x0101
- #define MYSQL_REWRITE_PRE_PARSE_INTERFACE_VERSION 0x0010
- #define MYSQL_REWRITE_POST_PARSE_INTERFACE_VERSION 0x0010
- #define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
- struct st_mysql_daemon
- {
- int interface_version;
- };
- #define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
- struct st_mysql_information_schema
- {
- int interface_version;
- };
- #define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
- struct st_mysql_storage_engine
- {
- int interface_version;
- };
- struct handlerton;
- #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0400
-
- struct Mysql_replication {
- int interface_version;
- };
- #define MYSQL_VALUE_TYPE_STRING 0
- #define MYSQL_VALUE_TYPE_REAL 1
- #define MYSQL_VALUE_TYPE_INT 2
- struct st_mysql_value
- {
- int (*value_type)(struct st_mysql_value *);
- const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
- int (*val_real)(struct st_mysql_value *, double *realbuf);
- int (*val_int)(struct st_mysql_value *, long long *intbuf);
- int (*is_unsigned)(struct st_mysql_value *);
- };
- #ifdef __cplusplus
- extern "C" {
- #endif
- int thd_in_lock_tables(const MYSQL_THD thd);
- int thd_tablespace_op(const MYSQL_THD thd);
- long long thd_test_options(const MYSQL_THD thd, long long test_options);
- int thd_sql_command(const MYSQL_THD thd);
- const char *set_thd_proc_info(MYSQL_THD thd, const char *info,
- const char *calling_func,
- const char *calling_file,
- const unsigned int calling_line);
- void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
- void thd_storage_lock_wait(MYSQL_THD thd, long long value);
- int thd_tx_isolation(const MYSQL_THD thd);
- int thd_tx_is_read_only(const MYSQL_THD thd);
- MYSQL_THD thd_tx_arbitrate(MYSQL_THD requestor, MYSQL_THD holder);
- int thd_tx_priority(const MYSQL_THD thd);
- int thd_tx_is_dd_trx(const MYSQL_THD thd);
- char *thd_security_context(MYSQL_THD thd, char *buffer, size_t length,
- size_t max_query_len);
- void thd_inc_row_count(MYSQL_THD thd);
- int thd_allow_batch(MYSQL_THD thd);
- void thd_mark_transaction_to_rollback(MYSQL_THD thd, int all);
- int mysql_tmpfile(const char *prefix);
- int thd_killed(const MYSQL_THD thd);
- void thd_set_kill_status(const MYSQL_THD thd);
- void thd_binlog_pos(const MYSQL_THD thd,
- const char **file_var,
- unsigned long long *pos_var);
- unsigned long thd_get_thread_id(const MYSQL_THD thd);
- void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
- void mysql_query_cache_invalidate4(MYSQL_THD thd,
- const char *key, unsigned int key_length,
- int using_trx);
- void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
- void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
- const void *ha_data);
- #ifdef __cplusplus
- }
- #endif
- #endif
|