MySQL  8.0.16
Source Code Documentation
plugin.h
Go to the documentation of this file.
1 /* Copyright (c) 2005, 2019, 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, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef _my_plugin_h
24 #define _my_plugin_h
25 
26 /**
27  @file include/mysql/plugin.h
28 */
29 
30 #ifndef MYSQL_ABI_CHECK
31 #include <stddef.h>
32 
33 #include "mysql_version.h" /* MYSQL_VERSION_ID */
34 #ifdef __cplusplus
35 #include "sql/sql_plugin.h" // plugin_thdvar_safe_update
36 #endif
37 #endif
38 
39 #include "status_var.h"
40 
41 /*
42  On Windows, exports from DLL need to be declared.
43  Also, plugin needs to be declared as extern "C" because MSVC
44  unlike other compilers, uses C++ mangling for variables not only
45  for functions.
46 */
47 #if defined(_MSC_VER)
48 #if defined(MYSQL_DYNAMIC_PLUGIN)
49 #ifdef __cplusplus
50 #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
51 #else
52 #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
53 #endif
54 #else /* MYSQL_DYNAMIC_PLUGIN */
55 #ifdef __cplusplus
56 #define MYSQL_PLUGIN_EXPORT extern "C"
57 #else
58 #define MYSQL_PLUGIN_EXPORT
59 #endif
60 #endif /*MYSQL_DYNAMIC_PLUGIN */
61 #else /*_MSC_VER */
62 #define MYSQL_PLUGIN_EXPORT
63 #endif
64 
65 #ifdef __cplusplus
66 class THD;
67 class Item;
68 #define MYSQL_THD THD *
69 #else
70 #define MYSQL_THD void *
71 #endif
72 
73 typedef void *MYSQL_PLUGIN;
74 
75 #ifndef MYSQL_ABI_CHECK
76 #include <mysql/services.h>
77 #endif
78 
79 #define MYSQL_XIDDATASIZE 128
80 /**
81  MYSQL_XID is binary compatible with the XID structure as
82  in the X/Open CAE Specification, Distributed Transaction Processing:
83  The XA Specification, X/Open Company Ltd., 1991.
84  http://www.opengroup.org/bookstore/catalog/c193.htm
85 
86  @see XID in sql/handler.h
87 */
88 struct MYSQL_XID {
89  long formatID;
92  char data[MYSQL_XIDDATASIZE]; /* Not \0-terminated */
93 };
94 
95 /*************************************************************************
96  Plugin API. Common for all plugin types.
97 */
98 
99 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0109
100 
101 /*
102  The allowable types of plugins
103 */
104 #define MYSQL_UDF_PLUGIN 0 /* User-defined function */
105 #define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
106 #define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
107 #define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */
108 #define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */
109 #define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */
110 #define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */
111 #define MYSQL_AUTHENTICATION_PLUGIN 7 /* The authentication plugin type */
112 #define MYSQL_VALIDATE_PASSWORD_PLUGIN 8 /* validate password plugin type */
113 #define MYSQL_GROUP_REPLICATION_PLUGIN 9 /* The Group Replication plugin */
114 #define MYSQL_KEYRING_PLUGIN 10 /* The Keyring plugin type */
115 #define MYSQL_CLONE_PLUGIN 11 /* The Clone plugin type */
116 #define MYSQL_MAX_PLUGIN_TYPE_NUM 12 /* The number of plugin types */
117 
118 /* We use the following strings to define licenses for plugins */
119 #define PLUGIN_LICENSE_PROPRIETARY 0
120 #define PLUGIN_LICENSE_GPL 1
121 #define PLUGIN_LICENSE_BSD 2
122 
123 #define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
124 #define PLUGIN_LICENSE_GPL_STRING "GPL"
125 #define PLUGIN_LICENSE_BSD_STRING "BSD"
126 
127 /*
128  Macros for beginning and ending plugin declarations. Between
129  mysql_declare_plugin and mysql_declare_plugin_end there should
130  be a st_mysql_plugin struct for each plugin to be declared.
131 */
132 
133 #ifndef MYSQL_DYNAMIC_PLUGIN
134 #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
135  MYSQL_PLUGIN_EXPORT int VERSION = MYSQL_PLUGIN_INTERFACE_VERSION; \
136  MYSQL_PLUGIN_EXPORT int PSIZE = sizeof(struct st_mysql_plugin); \
137  MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[] = {
138 #else
139 #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
140  MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_ = \
141  MYSQL_PLUGIN_INTERFACE_VERSION; \
142  MYSQL_PLUGIN_EXPORT int _mysql_sizeof_struct_st_plugin_ = \
143  sizeof(struct st_mysql_plugin); \
144  MYSQL_PLUGIN_EXPORT struct st_mysql_plugin _mysql_plugin_declarations_[] = {
145 #endif
146 
147 #define mysql_declare_plugin(NAME) \
148  __MYSQL_DECLARE_PLUGIN(NAME, builtin_##NAME##_plugin_interface_version, \
149  builtin_##NAME##_sizeof_struct_st_plugin, \
150  builtin_##NAME##_plugin)
151 
152 #define mysql_declare_plugin_end \
153  , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } \
154  }
155 
156 /*
157  Constants for plugin flags.
158  */
159 
160 #define PLUGIN_OPT_NO_INSTALL 1UL /* Not dynamically loadable */
161 #define PLUGIN_OPT_NO_UNINSTALL 2UL /* Not dynamically unloadable */
162 
163 /*
164  declarations for server variables and command line options
165 */
166 
167 #define PLUGIN_VAR_BOOL 0x0001
168 #define PLUGIN_VAR_INT 0x0002
169 #define PLUGIN_VAR_LONG 0x0003
170 #define PLUGIN_VAR_LONGLONG 0x0004
171 #define PLUGIN_VAR_STR 0x0005
172 #define PLUGIN_VAR_ENUM 0x0006
173 #define PLUGIN_VAR_SET 0x0007
174 #define PLUGIN_VAR_DOUBLE 0x0008
175 #define PLUGIN_VAR_UNSIGNED 0x0080
176 #define PLUGIN_VAR_THDLOCAL 0x0100 /* Variable is per-connection */
177 #define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
178 #define PLUGIN_VAR_NOSYSVAR 0x0400 /* Configurable only by cmd-line */
179 #define PLUGIN_VAR_NOCMDOPT 0x0800 /* Not a command line option */
180 #define PLUGIN_VAR_NOCMDARG 0x1000 /* No argument for cmd line */
181 #define PLUGIN_VAR_RQCMDARG 0x0000 /* Argument required for cmd line */
182 #define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */
183 #define PLUGIN_VAR_NODEFAULT 0x4000 /* SET DEFAULT is prohibited */
184 #define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */
185 #define PLUGIN_VAR_NOPERSIST \
186  0x10000 /* SET PERSIST_ONLY is prohibited \
187  for read only variables */
188 
189 /**
190  There can be some variables which needs to be set before plugin is loaded but
191  not after plugin is loaded. ex: GR specific variables. Below flag must be set
192  for these kind of variables.
193 */
194 #define PLUGIN_VAR_PERSIST_AS_READ_ONLY 0x20000
195 #define PLUGIN_VAR_INVISIBLE 0x40000 /* Variable should not be shown */
196 
197 struct SYS_VAR;
198 struct st_mysql_value;
199 
200 /*
201  SYNOPSIS
202  (*mysql_var_check_func)()
203  thd thread handle
204  var dynamic variable being altered
205  save pointer to temporary storage
206  value user provided value
207  RETURN
208  0 user provided value is OK and the update func may be called.
209  any other value indicates error.
210 
211  This function should parse the user provided value and store in the
212  provided temporary storage any data as required by the update func.
213  There is sufficient space in the temporary storage to store a double.
214  Note that the update func may not be called if any other error occurs
215  so any memory allocated should be thread-local so that it may be freed
216  automatically at the end of the statement.
217 */
218 
219 typedef int (*mysql_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save,
220  struct st_mysql_value *value);
221 
222 /*
223  SYNOPSIS
224  (*mysql_var_update_func)()
225  thd thread handle
226  var dynamic variable being altered
227  var_ptr pointer to dynamic variable
228  save pointer to temporary storage
229  RETURN
230  NONE
231 
232  This function should use the validated value stored in the temporary store
233  and persist it in the provided pointer to the dynamic variable.
234  For example, strings may require memory to be allocated.
235 */
236 typedef void (*mysql_var_update_func)(MYSQL_THD thd, SYS_VAR *var,
237  void *var_ptr, const void *save);
238 
239 /* the following declarations are for internal use only */
240 
241 #define PLUGIN_VAR_MASK \
242  (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT | \
243  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | \
244  PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_NODEFAULT | PLUGIN_VAR_NOPERSIST | \
245  PLUGIN_VAR_PERSIST_AS_READ_ONLY | PLUGIN_VAR_INVISIBLE)
246 
247 #define MYSQL_PLUGIN_VAR_HEADER \
248  int flags; \
249  const char *name; \
250  const char *comment; \
251  mysql_var_check_func check; \
252  mysql_var_update_func update
253 
254 #define MYSQL_SYSVAR_NAME(name) mysql_sysvar_##name
255 #define MYSQL_SYSVAR(name) ((SYS_VAR *)&(MYSQL_SYSVAR_NAME(name)))
256 
257 /*
258  for global variables, the value pointer is the first
259  element after the header, the default value is the second.
260  for thread variables, the value offset is the first
261  element after the header, the default value is the second.
262 */
263 
264 #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) \
265  struct { \
266  MYSQL_PLUGIN_VAR_HEADER; \
267  type *value; \
268  const type def_val; \
269  } MYSQL_SYSVAR_NAME(name)
270 
271 #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) \
272  struct { \
273  MYSQL_PLUGIN_VAR_HEADER; \
274  type *value; \
275  type def_val; \
276  type min_val; \
277  type max_val; \
278  type blk_sz; \
279  } MYSQL_SYSVAR_NAME(name)
280 
281 #define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) \
282  struct { \
283  MYSQL_PLUGIN_VAR_HEADER; \
284  type *value; \
285  type def_val; \
286  TYPELIB *typelib; \
287  } MYSQL_SYSVAR_NAME(name)
288 
289 #define DECLARE_THDVAR_FUNC(type) type *(*resolve)(MYSQL_THD thd, int offset)
290 
291 #define DECLARE_MYSQL_THDVAR_BASIC(name, type) \
292  struct { \
293  MYSQL_PLUGIN_VAR_HEADER; \
294  int offset; \
295  const type def_val; \
296  DECLARE_THDVAR_FUNC(type); \
297  } MYSQL_SYSVAR_NAME(name)
298 
299 #define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) \
300  struct { \
301  MYSQL_PLUGIN_VAR_HEADER; \
302  int offset; \
303  type def_val; \
304  type min_val; \
305  type max_val; \
306  type blk_sz; \
307  DECLARE_THDVAR_FUNC(type); \
308  } MYSQL_SYSVAR_NAME(name)
309 
310 #define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) \
311  struct { \
312  MYSQL_PLUGIN_VAR_HEADER; \
313  int offset; \
314  type def_val; \
315  DECLARE_THDVAR_FUNC(type); \
316  TYPELIB *typelib; \
317  } MYSQL_SYSVAR_NAME(name)
318 
319 /*
320  the following declarations are for use by plugin implementors
321 */
322 
323 #define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
324  DECLARE_MYSQL_SYSVAR_BASIC(name, bool) = { \
325  PLUGIN_VAR_BOOL | ((opt)&PLUGIN_VAR_MASK), \
326  #name, \
327  comment, \
328  check, \
329  update, \
330  &varname, \
331  def}
332 
333 #define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
334  DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
335  PLUGIN_VAR_STR | ((opt)&PLUGIN_VAR_MASK), \
336  #name, \
337  comment, \
338  check, \
339  update, \
340  &varname, \
341  def}
342 
343 #define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, \
344  max, blk) \
345  DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
346  PLUGIN_VAR_INT | ((opt)&PLUGIN_VAR_MASK), \
347  #name, \
348  comment, \
349  check, \
350  update, \
351  &varname, \
352  def, \
353  min, \
354  max, \
355  blk}
356 
357 #define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, \
358  min, max, blk) \
359  DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
360  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt)&PLUGIN_VAR_MASK), \
361  #name, \
362  comment, \
363  check, \
364  update, \
365  &varname, \
366  def, \
367  min, \
368  max, \
369  blk}
370 
371 #define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, \
372  min, max, blk) \
373  DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
374  PLUGIN_VAR_LONG | ((opt)&PLUGIN_VAR_MASK), \
375  #name, \
376  comment, \
377  check, \
378  update, \
379  &varname, \
380  def, \
381  min, \
382  max, \
383  blk}
384 
385 #define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, \
386  min, max, blk) \
387  DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
388  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt)&PLUGIN_VAR_MASK), \
389  #name, \
390  comment, \
391  check, \
392  update, \
393  &varname, \
394  def, \
395  min, \
396  max, \
397  blk}
398 
399 #define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, \
400  min, max, blk) \
401  DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \
402  PLUGIN_VAR_LONGLONG | ((opt)&PLUGIN_VAR_MASK), \
403  #name, \
404  comment, \
405  check, \
406  update, \
407  &varname, \
408  def, \
409  min, \
410  max, \
411  blk}
412 
413 #define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, \
414  def, min, max, blk) \
415  DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
416  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt)&PLUGIN_VAR_MASK), \
417  #name, \
418  comment, \
419  check, \
420  update, \
421  &varname, \
422  def, \
423  min, \
424  max, \
425  blk}
426 
427 #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, \
428  typelib) \
429  DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
430  PLUGIN_VAR_ENUM | ((opt)&PLUGIN_VAR_MASK), \
431  #name, \
432  comment, \
433  check, \
434  update, \
435  &varname, \
436  def, \
437  typelib}
438 
439 #define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, \
440  typelib) \
441  DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \
442  PLUGIN_VAR_SET | ((opt)&PLUGIN_VAR_MASK), \
443  #name, \
444  comment, \
445  check, \
446  update, \
447  &varname, \
448  def, \
449  typelib}
450 
451 #define MYSQL_SYSVAR_DOUBLE(name, varname, opt, comment, check, update, def, \
452  min, max, blk) \
453  DECLARE_MYSQL_SYSVAR_SIMPLE(name, double) = { \
454  PLUGIN_VAR_DOUBLE | ((opt)&PLUGIN_VAR_MASK), \
455  #name, \
456  comment, \
457  check, \
458  update, \
459  &varname, \
460  def, \
461  min, \
462  max, \
463  blk}
464 
465 #define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
466  DECLARE_MYSQL_THDVAR_BASIC(name, bool) = { \
467  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
468  #name, \
469  comment, \
470  check, \
471  update, \
472  -1, \
473  def, \
474  NULL}
475 
476 #define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
477  DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
478  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
479  #name, \
480  comment, \
481  check, \
482  update, \
483  -1, \
484  def, \
485  NULL}
486 
487 #define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, \
488  blk) \
489  DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
490  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
491  #name, \
492  comment, \
493  check, \
494  update, \
495  -1, \
496  def, \
497  min, \
498  max, \
499  blk, \
500  NULL}
501 
502 #define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, \
503  blk) \
504  DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
505  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | \
506  ((opt)&PLUGIN_VAR_MASK), \
507  #name, \
508  comment, \
509  check, \
510  update, \
511  -1, \
512  def, \
513  min, \
514  max, \
515  blk, \
516  NULL}
517 
518 #define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, \
519  blk) \
520  DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
521  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
522  #name, \
523  comment, \
524  check, \
525  update, \
526  -1, \
527  def, \
528  min, \
529  max, \
530  blk, \
531  NULL}
532 
533 #define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, \
534  blk) \
535  DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
536  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | \
537  ((opt)&PLUGIN_VAR_MASK), \
538  #name, \
539  comment, \
540  check, \
541  update, \
542  -1, \
543  def, \
544  min, \
545  max, \
546  blk, \
547  NULL}
548 
549 #define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, \
550  max, blk) \
551  DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \
552  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
553  #name, \
554  comment, \
555  check, \
556  update, \
557  -1, \
558  def, \
559  min, \
560  max, \
561  blk, \
562  NULL}
563 
564 #define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, \
565  max, blk) \
566  DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \
567  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | \
568  ((opt)&PLUGIN_VAR_MASK), \
569  #name, \
570  comment, \
571  check, \
572  update, \
573  -1, \
574  def, \
575  min, \
576  max, \
577  blk, \
578  NULL}
579 
580 #define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
581  DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
582  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
583  #name, \
584  comment, \
585  check, \
586  update, \
587  -1, \
588  def, \
589  NULL, \
590  typelib}
591 
592 #define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
593  DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \
594  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
595  #name, \
596  comment, \
597  check, \
598  update, \
599  -1, \
600  def, \
601  NULL, \
602  typelib}
603 
604 #define MYSQL_THDVAR_DOUBLE(name, opt, comment, check, update, def, min, max, \
605  blk) \
606  DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \
607  PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
608  #name, \
609  comment, \
610  check, \
611  update, \
612  -1, \
613  def, \
614  min, \
615  max, \
616  blk, \
617  NULL}
618 
619 /* accessor macros */
620 
621 #define SYSVAR(name) (*(MYSQL_SYSVAR_NAME(name).value))
622 
623 /* when thd == null, result points to global value */
624 #define THDVAR(thd, name) \
625  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
626 
627 #define THDVAR_SET(thd, name, value) \
628  plugin_thdvar_safe_update(thd, MYSQL_SYSVAR(name), \
629  (char **)&THDVAR(thd, name), (const char *)value);
630 
631 /*
632  Plugin description structure.
633 */
634 
636  int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
637  void *info; /* pointer to type-specific plugin descriptor */
638  const char *name; /* plugin name */
639  const char *author; /* plugin author (for I_S.PLUGINS) */
640  const char *descr; /* general descriptive text (for I_S.PLUGINS) */
641  int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
642  /** Function to invoke when plugin is loaded. */
644  /** Function to invoke when plugin is uninstalled. */
646  /** Function to invoke when plugin is unloaded. */
648  unsigned int version; /* plugin version (for I_S.PLUGINS) */
651  void *__reserved1; /* reserved for dependency checking */
652  unsigned long flags; /* flags for plugin */
653 };
654 
655 /*************************************************************************
656  API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
657 */
658 #define MYSQL_FTPARSER_INTERFACE_VERSION 0x0101
659 
660 /*************************************************************************
661  API for Query Rewrite plugin. (MYSQL_QUERY_REWRITE_PLUGIN)
662 */
663 
664 #define MYSQL_REWRITE_PRE_PARSE_INTERFACE_VERSION 0x0010
665 #define MYSQL_REWRITE_POST_PARSE_INTERFACE_VERSION 0x0010
666 
667 /*************************************************************************
668  API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
669 */
670 
671 /* handlertons of different MySQL releases are incompatible */
672 #define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
673 
674 /*
675  Here we define only the descriptor structure, that is referred from
676  st_mysql_plugin.
677 */
678 
681 };
682 
683 /*************************************************************************
684  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
685 */
686 
687 /* handlertons of different MySQL releases are incompatible */
688 #define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
689 
690 /*
691  Here we define only the descriptor structure, that is referred from
692  st_mysql_plugin.
693 */
694 
697 };
698 
699 /*************************************************************************
700  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
701 */
702 
703 /* handlertons of different MySQL releases are incompatible */
704 #define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
705 
706 /*
707  The real API is in the sql/handler.h
708  Here we define only the descriptor structure, that is referred from
709  st_mysql_plugin.
710 */
711 
714 };
715 
716 struct handlerton;
717 
718 /*
719  API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
720 */
721 #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0400
722 
723 /**
724  Replication plugin descriptor
725 */
728 };
729 
730 /*************************************************************************
731  st_mysql_value struct for reading values from mysqld.
732  Used by server variables framework to parse user-provided values.
733  Will be used for arguments when implementing UDFs.
734 
735  Note that val_str() returns a string in temporary memory
736  that will be freed at the end of statement. Copy the string
737  if you need it to persist.
738 */
739 
740 #define MYSQL_VALUE_TYPE_STRING 0
741 #define MYSQL_VALUE_TYPE_REAL 1
742 #define MYSQL_VALUE_TYPE_INT 2
743 
745  int (*value_type)(struct st_mysql_value *);
746  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
747  int (*val_real)(struct st_mysql_value *, double *realbuf);
748  int (*val_int)(struct st_mysql_value *, long long *intbuf);
749  int (*is_unsigned)(struct st_mysql_value *);
750 };
751 
752 /*************************************************************************
753  Miscellaneous functions for plugin implementors
754 */
755 
756 #define thd_proc_info(thd, msg) \
757  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
758 
759 #ifdef __cplusplus
760 extern "C" {
761 #endif
762 
763 int thd_in_lock_tables(const MYSQL_THD thd);
764 int thd_tablespace_op(const MYSQL_THD thd);
765 long long thd_test_options(const MYSQL_THD thd, long long test_options);
766 int thd_sql_command(const MYSQL_THD thd);
767 const char *set_thd_proc_info(MYSQL_THD thd, const char *info,
768  const char *calling_func,
769  const char *calling_file,
770  const unsigned int calling_line);
771 void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
772 void thd_storage_lock_wait(MYSQL_THD thd, long long value);
773 int thd_tx_isolation(const MYSQL_THD thd);
774 int thd_tx_is_read_only(const MYSQL_THD thd);
775 MYSQL_THD thd_tx_arbitrate(MYSQL_THD requestor, MYSQL_THD holder);
776 int thd_tx_priority(const MYSQL_THD thd);
777 int thd_tx_is_dd_trx(const MYSQL_THD thd);
778 char *thd_security_context(MYSQL_THD thd, char *buffer, size_t length,
779  size_t max_query_len);
780 /* Increments the row counter, see THD::row_count */
781 void thd_inc_row_count(MYSQL_THD thd);
782 int thd_allow_batch(MYSQL_THD thd);
783 
784 /**
785  Mark transaction to rollback and mark error as fatal to a
786  sub-statement if in sub statement mode.
787 
788  @param thd user thread connection handle
789  @param all if all != 0, rollback the main transaction
790 */
791 
793 
794 /**
795  Create a temporary file.
796 
797  @details
798  The temporary file is created in a location specified by the mysql
799  server configuration (--tmpdir option). The caller does not need to
800  delete the file, it will be deleted automatically.
801 
802  @param prefix prefix for temporary file name
803  @retval -1 error
804  @retval >= 0 a file handle that can be passed to dup or my_close
805 */
806 int mysql_tmpfile(const char *prefix);
807 
808 /**
809  Check the killed state of a connection
810 
811  @details
812  In MySQL support for the KILL statement is cooperative. The KILL
813  statement only sets a "killed" flag. This function returns the value
814  of that flag. A thread should check it often, especially inside
815  time-consuming loops, and gracefully abort the operation if it is
816  non-zero.
817 
818  @param v_thd user thread connection handle
819  @retval 0 the connection is active
820  @retval 1 the connection has been killed
821 */
822 int thd_killed(const void *v_thd);
823 
824 /**
825  Set the killed status of the current statement.
826 
827  @param thd user thread connection handle
828 */
829 void thd_set_kill_status(const MYSQL_THD thd);
830 
831 /**
832  Get binary log position for latest written entry.
833 
834  @note The file variable will be set to a buffer holding the name of
835  the file name currently, but this can change if a rotation
836  occur. Copy the string if you want to retain it.
837 
838  @param thd Use thread connection handle
839  @param file_var Pointer to variable that will hold the file name.
840  @param pos_var Pointer to variable that will hold the file position.
841  */
842 void thd_binlog_pos(const MYSQL_THD thd, const char **file_var,
843  unsigned long long *pos_var);
844 
845 /**
846  Return the thread id of a user thread
847 
848  @param thd user thread connection handle
849  @return thread id
850 */
851 unsigned long thd_get_thread_id(const MYSQL_THD thd);
852 
853 /**
854  Get the XID for this connection's transaction
855 
856  @param thd user thread connection handle
857  @param xid location where identifier is stored
858 */
859 void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
860 
861 /**
862  Provide a handler data getter to simplify coding
863 */
864 void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
865 
866 /**
867  Provide a handler data setter to simplify coding
868 
869  @details
870  Set ha_data pointer (storage engine per-connection information).
871 
872  To avoid unclean deactivation (uninstall) of storage engine plugin
873  in the middle of transaction, additional storage engine plugin
874  lock is acquired.
875 
876  If ha_data is not null and storage engine plugin was not locked
877  by thd_set_ha_data() in this connection before, storage engine
878  plugin gets locked.
879 
880  If ha_data is null and storage engine plugin was locked by
881  thd_set_ha_data() in this connection before, storage engine
882  plugin lock gets released.
883 
884  If handlerton::close_connection() didn't reset ha_data, server does
885  it immediately after calling handlerton::close_connection().
886 */
887 void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
888  const void *ha_data);
889 
890 /**
891  Interface to remove the per thread openssl error queue.
892  This function is a no-op when openssl is not used.
893 */
894 
896 #ifdef __cplusplus
897 }
898 #endif
899 
900 #endif /* _my_plugin_h */
int license
Definition: plugin.h:641
MYSQL_XID is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991.
Definition: plugin.h:88
int thd_sql_command(const MYSQL_THD thd)
Definition: sql_thd_api.cc:383
int(* mysql_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save, struct st_mysql_value *value)
Definition: plugin.h:219
int interface_version
Definition: plugin.h:713
int type
Definition: plugin.h:636
void thd_binlog_pos(const MYSQL_THD thd, const char **file_var, unsigned long long *pos_var)
Get binary log position for latest written entry.
Definition: sql_thd_api.cc:296
long long thd_test_options(const MYSQL_THD thd, long long test_options)
Definition: sql_thd_api.cc:379
void thd_mark_transaction_to_rollback(MYSQL_THD thd, int all)
Mark transaction to rollback and mark error as fatal to a sub-statement if in sub statement mode...
Definition: sql_thd_api.cc:544
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
Definition: sql_plugin_var.h:183
char data[MYSQL_XIDDATASIZE]
Definition: plugin.h:92
SHOW_VAR * status_vars
Definition: plugin.h:649
int thd_tx_is_read_only(const MYSQL_THD thd)
Definition: sql_thd_api.cc:387
unsigned int version
Definition: plugin.h:648
void remove_ssl_err_thread_state()
Interface to remove the per thread openssl error queue.
Definition: sql_thd_api.cc:657
int(* check_uninstall)(MYSQL_PLUGIN)
Function to invoke when plugin is uninstalled.
Definition: plugin.h:645
int(* value_type)(struct st_mysql_value *)
Definition: plugin.h:745
int thd_killed(const void *v_thd)
Check the killed state of a connection.
Definition: sql_thd_api.cc:505
Definition: plugin.h:635
void * __reserved1
Definition: plugin.h:651
int(* val_int)(struct st_mysql_value *, long long *intbuf)
Definition: plugin.h:748
int interface_version
Definition: plugin.h:727
void thd_inc_row_count(MYSQL_THD thd)
Definition: sql_thd_api.cc:408
int thd_in_lock_tables(const MYSQL_THD thd)
Definition: sql_thd_api.cc:305
char * thd_security_context(MYSQL_THD thd, char *buffer, size_t length, size_t max_query_len)
Dumps a text description of a thread, its security context (user, host) and the current query...
Definition: sql_thd_api.cc:424
Definition: plugin.h:712
long gtrid_length
Definition: plugin.h:90
void ** thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton)
Definition: sql_thd_api.cc:348
int(* deinit)(MYSQL_PLUGIN)
Function to invoke when plugin is unloaded.
Definition: plugin.h:647
Definition: plugin.h:744
void * thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton)
Provide a handler data getter to simplify coding.
Definition: sql_thd_api.cc:359
void(* mysql_var_update_func)(MYSQL_THD thd, SYS_VAR *var, void *var_ptr, const void *save)
Definition: plugin.h:236
void * info
Definition: plugin.h:637
SHOW STATUS Server status variable.
Definition: status_var.h:78
const char * descr
Definition: plugin.h:640
void * MYSQL_PLUGIN
Definition: plugin.h:73
int(* is_unsigned)(struct st_mysql_value *)
Definition: plugin.h:749
#define MYSQL_XIDDATASIZE
Definition: plugin.h:79
MYSQL_THD thd_tx_arbitrate(MYSQL_THD requestor, MYSQL_THD holder)
Definition: sql_thd_api.cc:393
#define MYSQL_THD
Definition: plugin.h:68
int thd_tx_isolation(const MYSQL_THD thd)
Definition: sql_thd_api.cc:385
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid)
Get the XID for this connection&#39;s transaction.
Definition: sql_thd_api.cc:494
Definition: item.h:666
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2219
int thd_allow_batch(MYSQL_THD thd)
Check if batching is allowed for the thread.
Definition: sql_thd_api.cc:537
void thd_storage_lock_wait(MYSQL_THD thd, long long value)
Definition: sql_thd_api.cc:352
const char * author
Definition: plugin.h:639
SYS_VAR ** system_vars
Definition: plugin.h:650
unsigned long thd_get_thread_id(const MYSQL_THD thd)
Return the thread id of a user thread.
Definition: sql_thd_api.cc:526
long bqual_length
Definition: plugin.h:91
void thd_set_kill_status(const MYSQL_THD thd)
Set the killed status of the current statement.
Definition: sql_thd_api.cc:518
Replication plugin descriptor.
Definition: plugin.h:726
int(* init)(MYSQL_PLUGIN)
Function to invoke when plugin is loaded.
Definition: plugin.h:643
long formatID
Definition: plugin.h:89
int thd_tx_is_dd_trx(const MYSQL_THD thd)
Definition: sql_thd_api.cc:404
unsigned long flags
Definition: plugin.h:652
int thd_tablespace_op(const MYSQL_THD thd)
Definition: sql_thd_api.cc:307
const char * name
Definition: plugin.h:638
const string value("\alue\)
Log info(cout, "NOTE")
void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton, const void *ha_data)
Provide a handler data setter to simplify coding.
Definition: sql_thd_api.cc:367
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)
Definition: sql_thd_api.cc:332
int mysql_tmpfile(const char *prefix)
Create a temporary file.
Definition: sql_thd_api.cc:301
Definition: plugin.h:679
int(* val_real)(struct st_mysql_value *, double *realbuf)
Definition: plugin.h:747
int interface_version
Definition: plugin.h:680
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
int thd_tx_priority(const MYSQL_THD thd)
Definition: sql_thd_api.cc:389
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:776
int interface_version
Definition: plugin.h:696
Definition: plugin.h:695