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