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