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