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