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