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