MySQL  8.0.18
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 0x010A
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 #define PLUGIN_OPT_ALLOW_EARLY 4UL /* allow --early-plugin-load */
163 
164 /*
165  declarations for server variables and command line options
166 */
167 
168 #define PLUGIN_VAR_BOOL 0x0001
169 #define PLUGIN_VAR_INT 0x0002
170 #define PLUGIN_VAR_LONG 0x0003
171 #define PLUGIN_VAR_LONGLONG 0x0004
172 #define PLUGIN_VAR_STR 0x0005
173 #define PLUGIN_VAR_ENUM 0x0006
174 #define PLUGIN_VAR_SET 0x0007
175 #define PLUGIN_VAR_DOUBLE 0x0008
176 #define PLUGIN_VAR_UNSIGNED 0x0080
177 #define PLUGIN_VAR_THDLOCAL 0x0100 /* Variable is per-connection */
178 #define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
179 #define PLUGIN_VAR_NOSYSVAR 0x0400 /* Configurable only by cmd-line */
180 #define PLUGIN_VAR_NOCMDOPT 0x0800 /* Not a command line option */
181 #define PLUGIN_VAR_NOCMDARG 0x1000 /* No argument for cmd line */
182 #define PLUGIN_VAR_RQCMDARG 0x0000 /* Argument required for cmd line */
183 #define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */
184 #define PLUGIN_VAR_NODEFAULT 0x4000 /* SET DEFAULT is prohibited */
185 #define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */
186 #define PLUGIN_VAR_NOPERSIST \
187  0x10000 /* SET PERSIST_ONLY is prohibited \
188  for read only variables */
189 
190 /**
191  There can be some variables which needs to be set before plugin is loaded but
192  not after plugin is loaded. ex: GR specific variables. Below flag must be set
193  for these kind of variables.
194 */
195 #define PLUGIN_VAR_PERSIST_AS_READ_ONLY 0x20000
196 #define PLUGIN_VAR_INVISIBLE 0x40000 /* Variable should not be shown */
197 
198 struct SYS_VAR;
199 struct st_mysql_value;
200 
201 /*
202  SYNOPSIS
203  (*mysql_var_check_func)()
204  thd thread handle
205  var dynamic variable being altered
206  save pointer to temporary storage
207  value user provided value
208  RETURN
209  0 user provided value is OK and the update func may be called.
210  any other value indicates error.
211 
212  This function should parse the user provided value and store in the
213  provided temporary storage any data as required by the update func.
214  There is sufficient space in the temporary storage to store a double.
215  Note that the update func may not be called if any other error occurs
216  so any memory allocated should be thread-local so that it may be freed
217  automatically at the end of the statement.
218 */
219 
220 typedef int (*mysql_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save,
221  struct st_mysql_value *value);
222 
223 /*
224  SYNOPSIS
225  (*mysql_var_update_func)()
226  thd thread handle
227  var dynamic variable being altered
228  var_ptr pointer to dynamic variable
229  save pointer to temporary storage
230  RETURN
231  NONE
232 
233  This function should use the validated value stored in the temporary store
234  and persist it in the provided pointer to the dynamic variable.
235  For example, strings may require memory to be allocated.
236 */
237 typedef void (*mysql_var_update_func)(MYSQL_THD thd, SYS_VAR *var,
238  void *var_ptr, const void *save);
239 
240 /* the following declarations are for internal use only */
241 
242 #define PLUGIN_VAR_MASK \
243  (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT | \
244  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | \
245  PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_NODEFAULT | PLUGIN_VAR_NOPERSIST | \
246  PLUGIN_VAR_PERSIST_AS_READ_ONLY | PLUGIN_VAR_INVISIBLE)
247 
248 #define MYSQL_PLUGIN_VAR_HEADER \
249  int flags; \
250  const char *name; \
251  const char *comment; \
252  mysql_var_check_func check; \
253  mysql_var_update_func update
254 
255 #define MYSQL_SYSVAR_NAME(name) mysql_sysvar_##name
256 #define MYSQL_SYSVAR(name) ((SYS_VAR *)&(MYSQL_SYSVAR_NAME(name)))
257 
258 /*
259  for global variables, the value pointer is the first
260  element after the header, the default value is the second.
261  for thread variables, the value offset is the first
262  element after the header, the default value is the second.
263 */
264 
265 #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) \
266  struct { \
267  MYSQL_PLUGIN_VAR_HEADER; \
268  type *value; \
269  const type def_val; \
270  } MYSQL_SYSVAR_NAME(name)
271 
272 #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) \
273  struct { \
274  MYSQL_PLUGIN_VAR_HEADER; \
275  type *value; \
276  type def_val; \
277  type min_val; \
278  type max_val; \
279  type blk_sz; \
280  } MYSQL_SYSVAR_NAME(name)
281 
282 #define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) \
283  struct { \
284  MYSQL_PLUGIN_VAR_HEADER; \
285  type *value; \
286  type def_val; \
287  TYPELIB *typelib; \
288  } MYSQL_SYSVAR_NAME(name)
289 
290 #define DECLARE_THDVAR_FUNC(type) type *(*resolve)(MYSQL_THD thd, int offset)
291 
292 #define DECLARE_MYSQL_THDVAR_BASIC(name, type) \
293  struct { \
294  MYSQL_PLUGIN_VAR_HEADER; \
295  int offset; \
296  const type def_val; \
297  DECLARE_THDVAR_FUNC(type); \
298  } MYSQL_SYSVAR_NAME(name)
299 
300 #define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) \
301  struct { \
302  MYSQL_PLUGIN_VAR_HEADER; \
303  int offset; \
304  type def_val; \
305  type min_val; \
306  type max_val; \
307  type blk_sz; \
308  DECLARE_THDVAR_FUNC(type); \
309  } MYSQL_SYSVAR_NAME(name)
310 
311 #define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) \
312  struct { \
313  MYSQL_PLUGIN_VAR_HEADER; \
314  int offset; \
315  type def_val; \
316  DECLARE_THDVAR_FUNC(type); \
317  TYPELIB *typelib; \
318  } MYSQL_SYSVAR_NAME(name)
319 
320 /*
321  the following declarations are for use by plugin implementors
322 */
323 
324 #define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
325  DECLARE_MYSQL_SYSVAR_BASIC(name, bool) = { \
326  PLUGIN_VAR_BOOL | ((opt)&PLUGIN_VAR_MASK), \
327  #name, \
328  comment, \
329  check, \
330  update, \
331  &varname, \
332  def}
333 
334 #define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
335  DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
336  PLUGIN_VAR_STR | ((opt)&PLUGIN_VAR_MASK), \
337  #name, \
338  comment, \
339  check, \
340  update, \
341  &varname, \
342  def}
343 
344 #define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, \
345  max, blk) \
346  DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
347  PLUGIN_VAR_INT | ((opt)&PLUGIN_VAR_MASK), \
348  #name, \
349  comment, \
350  check, \
351  update, \
352  &varname, \
353  def, \
354  min, \
355  max, \
356  blk}
357 
358 #define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, \
359  min, max, blk) \
360  DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
361  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt)&PLUGIN_VAR_MASK), \
362  #name, \
363  comment, \
364  check, \
365  update, \
366  &varname, \
367  def, \
368  min, \
369  max, \
370  blk}
371 
372 #define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, \
373  min, max, blk) \
374  DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
375  PLUGIN_VAR_LONG | ((opt)&PLUGIN_VAR_MASK), \
376  #name, \
377  comment, \
378  check, \
379  update, \
380  &varname, \
381  def, \
382  min, \
383  max, \
384  blk}
385 
386 #define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, \
387  min, max, blk) \
388  DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
389  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt)&PLUGIN_VAR_MASK), \
390  #name, \
391  comment, \
392  check, \
393  update, \
394  &varname, \
395  def, \
396  min, \
397  max, \
398  blk}
399 
400 #define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, \
401  min, max, blk) \
402  DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \
403  PLUGIN_VAR_LONGLONG | ((opt)&PLUGIN_VAR_MASK), \
404  #name, \
405  comment, \
406  check, \
407  update, \
408  &varname, \
409  def, \
410  min, \
411  max, \
412  blk}
413 
414 #define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, \
415  def, min, max, blk) \
416  DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
417  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt)&PLUGIN_VAR_MASK), \
418  #name, \
419  comment, \
420  check, \
421  update, \
422  &varname, \
423  def, \
424  min, \
425  max, \
426  blk}
427 
428 #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, \
429  typelib) \
430  DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
431  PLUGIN_VAR_ENUM | ((opt)&PLUGIN_VAR_MASK), \
432  #name, \
433  comment, \
434  check, \
435  update, \
436  &varname, \
437  def, \
438  typelib}
439 
440 #define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, \
441  typelib) \
442  DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \
443  PLUGIN_VAR_SET | ((opt)&PLUGIN_VAR_MASK), \
444  #name, \
445  comment, \
446  check, \
447  update, \
448  &varname, \
449  def, \
450  typelib}
451 
452 #define MYSQL_SYSVAR_DOUBLE(name, varname, opt, comment, check, update, def, \
453  min, max, blk) \
454  DECLARE_MYSQL_SYSVAR_SIMPLE(name, double) = { \
455  PLUGIN_VAR_DOUBLE | ((opt)&PLUGIN_VAR_MASK), \
456  #name, \
457  comment, \
458  check, \
459  update, \
460  &varname, \
461  def, \
462  min, \
463  max, \
464  blk}
465 
466 #define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
467  DECLARE_MYSQL_THDVAR_BASIC(name, bool) = { \
468  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
469  #name, \
470  comment, \
471  check, \
472  update, \
473  -1, \
474  def, \
475  NULL}
476 
477 #define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
478  DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
479  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
480  #name, \
481  comment, \
482  check, \
483  update, \
484  -1, \
485  def, \
486  NULL}
487 
488 #define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, \
489  blk) \
490  DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
491  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
492  #name, \
493  comment, \
494  check, \
495  update, \
496  -1, \
497  def, \
498  min, \
499  max, \
500  blk, \
501  NULL}
502 
503 #define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, \
504  blk) \
505  DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
506  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | \
507  ((opt)&PLUGIN_VAR_MASK), \
508  #name, \
509  comment, \
510  check, \
511  update, \
512  -1, \
513  def, \
514  min, \
515  max, \
516  blk, \
517  NULL}
518 
519 #define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, \
520  blk) \
521  DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
522  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
523  #name, \
524  comment, \
525  check, \
526  update, \
527  -1, \
528  def, \
529  min, \
530  max, \
531  blk, \
532  NULL}
533 
534 #define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, \
535  blk) \
536  DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
537  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | \
538  ((opt)&PLUGIN_VAR_MASK), \
539  #name, \
540  comment, \
541  check, \
542  update, \
543  -1, \
544  def, \
545  min, \
546  max, \
547  blk, \
548  NULL}
549 
550 #define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, \
551  max, blk) \
552  DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \
553  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
554  #name, \
555  comment, \
556  check, \
557  update, \
558  -1, \
559  def, \
560  min, \
561  max, \
562  blk, \
563  NULL}
564 
565 #define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, \
566  max, blk) \
567  DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \
568  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | \
569  ((opt)&PLUGIN_VAR_MASK), \
570  #name, \
571  comment, \
572  check, \
573  update, \
574  -1, \
575  def, \
576  min, \
577  max, \
578  blk, \
579  NULL}
580 
581 #define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
582  DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
583  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
584  #name, \
585  comment, \
586  check, \
587  update, \
588  -1, \
589  def, \
590  NULL, \
591  typelib}
592 
593 #define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
594  DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \
595  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
596  #name, \
597  comment, \
598  check, \
599  update, \
600  -1, \
601  def, \
602  NULL, \
603  typelib}
604 
605 #define MYSQL_THDVAR_DOUBLE(name, opt, comment, check, update, def, min, max, \
606  blk) \
607  DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \
608  PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt)&PLUGIN_VAR_MASK), \
609  #name, \
610  comment, \
611  check, \
612  update, \
613  -1, \
614  def, \
615  min, \
616  max, \
617  blk, \
618  NULL}
619 
620 /* accessor macros */
621 
622 #define SYSVAR(name) (*(MYSQL_SYSVAR_NAME(name).value))
623 
624 /* when thd == null, result points to global value */
625 #define THDVAR(thd, name) \
626  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
627 
628 #define THDVAR_SET(thd, name, value) \
629  plugin_thdvar_safe_update(thd, MYSQL_SYSVAR(name), \
630  (char **)&THDVAR(thd, name), (const char *)value);
631 
632 /*
633  Plugin description structure.
634 */
635 
637  int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
638  void *info; /* pointer to type-specific plugin descriptor */
639  const char *name; /* plugin name */
640  const char *author; /* plugin author (for I_S.PLUGINS) */
641  const char *descr; /* general descriptive text (for I_S.PLUGINS) */
642  int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
643  /** Function to invoke when plugin is loaded. */
645  /** Function to invoke when plugin is uninstalled. */
647  /** Function to invoke when plugin is unloaded. */
649  unsigned int version; /* plugin version (for I_S.PLUGINS) */
652  void *__reserved1; /* reserved for dependency checking */
653  unsigned long flags; /* flags for plugin */
654 };
655 
656 /*************************************************************************
657  API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
658 */
659 #define MYSQL_FTPARSER_INTERFACE_VERSION 0x0101
660 
661 /*************************************************************************
662  API for Query Rewrite plugin. (MYSQL_QUERY_REWRITE_PLUGIN)
663 */
664 
665 #define MYSQL_REWRITE_PRE_PARSE_INTERFACE_VERSION 0x0010
666 #define MYSQL_REWRITE_POST_PARSE_INTERFACE_VERSION 0x0010
667 
668 /*************************************************************************
669  API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
670 */
671 
672 /* handlertons of different MySQL releases are incompatible */
673 #define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
674 
675 /*
676  Here we define only the descriptor structure, that is referred from
677  st_mysql_plugin.
678 */
679 
682 };
683 
684 /*************************************************************************
685  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
686 */
687 
688 /* handlertons of different MySQL releases are incompatible */
689 #define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
690 
691 /*
692  Here we define only the descriptor structure, that is referred from
693  st_mysql_plugin.
694 */
695 
698 };
699 
700 /*************************************************************************
701  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
702 */
703 
704 /* handlertons of different MySQL releases are incompatible */
705 #define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
706 
707 /*
708  The real API is in the sql/handler.h
709  Here we define only the descriptor structure, that is referred from
710  st_mysql_plugin.
711 */
712 
715 };
716 
717 struct handlerton;
718 
719 /*
720  API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
721 */
722 #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0400
723 
724 /**
725  Replication plugin descriptor
726 */
729 };
730 
731 /*************************************************************************
732  st_mysql_value struct for reading values from mysqld.
733  Used by server variables framework to parse user-provided values.
734  Will be used for arguments when implementing UDFs.
735 
736  Note that val_str() returns a string in temporary memory
737  that will be freed at the end of statement. Copy the string
738  if you need it to persist.
739 */
740 
741 #define MYSQL_VALUE_TYPE_STRING 0
742 #define MYSQL_VALUE_TYPE_REAL 1
743 #define MYSQL_VALUE_TYPE_INT 2
744 
746  int (*value_type)(struct st_mysql_value *);
747  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
748  int (*val_real)(struct st_mysql_value *, double *realbuf);
749  int (*val_int)(struct st_mysql_value *, long long *intbuf);
750  int (*is_unsigned)(struct st_mysql_value *);
751 };
752 
753 /*************************************************************************
754  Miscellaneous functions for plugin implementors
755 */
756 
757 #define thd_proc_info(thd, msg) \
758  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
759 
760 #ifdef __cplusplus
761 extern "C" {
762 #endif
763 
764 int thd_in_lock_tables(const MYSQL_THD thd);
765 int thd_tablespace_op(const MYSQL_THD thd);
766 long long thd_test_options(const MYSQL_THD thd, long long test_options);
767 int thd_sql_command(const MYSQL_THD thd);
768 const char *set_thd_proc_info(MYSQL_THD thd, const char *info,
769  const char *calling_func,
770  const char *calling_file,
771  const unsigned int calling_line);
772 void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
773 void thd_storage_lock_wait(MYSQL_THD thd, long long value);
774 int thd_tx_isolation(const MYSQL_THD thd);
775 int thd_tx_is_read_only(const MYSQL_THD thd);
776 MYSQL_THD thd_tx_arbitrate(MYSQL_THD requestor, MYSQL_THD holder);
777 int thd_tx_priority(const MYSQL_THD thd);
778 int thd_tx_is_dd_trx(const MYSQL_THD thd);
779 char *thd_security_context(MYSQL_THD thd, char *buffer, size_t length,
780  size_t max_query_len);
781 /* Increments the row counter, see THD::row_count */
782 void thd_inc_row_count(MYSQL_THD thd);
783 int thd_allow_batch(MYSQL_THD thd);
784 
785 /**
786  Mark transaction to rollback and mark error as fatal to a
787  sub-statement if in sub statement mode.
788 
789  @param thd user thread connection handle
790  @param all if all != 0, rollback the main transaction
791 */
792 
794 
795 /**
796  Create a temporary file.
797 
798  @details
799  The temporary file is created in a location specified by the mysql
800  server configuration (--tmpdir option). The caller does not need to
801  delete the file, it will be deleted automatically.
802 
803  @param prefix prefix for temporary file name
804  @retval -1 error
805  @retval >= 0 a file handle that can be passed to dup or my_close
806 */
807 int mysql_tmpfile(const char *prefix);
808 
809 /**
810  Check the killed state of a connection
811 
812  @details
813  In MySQL support for the KILL statement is cooperative. The KILL
814  statement only sets a "killed" flag. This function returns the value
815  of that flag. A thread should check it often, especially inside
816  time-consuming loops, and gracefully abort the operation if it is
817  non-zero.
818 
819  @param v_thd user thread connection handle
820  @retval 0 the connection is active
821  @retval 1 the connection has been killed
822 */
823 int thd_killed(const void *v_thd);
824 
825 /**
826  Set the killed status of the current statement.
827 
828  @param thd user thread connection handle
829 */
830 void thd_set_kill_status(const MYSQL_THD thd);
831 
832 /**
833  Get binary log position for latest written entry.
834 
835  @note The file variable will be set to a buffer holding the name of
836  the file name currently, but this can change if a rotation
837  occur. Copy the string if you want to retain it.
838 
839  @param thd Use thread connection handle
840  @param file_var Pointer to variable that will hold the file name.
841  @param pos_var Pointer to variable that will hold the file position.
842  */
843 void thd_binlog_pos(const MYSQL_THD thd, const char **file_var,
844  unsigned long long *pos_var);
845 
846 /**
847  Return the thread id of a user thread
848 
849  @param thd user thread connection handle
850  @return thread id
851 */
852 unsigned long thd_get_thread_id(const MYSQL_THD thd);
853 
854 /**
855  Get the XID for this connection's transaction
856 
857  @param thd user thread connection handle
858  @param xid location where identifier is stored
859 */
860 void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
861 
862 /**
863  Provide a handler data getter to simplify coding
864 */
865 void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
866 
867 /**
868  Provide a handler data setter to simplify coding
869 
870  @details
871  Set ha_data pointer (storage engine per-connection information).
872 
873  To avoid unclean deactivation (uninstall) of storage engine plugin
874  in the middle of transaction, additional storage engine plugin
875  lock is acquired.
876 
877  If ha_data is not null and storage engine plugin was not locked
878  by thd_set_ha_data() in this connection before, storage engine
879  plugin gets locked.
880 
881  If ha_data is null and storage engine plugin was locked by
882  thd_set_ha_data() in this connection before, storage engine
883  plugin lock gets released.
884 
885  If handlerton::close_connection() didn't reset ha_data, server does
886  it immediately after calling handlerton::close_connection().
887 */
888 void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
889  const void *ha_data);
890 
891 /**
892  Interface to remove the per thread openssl error queue.
893  This function is a no-op when openssl is not used.
894 */
895 
897 #ifdef __cplusplus
898 }
899 #endif
900 
901 #endif /* _my_plugin_h */
int license
Definition: plugin.h:642
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:220
int interface_version
Definition: plugin.h:714
int type
Definition: plugin.h:637
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:545
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
Definition: plugin.h:62
char data[MYSQL_XIDDATASIZE]
Definition: plugin.h:92
SHOW_VAR * status_vars
Definition: plugin.h:650
int thd_tx_is_read_only(const MYSQL_THD thd)
Definition: sql_thd_api.cc:387
unsigned int version
Definition: plugin.h:649
void remove_ssl_err_thread_state()
Interface to remove the per thread openssl error queue.
Definition: sql_thd_api.cc:655
int(* check_uninstall)(MYSQL_PLUGIN)
Function to invoke when plugin is uninstalled.
Definition: plugin.h:646
int(* value_type)(struct st_mysql_value *)
Definition: plugin.h:746
int thd_killed(const void *v_thd)
Check the killed state of a connection.
Definition: sql_thd_api.cc:506
Definition: plugin.h:636
void * __reserved1
Definition: plugin.h:652
int(* val_int)(struct st_mysql_value *, long long *intbuf)
Definition: plugin.h:749
int interface_version
Definition: plugin.h:728
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:713
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:648
Definition: plugin.h:745
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:237
void * info
Definition: plugin.h:638
SHOW STATUS Server status variable.
Definition: status_var.h:78
const char * descr
Definition: plugin.h:641
void * MYSQL_PLUGIN
Definition: plugin.h:73
int(* is_unsigned)(struct st_mysql_value *)
Definition: plugin.h:750
#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:668
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2272
int thd_allow_batch(MYSQL_THD thd)
Check if batching is allowed for the thread.
Definition: sql_thd_api.cc:538
void thd_storage_lock_wait(MYSQL_THD thd, long long value)
Definition: sql_thd_api.cc:352
const char * author
Definition: plugin.h:640
SYS_VAR ** system_vars
Definition: plugin.h:651
unsigned long thd_get_thread_id(const MYSQL_THD thd)
Return the thread id of a user thread.
Definition: sql_thd_api.cc:527
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:519
Replication plugin descriptor.
Definition: plugin.h:727
int(* init)(MYSQL_PLUGIN)
Function to invoke when plugin is loaded.
Definition: plugin.h:644
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:653
int thd_tablespace_op(const MYSQL_THD thd)
Definition: sql_thd_api.cc:307
const char * name
Definition: plugin.h:639
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:680
int(* val_real)(struct st_mysql_value *, double *realbuf)
Definition: plugin.h:748
int interface_version
Definition: plugin.h:681
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:778
int interface_version
Definition: plugin.h:697
Definition: plugin.h:696