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