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