/src/server/include/mysql/plugin.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (c) 2005, 2013, Oracle and/or its affiliates |
2 | | Copyright (C) 2009, 2017, MariaDB |
3 | | |
4 | | This program is free software; you can redistribute it and/or modify |
5 | | it under the terms of the GNU General Public License as published by |
6 | | the Free Software Foundation; version 2 of the License. |
7 | | |
8 | | This program is distributed in the hope that it will be useful, |
9 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | | GNU General Public License for more details. |
12 | | |
13 | | You should have received a copy of the GNU General Public License |
14 | | along with this program; if not, write to the Free Software |
15 | | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ |
16 | | |
17 | | /** |
18 | | @file |
19 | | |
20 | | Interfaces for creating server and client plugins. |
21 | | */ |
22 | | |
23 | | #ifndef MYSQL_PLUGIN_INCLUDED |
24 | | #define MYSQL_PLUGIN_INCLUDED |
25 | | |
26 | | /* |
27 | | On Windows, exports from DLL need to be declared |
28 | | Also, plugin needs to be declared as extern "C" because MSVC |
29 | | unlike other compilers, uses C++ mangling for variables not only |
30 | | for functions. |
31 | | */ |
32 | | #ifdef MYSQL_DYNAMIC_PLUGIN |
33 | | #ifdef _MSC_VER |
34 | | #define MYSQL_DLLEXPORT _declspec(dllexport) |
35 | | #else |
36 | | #define MYSQL_DLLEXPORT |
37 | | #endif |
38 | | #else |
39 | | #define MYSQL_DLLEXPORT |
40 | | #endif |
41 | | |
42 | | #ifdef __cplusplus |
43 | | #define MYSQL_PLUGIN_EXPORT extern "C" MYSQL_DLLEXPORT |
44 | | #else |
45 | | #define MYSQL_PLUGIN_EXPORT MYSQL_DLLEXPORT |
46 | | #endif |
47 | | |
48 | | #ifdef __cplusplus |
49 | | class THD; |
50 | | class Item; |
51 | | #define MYSQL_THD THD* |
52 | | #else |
53 | | struct THD; |
54 | | typedef struct THD* MYSQL_THD; |
55 | | #endif |
56 | | |
57 | | typedef char my_bool; |
58 | | typedef void * MYSQL_PLUGIN; |
59 | | |
60 | | #include <mysql/services.h> |
61 | | |
62 | | #define MYSQL_XIDDATASIZE 128 |
63 | | /** |
64 | | struct st_mysql_xid is binary compatible with the XID structure as |
65 | | in the X/Open CAE Specification, Distributed Transaction Processing: |
66 | | The XA Specification, X/Open Company Ltd., 1991. |
67 | | http://www.opengroup.org/bookstore/catalog/c193.htm |
68 | | |
69 | | @see XID in sql/handler.h |
70 | | */ |
71 | | struct st_mysql_xid { |
72 | | long formatID; |
73 | | long gtrid_length; |
74 | | long bqual_length; |
75 | | char data[MYSQL_XIDDATASIZE]; /* Not \0-terminated */ |
76 | | }; |
77 | | typedef struct st_mysql_xid MYSQL_XID; |
78 | | |
79 | | /************************************************************************* |
80 | | Plugin API. Common for all plugin types. |
81 | | */ |
82 | | |
83 | | /** MySQL plugin interface version */ |
84 | | #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104 |
85 | | |
86 | | /** MariaDB plugin interface version */ |
87 | | #define MARIA_PLUGIN_INTERFACE_VERSION 0x010f |
88 | | |
89 | | /* |
90 | | The allowable types of plugins |
91 | | */ |
92 | | #define MYSQL_UDF_PLUGIN 0 /**< not implemented */ |
93 | | #define MYSQL_STORAGE_ENGINE_PLUGIN 1 |
94 | | #define MYSQL_FTPARSER_PLUGIN 2 /**< Full-text parser plugin */ |
95 | | #define MYSQL_DAEMON_PLUGIN 3 |
96 | | #define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 |
97 | | #define MYSQL_AUDIT_PLUGIN 5 |
98 | | #define MYSQL_REPLICATION_PLUGIN 6 |
99 | | #define MYSQL_AUTHENTICATION_PLUGIN 7 |
100 | | #define MYSQL_MAX_PLUGIN_TYPE_NUM 12 /**< The number of plugin types */ |
101 | | |
102 | | /* MariaDB plugin types */ |
103 | | /** Client and server password validation */ |
104 | | #define MariaDB_PASSWORD_VALIDATION_PLUGIN 8 |
105 | | /**< Encryption and key management plugins */ |
106 | | #define MariaDB_ENCRYPTION_PLUGIN 9 |
107 | | /**< Plugins for SQL data storage types */ |
108 | | #define MariaDB_DATA_TYPE_PLUGIN 10 |
109 | | /**< Plugins for new native SQL functions */ |
110 | | #define MariaDB_FUNCTION_PLUGIN 11 |
111 | | |
112 | | /* We use the following strings to define licenses for plugins */ |
113 | | #define PLUGIN_LICENSE_PROPRIETARY 0 |
114 | | #define PLUGIN_LICENSE_GPL 1 |
115 | | #define PLUGIN_LICENSE_BSD 2 |
116 | | |
117 | | #define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY" |
118 | | #define PLUGIN_LICENSE_GPL_STRING "GPL" |
119 | | #define PLUGIN_LICENSE_BSD_STRING "BSD" |
120 | | |
121 | | /* definitions of code maturity for plugins */ |
122 | | #define MariaDB_PLUGIN_MATURITY_UNKNOWN 0 |
123 | | #define MariaDB_PLUGIN_MATURITY_EXPERIMENTAL 1 |
124 | | #define MariaDB_PLUGIN_MATURITY_ALPHA 2 |
125 | | #define MariaDB_PLUGIN_MATURITY_BETA 3 |
126 | | #define MariaDB_PLUGIN_MATURITY_GAMMA 4 |
127 | | #define MariaDB_PLUGIN_MATURITY_STABLE 5 |
128 | | |
129 | | /* |
130 | | Macros for beginning and ending plugin declarations. Between |
131 | | mysql_declare_plugin and mysql_declare_plugin_end there should |
132 | | be a st_mysql_plugin struct for each plugin to be declared. |
133 | | */ |
134 | | |
135 | | |
136 | | #ifndef MYSQL_DYNAMIC_PLUGIN |
137 | | #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \ |
138 | | int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \ |
139 | | int PSIZE= sizeof(struct st_mysql_plugin); \ |
140 | | struct st_mysql_plugin DECLS[]= { |
141 | | |
142 | | #define MARIA_DECLARE_PLUGIN__(NAME, VERSION, PSIZE, DECLS) \ |
143 | | MYSQL_PLUGIN_EXPORT int VERSION; \ |
144 | | int VERSION= MARIA_PLUGIN_INTERFACE_VERSION; \ |
145 | | MYSQL_PLUGIN_EXPORT int PSIZE; \ |
146 | | int PSIZE= sizeof(struct st_maria_plugin); \ |
147 | | MYSQL_PLUGIN_EXPORT struct st_maria_plugin DECLS[]; \ |
148 | | struct st_maria_plugin DECLS[]= { |
149 | | #else |
150 | | |
151 | | #define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \ |
152 | | MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_; \ |
153 | | int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \ |
154 | | MYSQL_PLUGIN_EXPORT int _mysql_sizeof_struct_st_plugin_; \ |
155 | | int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin); \ |
156 | | MYSQL_PLUGIN_EXPORT struct st_mysql_plugin _mysql_plugin_declarations_[]; \ |
157 | | struct st_mysql_plugin _mysql_plugin_declarations_[]= { |
158 | | |
159 | | #define MARIA_DECLARE_PLUGIN__(NAME, VERSION, PSIZE, DECLS) \ |
160 | | MYSQL_PLUGIN_EXPORT int _maria_plugin_interface_version_; \ |
161 | | int _maria_plugin_interface_version_= MARIA_PLUGIN_INTERFACE_VERSION; \ |
162 | | MYSQL_PLUGIN_EXPORT int _maria_sizeof_struct_st_plugin_; \ |
163 | | int _maria_sizeof_struct_st_plugin_= sizeof(struct st_maria_plugin); \ |
164 | | MYSQL_PLUGIN_EXPORT struct st_maria_plugin _maria_plugin_declarations_[]; \ |
165 | | struct st_maria_plugin _maria_plugin_declarations_[]= { |
166 | | |
167 | | #endif |
168 | | |
169 | | #define mysql_declare_plugin(NAME) \ |
170 | | __MYSQL_DECLARE_PLUGIN(NAME, \ |
171 | | builtin_ ## NAME ## _plugin_interface_version, \ |
172 | | builtin_ ## NAME ## _sizeof_struct_st_plugin, \ |
173 | | builtin_ ## NAME ## _plugin) |
174 | | |
175 | | #define maria_declare_plugin(NAME) \ |
176 | | MARIA_DECLARE_PLUGIN__(NAME, \ |
177 | | builtin_maria_ ## NAME ## _plugin_interface_version, \ |
178 | | builtin_maria_ ## NAME ## _sizeof_struct_st_plugin, \ |
179 | | builtin_maria_ ## NAME ## _plugin) |
180 | | |
181 | | #define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}} |
182 | | #define maria_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}} |
183 | | |
184 | | /* |
185 | | declarations for SHOW STATUS support in plugins |
186 | | */ |
187 | | enum enum_mysql_show_type |
188 | | { |
189 | | SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG, |
190 | | SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, |
191 | | SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, |
192 | | SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_SIMPLE_FUNC, |
193 | | SHOW_SIZE_T, SHOW_always_last |
194 | | }; |
195 | | |
196 | | /* backward compatibility mapping. */ |
197 | | #define SHOW_INT SHOW_UINT |
198 | | #define SHOW_LONG SHOW_ULONG |
199 | | #define SHOW_LONGLONG SHOW_ULONGLONG |
200 | | |
201 | | enum enum_var_type |
202 | | { |
203 | | SHOW_OPT_DEFAULT= 0, SHOW_OPT_SESSION, SHOW_OPT_GLOBAL |
204 | | }; |
205 | | |
206 | | struct st_mysql_show_var { |
207 | | const char *name; |
208 | | void *value; |
209 | | enum enum_mysql_show_type type; |
210 | | }; |
211 | | |
212 | | struct system_status_var; |
213 | | |
214 | | #define SHOW_VAR_FUNC_BUFF_SIZE (256 * sizeof(void*)) |
215 | | typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, void *, struct system_status_var *status_var, enum enum_var_type); |
216 | | |
217 | | |
218 | | static inline |
219 | | struct st_mysql_show_var SHOW_FUNC_ENTRY(const char *name, |
220 | | mysql_show_var_func func_arg) |
221 | 0 | { |
222 | 0 | struct st_mysql_show_var tmp; |
223 | 0 | tmp.name= name; |
224 | 0 | tmp.value= (void*) func_arg; |
225 | 0 | tmp.type= SHOW_FUNC; |
226 | 0 | return tmp; |
227 | 0 | }; Unexecuted instantiation: fuzz_json.c:SHOW_FUNC_ENTRY Unexecuted instantiation: json_lib.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-ucs2.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-utf8.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype.c:SHOW_FUNC_ENTRY Unexecuted instantiation: dtoa.c:SHOW_FUNC_ENTRY Unexecuted instantiation: int2str.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-unidata.c:SHOW_FUNC_ENTRY Unexecuted instantiation: xml.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-mb.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-simple.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-uca.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-uca0900.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-uca1400.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_strtoll10.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_vsnprintf.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strfill.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strmake.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strnmov.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strxnmov.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-bin.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-latin1.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_malloc.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_static.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_thr_init.c:SHOW_FUNC_ENTRY Unexecuted instantiation: thr_mutex.c:SHOW_FUNC_ENTRY Unexecuted instantiation: thr_rwlock.c:SHOW_FUNC_ENTRY Unexecuted instantiation: psi_noop.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_error.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_getsystime.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_init.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_mess.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_once.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_symlink.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_sync.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_getpagesize.c:SHOW_FUNC_ENTRY Unexecuted instantiation: charset.c:SHOW_FUNC_ENTRY Unexecuted instantiation: errors.c:SHOW_FUNC_ENTRY Unexecuted instantiation: hash.c:SHOW_FUNC_ENTRY Unexecuted instantiation: mf_dirname.c:SHOW_FUNC_ENTRY Unexecuted instantiation: mf_loadpath.c:SHOW_FUNC_ENTRY Unexecuted instantiation: mf_pack.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_div.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_getwd.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_lib.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_open.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_read.c:SHOW_FUNC_ENTRY Unexecuted instantiation: array.c:SHOW_FUNC_ENTRY Unexecuted instantiation: charset-def.c:SHOW_FUNC_ENTRY Unexecuted instantiation: mf_qsort.c:SHOW_FUNC_ENTRY Unexecuted instantiation: my_alloc.c:SHOW_FUNC_ENTRY Unexecuted instantiation: bchange.c:SHOW_FUNC_ENTRY Unexecuted instantiation: bmove_upp.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-big5.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-cp932.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-czech.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-euc_kr.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-eucjpms.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-extra.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-gb2312.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-gbk.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-sjis.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-tis620.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-ujis.c:SHOW_FUNC_ENTRY Unexecuted instantiation: ctype-win1250ch.c:SHOW_FUNC_ENTRY Unexecuted instantiation: is_prefix.c:SHOW_FUNC_ENTRY Unexecuted instantiation: str2int.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strend.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strxmov.c:SHOW_FUNC_ENTRY Unexecuted instantiation: strmov_overlapp.c:SHOW_FUNC_ENTRY |
228 | | |
229 | | |
230 | | /* |
231 | | Constants for plugin flags. |
232 | | */ |
233 | | |
234 | | #define PLUGIN_OPT_NO_INSTALL 1UL /**< Not dynamically loadable */ |
235 | | #define PLUGIN_OPT_NO_UNINSTALL 2UL /**< Not dynamically unloadable */ |
236 | | |
237 | | |
238 | | /* |
239 | | declarations for server variables and command line options |
240 | | */ |
241 | | |
242 | | |
243 | | #define PLUGIN_VAR_BOOL 0x0001 |
244 | | #define PLUGIN_VAR_INT 0x0002 |
245 | | #define PLUGIN_VAR_LONG 0x0003 |
246 | | #define PLUGIN_VAR_LONGLONG 0x0004 |
247 | | #define PLUGIN_VAR_STR 0x0005 |
248 | | #define PLUGIN_VAR_ENUM 0x0006 |
249 | | #define PLUGIN_VAR_SET 0x0007 |
250 | | #define PLUGIN_VAR_DOUBLE 0x0008 |
251 | | #define PLUGIN_VAR_UNSIGNED 0x0080 |
252 | | #define PLUGIN_VAR_THDLOCAL 0x0100 /**< Variable is per-connection */ |
253 | | #define PLUGIN_VAR_READONLY 0x0200 /**< Server variable is read only */ |
254 | | #define PLUGIN_VAR_NOSYSVAR 0x0400 /**< Not a server variable */ |
255 | | #define PLUGIN_VAR_NOCMDOPT 0x0800 /**< Not a command line option */ |
256 | | #define PLUGIN_VAR_NOCMDARG 0x1000 /**< No argument for cmd line */ |
257 | | #define PLUGIN_VAR_RQCMDARG 0x0000 /**< Argument required for cmd line */ |
258 | | #define PLUGIN_VAR_OPCMDARG 0x2000 /**< Argument optional for cmd line */ |
259 | | #define PLUGIN_VAR_DEPRECATED 0x4000 /**< Server variable is deprecated */ |
260 | | #define PLUGIN_VAR_MEMALLOC 0x8000 /**< String needs memory allocated */ |
261 | | |
262 | | struct st_mysql_sys_var; |
263 | | struct st_mysql_value; |
264 | | |
265 | | /** |
266 | | SYNOPSIS |
267 | | (*mysql_var_check_func)() |
268 | | thd thread handle |
269 | | var dynamic variable being altered |
270 | | save pointer to temporary storage |
271 | | value user provided value |
272 | | RETURN |
273 | | 0 user provided value is OK and the update func may be called. |
274 | | any other value indicates error. |
275 | | |
276 | | This function should parse the user provided value and store in the |
277 | | provided temporary storage any data as required by the update func. |
278 | | There is sufficient space in the temporary storage to store a double. |
279 | | Note that the update func may not be called if any other error occurs |
280 | | so any memory allocated should be thread-local so that it may be freed |
281 | | automatically at the end of the statement. |
282 | | */ |
283 | | |
284 | | typedef int (*mysql_var_check_func)(MYSQL_THD thd, |
285 | | struct st_mysql_sys_var *var, |
286 | | void *save, struct st_mysql_value *value); |
287 | | |
288 | | /** |
289 | | SYNOPSIS |
290 | | (*mysql_var_update_func)() |
291 | | thd thread handle |
292 | | var dynamic variable being altered |
293 | | var_ptr pointer to dynamic variable |
294 | | save pointer to temporary storage |
295 | | RETURN |
296 | | NONE |
297 | | |
298 | | This function should use the validated value stored in the temporary store |
299 | | and persist it in the provided pointer to the dynamic variable. |
300 | | For example, strings may require memory to be allocated. |
301 | | */ |
302 | | typedef void (*mysql_var_update_func)(MYSQL_THD thd, |
303 | | struct st_mysql_sys_var *var, |
304 | | void *var_ptr, const void *save); |
305 | | |
306 | | |
307 | | /* the following declarations are for internal use only */ |
308 | | |
309 | | |
310 | | #define PLUGIN_VAR_MASK \ |
311 | | (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \ |
312 | | PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \ |
313 | | PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | \ |
314 | | PLUGIN_VAR_DEPRECATED | PLUGIN_VAR_MEMALLOC) |
315 | | |
316 | | #define MYSQL_PLUGIN_VAR_HEADER \ |
317 | | int flags; \ |
318 | | const char *name; \ |
319 | | const char *comment; \ |
320 | | mysql_var_check_func check; \ |
321 | | mysql_var_update_func update |
322 | | |
323 | | #define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name |
324 | | #define MYSQL_SYSVAR(name) \ |
325 | | ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name))) |
326 | | |
327 | | /* |
328 | | for global variables, the value pointer is the first |
329 | | element after the header, the default value is the second. |
330 | | for thread variables, the value offset is the first |
331 | | element after the header, the default value is the second. |
332 | | */ |
333 | | |
334 | | |
335 | | #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \ |
336 | | MYSQL_PLUGIN_VAR_HEADER; \ |
337 | | type *value; \ |
338 | | const type def_val; \ |
339 | | } MYSQL_SYSVAR_NAME(name) |
340 | | |
341 | | #define DECLARE_MYSQL_SYSVAR_CONST_BASIC(name, type) struct { \ |
342 | | MYSQL_PLUGIN_VAR_HEADER; \ |
343 | | const type *value; \ |
344 | | const type def_val; \ |
345 | | } MYSQL_SYSVAR_NAME(name) |
346 | | |
347 | | #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \ |
348 | | MYSQL_PLUGIN_VAR_HEADER; \ |
349 | | type *value; type def_val; \ |
350 | | type min_val; type max_val; \ |
351 | | type blk_sz; \ |
352 | | } MYSQL_SYSVAR_NAME(name) |
353 | | |
354 | | #define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \ |
355 | | MYSQL_PLUGIN_VAR_HEADER; \ |
356 | | type *value; type def_val; \ |
357 | | TYPELIB *typelib; \ |
358 | | } MYSQL_SYSVAR_NAME(name) |
359 | | |
360 | | #define DECLARE_THDVAR_FUNC(type) \ |
361 | | type *(*resolve)(MYSQL_THD thd, int offset) |
362 | | |
363 | | #define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \ |
364 | | MYSQL_PLUGIN_VAR_HEADER; \ |
365 | | int offset; \ |
366 | | const type def_val; \ |
367 | | DECLARE_THDVAR_FUNC(type); \ |
368 | | } MYSQL_SYSVAR_NAME(name) |
369 | | |
370 | | #define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \ |
371 | | MYSQL_PLUGIN_VAR_HEADER; \ |
372 | | int offset; \ |
373 | | type def_val; type min_val; \ |
374 | | type max_val; type blk_sz; \ |
375 | | DECLARE_THDVAR_FUNC(type); \ |
376 | | } MYSQL_SYSVAR_NAME(name) |
377 | | |
378 | | #define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \ |
379 | | MYSQL_PLUGIN_VAR_HEADER; \ |
380 | | int offset; \ |
381 | | const type def_val; \ |
382 | | DECLARE_THDVAR_FUNC(type); \ |
383 | | TYPELIB *typelib; \ |
384 | | } MYSQL_SYSVAR_NAME(name) |
385 | | |
386 | | |
387 | | /* |
388 | | the following declarations are for use by plugin implementors |
389 | | */ |
390 | | |
391 | | #define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \ |
392 | | DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \ |
393 | | PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \ |
394 | | #name, comment, check, update, &varname, def} |
395 | | |
396 | | #define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \ |
397 | | DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \ |
398 | | PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \ |
399 | | #name, comment, check, update, &varname, def} |
400 | | |
401 | | #define MYSQL_SYSVAR_CONST_STR(name, varname, opt, comment, check, update, def) \ |
402 | | DECLARE_MYSQL_SYSVAR_CONST_BASIC(name, char *) = { \ |
403 | | PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \ |
404 | | #name, comment, check, update, &varname, def} |
405 | | |
406 | | #define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \ |
407 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \ |
408 | | PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \ |
409 | | #name, comment, check, update, &varname, def, min, max, blk } |
410 | | |
411 | | #define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \ |
412 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \ |
413 | | PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
414 | | #name, comment, check, update, &varname, def, min, max, blk } |
415 | | |
416 | | #define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \ |
417 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \ |
418 | | PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \ |
419 | | #name, comment, check, update, &varname, def, min, max, blk } |
420 | | |
421 | | #define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \ |
422 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \ |
423 | | PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
424 | | #name, comment, check, update, &varname, def, min, max, blk } |
425 | | |
426 | | #define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \ |
427 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \ |
428 | | PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \ |
429 | | #name, comment, check, update, &varname, def, min, max, blk } |
430 | | |
431 | | #define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \ |
432 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \ |
433 | | PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
434 | | #name, comment, check, update, &varname, def, min, max, blk } |
435 | | |
436 | | #define MYSQL_SYSVAR_UINT64_T(name, varname, opt, comment, check, update, def, min, max, blk) \ |
437 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, uint64_t) = { \ |
438 | | PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
439 | | #name, comment, check, update, &varname, def, min, max, blk } |
440 | | |
441 | | #ifdef _WIN64 |
442 | | #define MYSQL_SYSVAR_SIZE_T(name, varname, opt, comment, check, update, def, min, max, blk) \ |
443 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, size_t) = { \ |
444 | | PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
445 | | #name, comment, check, update, &varname, def, min, max, blk } |
446 | | #else |
447 | | #define MYSQL_SYSVAR_SIZE_T(name, varname, opt, comment, check, update, def, min, max, blk) \ |
448 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, size_t) = { \ |
449 | | PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
450 | | #name, comment, check, update, &varname, def, min, max, blk } |
451 | | #endif |
452 | | |
453 | | #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \ |
454 | | DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \ |
455 | | PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \ |
456 | | #name, comment, check, update, &varname, def, typelib } |
457 | | |
458 | | #define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \ |
459 | | DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \ |
460 | | PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \ |
461 | | #name, comment, check, update, &varname, def, typelib } |
462 | | |
463 | | #define MYSQL_SYSVAR_DOUBLE(name, varname, opt, comment, check, update, def, min, max, blk) \ |
464 | | DECLARE_MYSQL_SYSVAR_SIMPLE(name, double) = { \ |
465 | | PLUGIN_VAR_DOUBLE | ((opt) & PLUGIN_VAR_MASK), \ |
466 | | #name, comment, check, update, &varname, def, min, max, blk } |
467 | | |
468 | | #define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \ |
469 | | DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \ |
470 | | PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
471 | | #name, comment, check, update, -1, def, 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, comment, check, update, -1, def, NULL} |
477 | | |
478 | | #define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \ |
479 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \ |
480 | | PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
481 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
482 | | |
483 | | #define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \ |
484 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \ |
485 | | PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
486 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
487 | | |
488 | | #define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \ |
489 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \ |
490 | | PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
491 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
492 | | |
493 | | #define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \ |
494 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \ |
495 | | PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
496 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
497 | | |
498 | | #define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \ |
499 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \ |
500 | | PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
501 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
502 | | |
503 | | #define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \ |
504 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \ |
505 | | PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ |
506 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
507 | | |
508 | | #define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \ |
509 | | DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \ |
510 | | PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
511 | | #name, comment, check, update, -1, def, NULL, typelib } |
512 | | |
513 | | #define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \ |
514 | | DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \ |
515 | | PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
516 | | #name, comment, check, update, -1, def, NULL, typelib } |
517 | | |
518 | | #define MYSQL_THDVAR_DOUBLE(name, opt, comment, check, update, def, min, max, blk) \ |
519 | | DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \ |
520 | | PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \ |
521 | | #name, comment, check, update, -1, def, min, max, blk, NULL } |
522 | | |
523 | | /* accessor macros */ |
524 | | |
525 | | #define SYSVAR(name) \ |
526 | | (*(MYSQL_SYSVAR_NAME(name).value)) |
527 | | |
528 | | /* when thd == null, result points to global value */ |
529 | | #define THDVAR(thd, name) \ |
530 | | (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset))) |
531 | | |
532 | | |
533 | | /** |
534 | | Plugin description structure. |
535 | | */ |
536 | | |
537 | | struct st_mysql_plugin |
538 | | { |
539 | | int type; /**< the plugin type (a MYSQL_XXX_PLUGIN value) */ |
540 | | void *info; /**< pointer to type-specific plugin descriptor */ |
541 | | const char *name; /**< plugin name */ |
542 | | const char *author; /**< plugin author (for I_S.PLUGINS) */ |
543 | | const char *descr; /**< general descriptive text (for I_S.PLUGINS) */ |
544 | | int license; /**< the plugin license (PLUGIN_LICENSE_XXX) */ |
545 | | /** |
546 | | The function to invoke when plugin is loaded. Plugin |
547 | | initialisation done here should defer any ALTER TABLE queries to |
548 | | after the ddl recovery is done, in the signal_ddl_recovery_done() |
549 | | callback called by ha_signal_ddl_recovery_done(). |
550 | | */ |
551 | | int (*init)(void *); |
552 | | int (*deinit)(void *);/**< the function to invoke when plugin is unloaded */ |
553 | | unsigned int version; /**< plugin version (for I_S.PLUGINS) */ |
554 | | struct st_mysql_show_var *status_vars; |
555 | | struct st_mysql_sys_var **system_vars; |
556 | | void * __reserved1; /**< reserved for dependency checking */ |
557 | | unsigned long flags; /**< flags for plugin */ |
558 | | }; |
559 | | |
560 | | /** |
561 | | MariaDB extension for plugins declaration structure. |
562 | | |
563 | | It also copies current MySQL plugin fields to have more independency |
564 | | in plugins extension |
565 | | */ |
566 | | |
567 | | struct st_maria_plugin |
568 | | { |
569 | | int type; /**< the plugin type (a MYSQL_XXX_PLUGIN value) */ |
570 | | void *info; /**< pointer to type-specific plugin descriptor */ |
571 | | const char *name; /**< plugin name */ |
572 | | const char *author; /**< plugin author (for SHOW PLUGINS) */ |
573 | | const char *descr; /**< general descriptive text (for SHOW PLUGINS ) */ |
574 | | int license; /**< the plugin license (PLUGIN_LICENSE_XXX) */ |
575 | | /** |
576 | | The function to invoke when plugin is loaded. Plugin |
577 | | initialisation done here should defer any ALTER TABLE queries to |
578 | | after the ddl recovery is done, in the signal_ddl_recovery_done() |
579 | | callback called by ha_signal_ddl_recovery_done(). |
580 | | */ |
581 | | int (*init)(void *); |
582 | | int (*deinit)(void *);/**< the function to invoke when plugin is unloaded */ |
583 | | unsigned int version; /**< plugin version (for SHOW PLUGINS) */ |
584 | | struct st_mysql_show_var *status_vars; |
585 | | struct st_mysql_sys_var **system_vars; |
586 | | const char *version_info; /**< plugin version string */ |
587 | | unsigned int maturity; /**< MariaDB_PLUGIN_MATURITY_XXX */ |
588 | | }; |
589 | | |
590 | | /************************************************************************* |
591 | | API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN) |
592 | | */ |
593 | | #include "plugin_ftparser.h" |
594 | | |
595 | | /************************************************************************* |
596 | | API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN) |
597 | | */ |
598 | | |
599 | | /* daemon plugins of different MySQL releases are incompatible */ |
600 | | #define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8) |
601 | | |
602 | | /* |
603 | | Here we define only the descriptor structure, that is referred from |
604 | | st_mysql_plugin. |
605 | | */ |
606 | | |
607 | | struct st_mysql_daemon |
608 | | { |
609 | | int interface_version; |
610 | | }; |
611 | | |
612 | | |
613 | | /************************************************************************* |
614 | | API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN) |
615 | | */ |
616 | | |
617 | | /* information schema plugins different MySQL releases are incompatible */ |
618 | | #define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8) |
619 | | |
620 | | /* |
621 | | Here we define only the descriptor structure, that is referred from |
622 | | st_mysql_plugin. |
623 | | */ |
624 | | |
625 | | struct st_mysql_information_schema |
626 | | { |
627 | | int interface_version; |
628 | | }; |
629 | | |
630 | | |
631 | | /************************************************************************* |
632 | | API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN) |
633 | | */ |
634 | | |
635 | | /* storage engines of different MySQL releases are incompatible */ |
636 | | #define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8) |
637 | | |
638 | | /* |
639 | | The real API is in the sql/handler.h |
640 | | Here we define only the descriptor structure, that is referred from |
641 | | st_mysql_plugin. |
642 | | */ |
643 | | |
644 | | struct st_mysql_storage_engine |
645 | | { |
646 | | int interface_version; |
647 | | }; |
648 | | |
649 | | struct transaction_participant; |
650 | | |
651 | | |
652 | | /* |
653 | | API for Replication plugin. (MYSQL_REPLICATION_PLUGIN) |
654 | | */ |
655 | | #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0200 |
656 | | |
657 | | /** |
658 | | Replication plugin descriptor |
659 | | */ |
660 | | struct Mysql_replication { |
661 | | int interface_version; |
662 | | }; |
663 | | |
664 | | #define MYSQL_VALUE_TYPE_STRING 0 |
665 | | #define MYSQL_VALUE_TYPE_REAL 1 |
666 | | #define MYSQL_VALUE_TYPE_INT 2 |
667 | | |
668 | | /************************************************************************* |
669 | | st_mysql_value struct for reading values from mysqld. |
670 | | Used by server variables framework to parse user-provided values. |
671 | | Will be used for arguments when implementing UDFs. |
672 | | |
673 | | Note that val_str() returns a string in temporary memory |
674 | | that will be freed at the end of statement. Copy the string |
675 | | if you need it to persist. |
676 | | */ |
677 | | |
678 | | struct st_mysql_value |
679 | | { |
680 | | int (*value_type)(struct st_mysql_value *); |
681 | | const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length); |
682 | | int (*val_real)(struct st_mysql_value *, double *realbuf); |
683 | | int (*val_int)(struct st_mysql_value *, long long *intbuf); |
684 | | int (*is_unsigned)(struct st_mysql_value *); |
685 | | }; |
686 | | |
687 | | |
688 | | /************************************************************************* |
689 | | Miscellaneous functions for plugin implementors |
690 | | */ |
691 | | |
692 | | #ifdef __cplusplus |
693 | | extern "C" { |
694 | | #endif |
695 | | |
696 | | int thd_in_lock_tables(const MYSQL_THD thd); |
697 | | int thd_tablespace_op(const MYSQL_THD thd); |
698 | | long long thd_test_options(const MYSQL_THD thd, long long test_options); |
699 | | int thd_sql_command(const MYSQL_THD thd); |
700 | | struct DDL_options_st; |
701 | | struct DDL_options_st *thd_ddl_options(const MYSQL_THD thd); |
702 | | void thd_storage_lock_wait(MYSQL_THD thd, long long value); |
703 | | int thd_tx_isolation(const MYSQL_THD thd); |
704 | | int thd_tx_is_read_only(const MYSQL_THD thd); |
705 | | |
706 | | /** |
707 | | Create a temporary file. |
708 | | |
709 | | @details |
710 | | The temporary file is created in a location specified by the mysql |
711 | | server configuration (--tmpdir option). The caller does not need to |
712 | | delete the file, it will be deleted automatically. |
713 | | |
714 | | @param prefix prefix for temporary file name |
715 | | @retval -1 error |
716 | | @retval >= 0 a file handle that can be passed to dup or my_close |
717 | | */ |
718 | | int mysql_tmpfile(const char *prefix); |
719 | | |
720 | | /** |
721 | | Return the thread id of a user thread |
722 | | |
723 | | @param thd user thread connection handle |
724 | | @return thread id |
725 | | */ |
726 | | unsigned long thd_get_thread_id(const MYSQL_THD thd); |
727 | | |
728 | | /** |
729 | | Get the XID for this connection's transaction |
730 | | |
731 | | @param thd user thread connection handle |
732 | | @param xid location where identifier is stored |
733 | | */ |
734 | | void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid); |
735 | | |
736 | | /** |
737 | | Invalidate the query cache for a given table. |
738 | | |
739 | | @param thd user thread connection handle |
740 | | @param key databasename\\0tablename\\0 |
741 | | @param key_length length of key in bytes, including the NUL bytes |
742 | | @param using_trx flag: TRUE if using transactions, FALSE otherwise |
743 | | */ |
744 | | void mysql_query_cache_invalidate4(MYSQL_THD thd, |
745 | | const char *key, unsigned int key_length, |
746 | | int using_trx); |
747 | | |
748 | | |
749 | | /** |
750 | | Provide a handler data getter to simplify coding |
751 | | */ |
752 | | void *thd_get_ha_data(const MYSQL_THD thd, const struct transaction_participant *hton); |
753 | | |
754 | | |
755 | | /** |
756 | | Provide a handler data setter to simplify coding |
757 | | |
758 | | @details |
759 | | Set ha_data pointer (storage engine per-connection information). |
760 | | |
761 | | To avoid unclean deactivation (uninstall) of storage engine plugin |
762 | | in the middle of transaction, additional storage engine plugin |
763 | | lock is acquired. |
764 | | |
765 | | If ha_data is not null and storage engine plugin was not locked |
766 | | by thd_set_ha_data() in this connection before, storage engine |
767 | | plugin gets locked. |
768 | | |
769 | | If ha_data is null and storage engine plugin was locked by |
770 | | thd_set_ha_data() in this connection before, storage engine |
771 | | plugin lock gets released. |
772 | | |
773 | | If transaction_participant::close_connection() didn't reset ha_data, server |
774 | | does it immediately after calling transaction_participant::close_connection() |
775 | | */ |
776 | | void thd_set_ha_data(MYSQL_THD thd, const struct transaction_participant *hton, |
777 | | const void *ha_data); |
778 | | |
779 | | |
780 | | /** |
781 | | Signal that the first part of handler commit is finished, and that the |
782 | | committed transaction is now visible and has fixed commit ordering with |
783 | | respect to other transactions. The commit need _not_ be durable yet, and |
784 | | typically will not be when this call makes sense. |
785 | | |
786 | | This call is optional, if the storage engine does not call it the upper |
787 | | layer will after the handler commit() method is done. However, the storage |
788 | | engine may choose to call it itself to increase the possibility for group |
789 | | commit. |
790 | | |
791 | | In-order parallel replication uses this to apply different transaction in |
792 | | parallel, but delay the commits of later transactions until earlier |
793 | | transactions have committed first, thus achieving increased performance on |
794 | | multi-core systems while still preserving full transaction consistency. |
795 | | |
796 | | The storage engine can call this from within the commit() method, typically |
797 | | after the commit record has been written to the transaction log, but before |
798 | | the log has been fsync()'ed. This will allow the next replicated transaction |
799 | | to proceed to commit before the first one has done fsync() or similar. Thus, |
800 | | it becomes possible for multiple sequential replicated transactions to share |
801 | | a single fsync() inside the engine in group commit. |
802 | | |
803 | | Note that this method should _not_ be called from within the commit_ordered() |
804 | | method, or any other place in the storage engine. When commit_ordered() is |
805 | | used (typically when binlog is enabled), the transaction coordinator takes |
806 | | care of this and makes group commit in the storage engine possible without |
807 | | any other action needed on the part of the storage engine. This function |
808 | | thd_wakeup_subsequent_commits() is only needed when no transaction |
809 | | coordinator is used, meaning a single storage engine and no binary log. |
810 | | */ |
811 | | void thd_wakeup_subsequent_commits(MYSQL_THD thd, int wakeup_error); |
812 | | |
813 | | #ifdef __cplusplus |
814 | | } |
815 | | #endif |
816 | | |
817 | | #endif |
818 | | |