MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plugin.h
1 /* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef _my_plugin_h
17 #define _my_plugin_h
18 
19 /*
20  On Windows, exports from DLL need to be declared
21  Also, plugin needs to be declared as extern "C" because MSVC
22  unlike other compilers, uses C++ mangling for variables not only
23  for functions.
24 */
25 #if defined(_MSC_VER)
26 #if defined(MYSQL_DYNAMIC_PLUGIN)
27  #ifdef __cplusplus
28  #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
29  #else
30  #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
31  #endif
32 #else /* MYSQL_DYNAMIC_PLUGIN */
33  #ifdef __cplusplus
34  #define MYSQL_PLUGIN_EXPORT extern "C"
35  #else
36  #define MYSQL_PLUGIN_EXPORT
37  #endif
38 #endif /*MYSQL_DYNAMIC_PLUGIN */
39 #else /*_MSC_VER */
40 #define MYSQL_PLUGIN_EXPORT
41 #endif
42 
43 #ifdef __cplusplus
44 class THD;
45 class Item;
46 #define MYSQL_THD THD*
47 #else
48 #define MYSQL_THD void*
49 #endif
50 
51 typedef void * MYSQL_PLUGIN;
52 
53 #include <mysql/services.h>
54 
55 #define MYSQL_XIDDATASIZE 128
56 
64 struct st_mysql_xid {
65  long formatID;
66  long gtrid_length;
67  long bqual_length;
68  char data[MYSQL_XIDDATASIZE]; /* Not \0-terminated */
69 };
70 typedef struct st_mysql_xid MYSQL_XID;
71 
72 /*************************************************************************
73  Plugin API. Common for all plugin types.
74 */
75 
76 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104
77 
78 /*
79  The allowable types of plugins
80 */
81 #define MYSQL_UDF_PLUGIN 0 /* User-defined function */
82 #define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
83 #define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
84 #define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */
85 #define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */
86 #define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */
87 #define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */
88 #define MYSQL_AUTHENTICATION_PLUGIN 7 /* The authentication plugin type */
89 #define MYSQL_VALIDATE_PASSWORD_PLUGIN 8 /* validate password plugin type */
90 #define MYSQL_MAX_PLUGIN_TYPE_NUM 9 /* The number of plugin types */
91 
92 /* We use the following strings to define licenses for plugins */
93 #define PLUGIN_LICENSE_PROPRIETARY 0
94 #define PLUGIN_LICENSE_GPL 1
95 #define PLUGIN_LICENSE_BSD 2
96 
97 #define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
98 #define PLUGIN_LICENSE_GPL_STRING "GPL"
99 #define PLUGIN_LICENSE_BSD_STRING "BSD"
100 
101 /*
102  Macros for beginning and ending plugin declarations. Between
103  mysql_declare_plugin and mysql_declare_plugin_end there should
104  be a st_mysql_plugin struct for each plugin to be declared.
105 */
106 
107 
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[]= {
113 #else
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_[]= {
118 #endif
119 
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)
125 
126 #define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}}
127 
131 enum enum_mysql_show_type
132 {
133  SHOW_UNDEF, SHOW_BOOL,
134  SHOW_INT,
135  SHOW_LONG,
136  SHOW_LONGLONG,
137  SHOW_CHAR, SHOW_CHAR_PTR,
138  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
139  SHOW_always_last
140 };
141 
143  const char *name;
144  char *value;
145  enum enum_mysql_show_type type;
146 };
147 
148 #define SHOW_VAR_FUNC_BUFF_SIZE 1024
149 typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *);
150 
151 
152 /*
153  Constants for plugin flags.
154  */
155 
156 #define PLUGIN_OPT_NO_INSTALL 1UL /* Not dynamically loadable */
157 #define PLUGIN_OPT_NO_UNINSTALL 2UL /* Not dynamically unloadable */
158 
159 
160 /*
161  declarations for server variables and command line options
162 */
163 
164 
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 /* Variable is per-connection */
175 #define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
176 #define PLUGIN_VAR_NOSYSVAR 0x0400 /* Not a server variable */
177 #define PLUGIN_VAR_NOCMDOPT 0x0800 /* Not a command line option */
178 #define PLUGIN_VAR_NOCMDARG 0x1000 /* No argument for cmd line */
179 #define PLUGIN_VAR_RQCMDARG 0x0000 /* Argument required for cmd line */
180 #define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */
181 #define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */
182 
183 struct st_mysql_sys_var;
184 struct st_mysql_value;
185 
186 /*
187  SYNOPSIS
188  (*mysql_var_check_func)()
189  thd thread handle
190  var dynamic variable being altered
191  save pointer to temporary storage
192  value user provided value
193  RETURN
194  0 user provided value is OK and the update func may be called.
195  any other value indicates error.
196 
197  This function should parse the user provided value and store in the
198  provided temporary storage any data as required by the update func.
199  There is sufficient space in the temporary storage to store a double.
200  Note that the update func may not be called if any other error occurs
201  so any memory allocated should be thread-local so that it may be freed
202  automatically at the end of the statement.
203 */
204 
205 typedef int (*mysql_var_check_func)(MYSQL_THD thd,
206  struct st_mysql_sys_var *var,
207  void *save, struct st_mysql_value *value);
208 
209 /*
210  SYNOPSIS
211  (*mysql_var_update_func)()
212  thd thread handle
213  var dynamic variable being altered
214  var_ptr pointer to dynamic variable
215  save pointer to temporary storage
216  RETURN
217  NONE
218 
219  This function should use the validated value stored in the temporary store
220  and persist it in the provided pointer to the dynamic variable.
221  For example, strings may require memory to be allocated.
222 */
223 typedef void (*mysql_var_update_func)(MYSQL_THD thd,
224  struct st_mysql_sys_var *var,
225  void *var_ptr, const void *save);
226 
227 
228 /* the following declarations are for internal use only */
229 
230 
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)
235 
236 #define MYSQL_PLUGIN_VAR_HEADER \
237  int flags; \
238  const char *name; \
239  const char *comment; \
240  mysql_var_check_func check; \
241  mysql_var_update_func update
242 
243 #define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
244 #define MYSQL_SYSVAR(name) \
245  ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
246 
247 /*
248  for global variables, the value pointer is the first
249  element after the header, the default value is the second.
250  for thread variables, the value offset is the first
251  element after the header, the default value is the second.
252 */
253 
254 
255 #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
256  MYSQL_PLUGIN_VAR_HEADER; \
257  type *value; \
258  const type def_val; \
259 } MYSQL_SYSVAR_NAME(name)
260 
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; \
265  type blk_sz; \
266 } MYSQL_SYSVAR_NAME(name)
267 
268 #define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
269  MYSQL_PLUGIN_VAR_HEADER; \
270  type *value; type def_val; \
271  TYPELIB *typelib; \
272 } MYSQL_SYSVAR_NAME(name)
273 
274 #define DECLARE_THDVAR_FUNC(type) \
275  type *(*resolve)(MYSQL_THD thd, int offset)
276 
277 #define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
278  MYSQL_PLUGIN_VAR_HEADER; \
279  int offset; \
280  const type def_val; \
281  DECLARE_THDVAR_FUNC(type); \
282 } MYSQL_SYSVAR_NAME(name)
283 
284 #define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
285  MYSQL_PLUGIN_VAR_HEADER; \
286  int offset; \
287  type def_val; type min_val; \
288  type max_val; type blk_sz; \
289  DECLARE_THDVAR_FUNC(type); \
290 } MYSQL_SYSVAR_NAME(name)
291 
292 #define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
293  MYSQL_PLUGIN_VAR_HEADER; \
294  int offset; \
295  type def_val; \
296  DECLARE_THDVAR_FUNC(type); \
297  TYPELIB *typelib; \
298 } MYSQL_SYSVAR_NAME(name)
299 
300 
301 /*
302  the following declarations are for use by plugin implementors
303 */
304 
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}
309 
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}
314 
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 }
319 
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 }
324 
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 }
329 
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 }
334 
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 }
339 
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 }
344 
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 }
349 
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 }
354 
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 }
359 
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}
364 
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}
369 
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 }
374 
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 }
379 
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 }
384 
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 }
389 
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 }
394 
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 }
399 
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 }
404 
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 }
409 
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 }
414 
415 /* accessor macros */
416 
417 #define SYSVAR(name) \
418  (*(MYSQL_SYSVAR_NAME(name).value))
419 
420 /* when thd == null, result points to global value */
421 #define THDVAR(thd, name) \
422  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
423 
424 
425 /*
426  Plugin description structure.
427 */
428 
430 {
431  int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
432  void *info; /* pointer to type-specific plugin descriptor */
433  const char *name; /* plugin name */
434  const char *author; /* plugin author (for I_S.PLUGINS) */
435  const char *descr; /* general descriptive text (for I_S.PLUGINS) */
436  int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
437  int (*init)(MYSQL_PLUGIN); /* the function to invoke when plugin is loaded */
438  int (*deinit)(MYSQL_PLUGIN);/* the function to invoke when plugin is unloaded */
439  unsigned int version; /* plugin version (for I_S.PLUGINS) */
440  struct st_mysql_show_var *status_vars;
441  struct st_mysql_sys_var **system_vars;
442  void * __reserved1; /* reserved for dependency checking */
443  unsigned long flags; /* flags for plugin */
444 };
445 
446 /*************************************************************************
447  API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
448 */
449 #include "plugin_ftparser.h"
450 
451 /*************************************************************************
452  API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
453 */
454 
455 /* handlertons of different MySQL releases are incompatible */
456 #define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
457 
458 /*
459  Here we define only the descriptor structure, that is referred from
460  st_mysql_plugin.
461 */
462 
464 {
465  int interface_version;
466 };
467 
468 
469 /*************************************************************************
470  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
471 */
472 
473 /* handlertons of different MySQL releases are incompatible */
474 #define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
475 
476 /*
477  Here we define only the descriptor structure, that is referred from
478  st_mysql_plugin.
479 */
480 
482 {
483  int interface_version;
484 };
485 
486 
487 /*************************************************************************
488  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
489 */
490 
491 /* handlertons of different MySQL releases are incompatible */
492 #define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
493 
494 /*
495  The real API is in the sql/handler.h
496  Here we define only the descriptor structure, that is referred from
497  st_mysql_plugin.
498 */
499 
501 {
502  int interface_version;
503 };
504 
505 struct handlerton;
506 
507 
508 /*
509  API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
510 */
511  #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0200
512 
517  int interface_version;
518  };
519 
520 /*************************************************************************
521  st_mysql_value struct for reading values from mysqld.
522  Used by server variables framework to parse user-provided values.
523  Will be used for arguments when implementing UDFs.
524 
525  Note that val_str() returns a string in temporary memory
526  that will be freed at the end of statement. Copy the string
527  if you need it to persist.
528 */
529 
530 #define MYSQL_VALUE_TYPE_STRING 0
531 #define MYSQL_VALUE_TYPE_REAL 1
532 #define MYSQL_VALUE_TYPE_INT 2
533 
535 {
536  int (*value_type)(struct st_mysql_value *);
537  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
538  int (*val_real)(struct st_mysql_value *, double *realbuf);
539  int (*val_int)(struct st_mysql_value *, long long *intbuf);
540  int (*is_unsigned)(struct st_mysql_value *);
541 };
542 
543 
544 /*************************************************************************
545  Miscellaneous functions for plugin implementors
546 */
547 
548 #ifdef __cplusplus
549 extern "C" {
550 #endif
551 
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);
563 /* Increments the row counter, see THD::row_count */
564 void thd_inc_row_count(MYSQL_THD thd);
565 int thd_allow_batch(MYSQL_THD thd);
566 
579 int mysql_tmpfile(const char *prefix);
580 
595 int thd_killed(const MYSQL_THD thd);
596 
597 
609 void thd_binlog_pos(const MYSQL_THD thd,
610  const char **file_var,
611  unsigned long long *pos_var);
612 
619 unsigned long thd_get_thread_id(const MYSQL_THD thd);
620 
627 void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
628 
637 void mysql_query_cache_invalidate4(MYSQL_THD thd,
638  const char *key, unsigned int key_length,
639  int using_trx);
640 
641 
645 void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
646 
647 
669 void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
670  const void *ha_data);
671 #ifdef __cplusplus
672 }
673 #endif
674 
675 #endif
676