1
by brian
clean slate |
1 |
/* Copyright (C) 2005 MySQL AB
|
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 as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
14 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
16 |
#ifndef _my_plugin_h
|
|
17 |
#define _my_plugin_h
|
|
18 |
||
19 |
#ifdef __cplusplus
|
|
20 |
class THD; |
|
21 |
class Item; |
|
22 |
#define MYSQL_THD THD*
|
|
23 |
#else
|
|
24 |
#define MYSQL_THD void*
|
|
25 |
#endif
|
|
26 |
||
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
27 |
#include <stdint.h> |
28 |
||
1
by brian
clean slate |
29 |
#ifndef _m_string_h
|
30 |
/* This definition must match the one given in m_string.h */
|
|
31 |
struct st_mysql_lex_string |
|
32 |
{
|
|
33 |
char *str; |
|
34 |
unsigned int length; |
|
35 |
};
|
|
36 |
#endif /* _m_string_h */ |
|
37 |
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; |
|
38 |
||
39 |
#define MYSQL_XIDDATASIZE 128
|
|
40 |
/**
|
|
41 |
struct st_mysql_xid is binary compatible with the XID structure as
|
|
42 |
in the X/Open CAE Specification, Distributed Transaction Processing:
|
|
43 |
The XA Specification, X/Open Company Ltd., 1991.
|
|
44 |
http://www.opengroup.org/bookstore/catalog/c193.htm
|
|
45 |
||
46 |
@see XID in sql/handler.h
|
|
47 |
*/
|
|
48 |
struct st_mysql_xid { |
|
49 |
long formatID; |
|
50 |
long gtrid_length; |
|
51 |
long bqual_length; |
|
52 |
char data[MYSQL_XIDDATASIZE]; /* Not \0-terminated */ |
|
53 |
};
|
|
54 |
typedef struct st_mysql_xid MYSQL_XID; |
|
55 |
||
56 |
/*************************************************************************
|
|
57 |
Plugin API. Common for all plugin types.
|
|
58 |
*/
|
|
59 |
||
60 |
/*
|
|
61 |
The allowable types of plugins
|
|
62 |
*/
|
|
190.1.1
by Mark Atwood
reorder plugin type numbering |
63 |
#define MYSQL_DAEMON_PLUGIN 0 /* Daemon / Raw */ |
64 |
#define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */ |
|
65 |
#define MYSQL_INFORMATION_SCHEMA_PLUGIN 2 /* Information Schema */ |
|
66 |
#define MYSQL_UDF_PLUGIN 3 /* User-Defined Function */ |
|
67 |
#define MYSQL_UDA_PLUGIN 4 /* User-Defined Aggregate function */ |
|
68 |
#define MYSQL_AUDIT_PLUGIN 5 /* Audit */ |
|
69 |
#define MYSQL_LOGGER_PLUGIN 6 /* Logging */ |
|
70 |
#define MYSQL_AUTH_PLUGIN 7 /* Authorization */ |
|
71 |
||
72 |
#define MYSQL_MAX_PLUGIN_TYPE_NUM 8 /* The number of plugin types */ |
|
1
by brian
clean slate |
73 |
|
74 |
/* We use the following strings to define licenses for plugins */
|
|
75 |
#define PLUGIN_LICENSE_PROPRIETARY 0
|
|
76 |
#define PLUGIN_LICENSE_GPL 1
|
|
77 |
#define PLUGIN_LICENSE_BSD 2
|
|
78 |
||
79 |
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
|
|
80 |
#define PLUGIN_LICENSE_GPL_STRING "GPL"
|
|
81 |
#define PLUGIN_LICENSE_BSD_STRING "BSD"
|
|
82 |
||
83 |
/*
|
|
84 |
Macros for beginning and ending plugin declarations. Between
|
|
85 |
mysql_declare_plugin and mysql_declare_plugin_end there should
|
|
86 |
be a st_mysql_plugin struct for each plugin to be declared.
|
|
87 |
*/
|
|
88 |
||
89 |
||
90 |
#ifndef MYSQL_DYNAMIC_PLUGIN
|
|
177.4.3
by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings |
91 |
#define __MYSQL_DECLARE_PLUGIN(NAME, DECLS) \
|
1
by brian
clean slate |
92 |
struct st_mysql_plugin DECLS[]= {
|
93 |
#else
|
|
177.4.3
by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings |
94 |
#define __MYSQL_DECLARE_PLUGIN(NAME, DECLS) \
|
1
by brian
clean slate |
95 |
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
|
96 |
#endif
|
|
97 |
||
98 |
#define mysql_declare_plugin(NAME) \
|
|
99 |
__MYSQL_DECLARE_PLUGIN(NAME, \
|
|
100 |
builtin_ ## NAME ## _plugin)
|
|
101 |
||
177.4.3
by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings |
102 |
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
|
1
by brian
clean slate |
103 |
|
104 |
/*
|
|
105 |
declarations for SHOW STATUS support in plugins
|
|
106 |
*/
|
|
107 |
enum enum_mysql_show_type |
|
108 |
{
|
|
109 |
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG, |
|
110 |
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, |
|
111 |
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE |
|
112 |
};
|
|
113 |
||
114 |
struct st_mysql_show_var { |
|
115 |
const char *name; |
|
116 |
char *value; |
|
117 |
enum enum_mysql_show_type type; |
|
118 |
};
|
|
119 |
||
77.1.9
by Monty Taylor
All of storage/ compiles clean now. |
120 |
|
1
by brian
clean slate |
121 |
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
|
122 |
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *); |
|
123 |
||
77.1.45
by Monty Taylor
Warning fixes. |
124 |
struct st_show_var_func_container { |
125 |
mysql_show_var_func func; |
|
126 |
};
|
|
1
by brian
clean slate |
127 |
/*
|
128 |
declarations for server variables and command line options
|
|
129 |
*/
|
|
130 |
||
131 |
||
132 |
#define PLUGIN_VAR_BOOL 0x0001
|
|
133 |
#define PLUGIN_VAR_INT 0x0002
|
|
134 |
#define PLUGIN_VAR_LONG 0x0003
|
|
135 |
#define PLUGIN_VAR_LONGLONG 0x0004
|
|
136 |
#define PLUGIN_VAR_STR 0x0005
|
|
137 |
#define PLUGIN_VAR_ENUM 0x0006
|
|
138 |
#define PLUGIN_VAR_SET 0x0007
|
|
139 |
#define PLUGIN_VAR_UNSIGNED 0x0080
|
|
140 |
#define PLUGIN_VAR_THDLOCAL 0x0100 /* Variable is per-connection */ |
|
141 |
#define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */ |
|
142 |
#define PLUGIN_VAR_NOSYSVAR 0x0400 /* Not a server variable */ |
|
143 |
#define PLUGIN_VAR_NOCMDOPT 0x0800 /* Not a command line option */ |
|
144 |
#define PLUGIN_VAR_NOCMDARG 0x1000 /* No argument for cmd line */ |
|
145 |
#define PLUGIN_VAR_RQCMDARG 0x0000 /* Argument required for cmd line */ |
|
146 |
#define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */ |
|
147 |
#define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */ |
|
148 |
||
149 |
struct st_mysql_sys_var; |
|
150 |
struct st_mysql_value; |
|
151 |
||
152 |
/*
|
|
153 |
SYNOPSIS
|
|
154 |
(*mysql_var_check_func)()
|
|
155 |
thd thread handle
|
|
156 |
var dynamic variable being altered
|
|
157 |
save pointer to temporary storage
|
|
158 |
value user provided value
|
|
159 |
RETURN
|
|
160 |
0 user provided value is OK and the update func may be called.
|
|
161 |
any other value indicates error.
|
|
162 |
|
|
163 |
This function should parse the user provided value and store in the
|
|
164 |
provided temporary storage any data as required by the update func.
|
|
165 |
There is sufficient space in the temporary storage to store a double.
|
|
166 |
Note that the update func may not be called if any other error occurs
|
|
167 |
so any memory allocated should be thread-local so that it may be freed
|
|
168 |
automatically at the end of the statement.
|
|
169 |
*/
|
|
170 |
||
171 |
typedef int (*mysql_var_check_func)(MYSQL_THD thd, |
|
172 |
struct st_mysql_sys_var *var, |
|
173 |
void *save, struct st_mysql_value *value); |
|
174 |
||
175 |
/*
|
|
176 |
SYNOPSIS
|
|
177 |
(*mysql_var_update_func)()
|
|
178 |
thd thread handle
|
|
179 |
var dynamic variable being altered
|
|
180 |
var_ptr pointer to dynamic variable
|
|
181 |
save pointer to temporary storage
|
|
182 |
RETURN
|
|
183 |
NONE
|
|
184 |
|
|
185 |
This function should use the validated value stored in the temporary store
|
|
186 |
and persist it in the provided pointer to the dynamic variable.
|
|
187 |
For example, strings may require memory to be allocated.
|
|
188 |
*/
|
|
189 |
typedef void (*mysql_var_update_func)(MYSQL_THD thd, |
|
190 |
struct st_mysql_sys_var *var, |
|
191 |
void *var_ptr, const void *save); |
|
192 |
||
193 |
||
194 |
/* the following declarations are for internal use only */
|
|
195 |
||
196 |
||
197 |
#define PLUGIN_VAR_MASK \
|
|
198 |
(PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
|
|
199 |
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
|
|
200 |
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
|
|
201 |
||
202 |
#define MYSQL_PLUGIN_VAR_HEADER \
|
|
203 |
int flags; \
|
|
204 |
const char *name; \
|
|
205 |
const char *comment; \
|
|
206 |
mysql_var_check_func check; \
|
|
207 |
mysql_var_update_func update
|
|
208 |
||
209 |
#define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
|
|
210 |
#define MYSQL_SYSVAR(name) \
|
|
211 |
((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
|
|
212 |
||
213 |
/*
|
|
214 |
for global variables, the value pointer is the first
|
|
215 |
element after the header, the default value is the second.
|
|
216 |
for thread variables, the value offset is the first
|
|
217 |
element after the header, the default value is the second.
|
|
218 |
*/
|
|
219 |
||
220 |
||
221 |
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
|
|
222 |
MYSQL_PLUGIN_VAR_HEADER; \
|
|
223 |
type *value; \
|
|
224 |
const type def_val; \
|
|
225 |
} MYSQL_SYSVAR_NAME(name)
|
|
226 |
||
227 |
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
|
|
228 |
MYSQL_PLUGIN_VAR_HEADER; \
|
|
229 |
type *value; type def_val; \
|
|
230 |
type min_val; type max_val; \
|
|
231 |
type blk_sz; \
|
|
232 |
} MYSQL_SYSVAR_NAME(name)
|
|
233 |
||
234 |
#define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
|
|
235 |
MYSQL_PLUGIN_VAR_HEADER; \
|
|
236 |
type *value; type def_val; \
|
|
237 |
TYPELIB *typelib; \
|
|
238 |
} MYSQL_SYSVAR_NAME(name)
|
|
239 |
||
240 |
#define DECLARE_THDVAR_FUNC(type) \
|
|
241 |
type *(*resolve)(MYSQL_THD thd, int offset)
|
|
242 |
||
243 |
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
|
|
244 |
MYSQL_PLUGIN_VAR_HEADER; \
|
|
245 |
int offset; \
|
|
246 |
const type def_val; \
|
|
247 |
DECLARE_THDVAR_FUNC(type); \
|
|
248 |
} MYSQL_SYSVAR_NAME(name)
|
|
249 |
||
250 |
#define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
|
|
251 |
MYSQL_PLUGIN_VAR_HEADER; \
|
|
252 |
int offset; \
|
|
253 |
type def_val; type min_val; \
|
|
254 |
type max_val; type blk_sz; \
|
|
255 |
DECLARE_THDVAR_FUNC(type); \
|
|
256 |
} MYSQL_SYSVAR_NAME(name)
|
|
257 |
||
258 |
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
|
|
259 |
MYSQL_PLUGIN_VAR_HEADER; \
|
|
260 |
int offset; \
|
|
261 |
type def_val; \
|
|
262 |
DECLARE_THDVAR_FUNC(type); \
|
|
263 |
TYPELIB *typelib; \
|
|
264 |
} MYSQL_SYSVAR_NAME(name)
|
|
265 |
||
266 |
||
267 |
/*
|
|
268 |
the following declarations are for use by plugin implementors
|
|
269 |
*/
|
|
270 |
||
271 |
#define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
|
|
272 |
DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \
|
|
273 |
PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
|
|
274 |
#name, comment, check, update, &varname, def}
|
|
275 |
||
276 |
#define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
|
|
277 |
DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
|
|
278 |
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
|
|
279 |
#name, comment, check, update, &varname, def}
|
|
280 |
||
281 |
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
|
|
282 |
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
|
|
283 |
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
|
|
284 |
#name, comment, check, update, &varname, def, min, max, blk }
|
|
285 |
||
286 |
#define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
|
|
287 |
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
|
|
288 |
PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
|
289 |
#name, comment, check, update, &varname, def, min, max, blk }
|
|
290 |
||
291 |
#define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
|
292 |
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
|
|
293 |
PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
|
|
294 |
#name, comment, check, update, &varname, def, min, max, blk }
|
|
295 |
||
296 |
#define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
|
297 |
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
|
|
298 |
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
|
299 |
#name, comment, check, update, &varname, def, min, max, blk }
|
|
300 |
||
301 |
#define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
302 |
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int64_t) = { \
|
1
by brian
clean slate |
303 |
PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
|
304 |
#name, comment, check, update, &varname, def, min, max, blk }
|
|
305 |
||
306 |
#define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
307 |
DECLARE_MYSQL_SYSVAR_SIMPLE(name, uint64_t) = { \
|
1
by brian
clean slate |
308 |
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
309 |
#name, comment, check, update, &varname, def, min, max, blk }
|
|
310 |
||
311 |
#define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
|
|
312 |
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
|
|
313 |
PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
|
|
314 |
#name, comment, check, update, &varname, def, typelib }
|
|
315 |
||
316 |
#define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
317 |
DECLARE_MYSQL_SYSVAR_TYPELIB(name, uint64_t) = { \
|
1
by brian
clean slate |
318 |
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
|
319 |
#name, comment, check, update, &varname, def, typelib }
|
|
320 |
||
321 |
#define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
|
|
322 |
DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \
|
|
323 |
PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
|
324 |
#name, comment, check, update, -1, def, NULL}
|
|
325 |
||
326 |
#define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
|
|
327 |
DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
|
|
328 |
PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
|
329 |
#name, comment, check, update, -1, def, NULL}
|
|
330 |
||
331 |
#define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
|
|
332 |
DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
|
|
333 |
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
|
334 |
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
|
335 |
||
336 |
#define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
|
|
337 |
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
|
|
338 |
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
|
339 |
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
|
340 |
||
341 |
#define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
|
|
342 |
DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
|
|
343 |
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
|
344 |
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
|
345 |
||
346 |
#define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
|
|
347 |
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
|
|
348 |
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
|
349 |
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
|
350 |
||
351 |
#define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
352 |
DECLARE_MYSQL_THDVAR_SIMPLE(name, int64_t) = { \
|
1
by brian
clean slate |
353 |
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
354 |
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
|
355 |
||
356 |
#define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
357 |
DECLARE_MYSQL_THDVAR_SIMPLE(name, uint64_t) = { \
|
1
by brian
clean slate |
358 |
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
359 |
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
|
360 |
||
361 |
#define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
|
|
362 |
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
|
|
363 |
PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
|
364 |
#name, comment, check, update, -1, def, NULL, typelib }
|
|
365 |
||
366 |
#define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
367 |
DECLARE_MYSQL_THDVAR_TYPELIB(name, uint64_t) = { \
|
1
by brian
clean slate |
368 |
PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
369 |
#name, comment, check, update, -1, def, NULL, typelib }
|
|
370 |
||
371 |
/* accessor macros */
|
|
372 |
||
373 |
#define SYSVAR(name) \
|
|
374 |
(*(MYSQL_SYSVAR_NAME(name).value))
|
|
375 |
||
376 |
/* when thd == null, result points to global value */
|
|
377 |
#define THDVAR(thd, name) \
|
|
378 |
(*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
|
|
379 |
||
380 |
||
381 |
/*
|
|
382 |
Plugin description structure.
|
|
383 |
*/
|
|
384 |
||
385 |
struct st_mysql_plugin |
|
386 |
{
|
|
387 |
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */ |
|
177.4.3
by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings |
388 |
const char *name; /* plugin name (for SHOW PLUGINS) */ |
389 |
const char *version; /* plugin version (for SHOW PLUGINS) */ |
|
1
by brian
clean slate |
390 |
const char *author; /* plugin author (for SHOW PLUGINS) */ |
391 |
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */ |
|
392 |
int license; /* the plugin license (PLUGIN_LICENSE_XXX) */ |
|
393 |
int (*init)(void *); /* the function to invoke when plugin is loaded */ |
|
394 |
int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ |
|
395 |
struct st_mysql_show_var *status_vars; |
|
396 |
struct st_mysql_sys_var **system_vars; |
|
397 |
void * __reserved1; /* reserved for dependency checking */ |
|
398 |
};
|
|
399 |
||
400 |
struct handlerton; |
|
401 |
||
402 |
||
403 |
/*************************************************************************
|
|
404 |
st_mysql_value struct for reading values from mysqld.
|
|
405 |
Used by server variables framework to parse user-provided values.
|
|
406 |
Will be used for arguments when implementing UDFs.
|
|
407 |
||
408 |
Note that val_str() returns a string in temporary memory
|
|
409 |
that will be freed at the end of statement. Copy the string
|
|
410 |
if you need it to persist.
|
|
411 |
*/
|
|
412 |
||
413 |
#define MYSQL_VALUE_TYPE_STRING 0
|
|
414 |
#define MYSQL_VALUE_TYPE_REAL 1
|
|
415 |
#define MYSQL_VALUE_TYPE_INT 2
|
|
416 |
||
417 |
struct st_mysql_value |
|
418 |
{
|
|
419 |
int (*value_type)(struct st_mysql_value *); |
|
420 |
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length); |
|
421 |
int (*val_real)(struct st_mysql_value *, double *realbuf); |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
422 |
int (*val_int)(struct st_mysql_value *, int64_t *intbuf); |
1
by brian
clean slate |
423 |
};
|
424 |
||
425 |
||
426 |
/*************************************************************************
|
|
427 |
Miscellaneous functions for plugin implementors
|
|
428 |
*/
|
|
429 |
||
430 |
#ifdef __cplusplus
|
|
431 |
extern "C" { |
|
432 |
#endif
|
|
433 |
||
434 |
int thd_in_lock_tables(const MYSQL_THD thd); |
|
435 |
int thd_tablespace_op(const MYSQL_THD thd); |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
436 |
int64_t thd_test_options(const MYSQL_THD thd, int64_t test_options); |
1
by brian
clean slate |
437 |
int thd_sql_command(const MYSQL_THD thd); |
438 |
const char *thd_proc_info(MYSQL_THD thd, const char *info); |
|
439 |
void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton); |
|
440 |
int thd_tx_isolation(const MYSQL_THD thd); |
|
441 |
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length, |
|
442 |
unsigned int max_query_len); |
|
443 |
/* Increments the row counter, see THD::row_count */
|
|
444 |
void thd_inc_row_count(MYSQL_THD thd); |
|
445 |
||
446 |
/**
|
|
447 |
Create a temporary file.
|
|
448 |
||
449 |
@details
|
|
450 |
The temporary file is created in a location specified by the mysql
|
|
451 |
server configuration (--tmpdir option). The caller does not need to
|
|
452 |
delete the file, it will be deleted automatically.
|
|
453 |
||
454 |
@param prefix prefix for temporary file name
|
|
455 |
@retval -1 error
|
|
456 |
@retval >= 0 a file handle that can be passed to dup or my_close
|
|
457 |
*/
|
|
458 |
int mysql_tmpfile(const char *prefix); |
|
459 |
||
460 |
/**
|
|
461 |
Check the killed state of a connection
|
|
462 |
||
463 |
@details
|
|
464 |
In MySQL support for the KILL statement is cooperative. The KILL
|
|
465 |
statement only sets a "killed" flag. This function returns the value
|
|
466 |
of that flag. A thread should check it often, especially inside
|
|
467 |
time-consuming loops, and gracefully abort the operation if it is
|
|
468 |
non-zero.
|
|
469 |
||
470 |
@param thd user thread connection handle
|
|
471 |
@retval 0 the connection is active
|
|
472 |
@retval 1 the connection has been killed
|
|
473 |
*/
|
|
474 |
int thd_killed(const MYSQL_THD thd); |
|
475 |
||
476 |
||
477 |
/**
|
|
478 |
Return the thread id of a user thread
|
|
479 |
||
480 |
@param thd user thread connection handle
|
|
481 |
@return thread id
|
|
482 |
*/
|
|
483 |
unsigned long thd_get_thread_id(const MYSQL_THD thd); |
|
484 |
||
485 |
||
486 |
/**
|
|
487 |
Allocate memory in the connection's local memory pool
|
|
488 |
||
489 |
@details
|
|
490 |
When properly used in place of @c my_malloc(), this can significantly
|
|
491 |
improve concurrency. Don't use this or related functions to allocate
|
|
492 |
large chunks of memory. Use for temporary storage only. The memory
|
|
493 |
will be freed automatically at the end of the statement; no explicit
|
|
494 |
code is required to prevent memory leaks.
|
|
495 |
||
496 |
@see alloc_root()
|
|
497 |
*/
|
|
498 |
void *thd_alloc(MYSQL_THD thd, unsigned int size); |
|
499 |
/**
|
|
500 |
@see thd_alloc()
|
|
501 |
*/
|
|
502 |
void *thd_calloc(MYSQL_THD thd, unsigned int size); |
|
503 |
/**
|
|
504 |
@see thd_alloc()
|
|
505 |
*/
|
|
506 |
char *thd_strdup(MYSQL_THD thd, const char *str); |
|
507 |
/**
|
|
508 |
@see thd_alloc()
|
|
509 |
*/
|
|
510 |
char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size); |
|
511 |
/**
|
|
512 |
@see thd_alloc()
|
|
513 |
*/
|
|
514 |
void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size); |
|
515 |
||
516 |
/**
|
|
517 |
Create a LEX_STRING in this connection's local memory pool
|
|
518 |
||
519 |
@param thd user thread connection handle
|
|
520 |
@param lex_str pointer to LEX_STRING object to be initialized
|
|
521 |
@param str initializer to be copied into lex_str
|
|
522 |
@param size length of str, in bytes
|
|
523 |
@param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
|
|
524 |
instead of using lex_str value
|
|
525 |
@return NULL on failure, or pointer to the LEX_STRING object
|
|
526 |
||
527 |
@see thd_alloc()
|
|
528 |
*/
|
|
529 |
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str, |
|
530 |
const char *str, unsigned int size, |
|
531 |
int allocate_lex_string); |
|
532 |
||
533 |
/**
|
|
534 |
Get the XID for this connection's transaction
|
|
535 |
||
536 |
@param thd user thread connection handle
|
|
537 |
@param xid location where identifier is stored
|
|
538 |
*/
|
|
539 |
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid); |
|
540 |
||
541 |
/**
|
|
542 |
Invalidate the query cache for a given table.
|
|
543 |
||
544 |
@param thd user thread connection handle
|
|
545 |
@param key databasename\\0tablename\\0
|
|
546 |
@param key_length length of key in bytes, including the NUL bytes
|
|
547 |
@param using_trx flag: TRUE if using transactions, FALSE otherwise
|
|
548 |
*/
|
|
549 |
void mysql_query_cache_invalidate4(MYSQL_THD thd, |
|
550 |
const char *key, unsigned int key_length, |
|
551 |
int using_trx); |
|
552 |
||
553 |
#ifdef __cplusplus
|
|
554 |
}
|
|
555 |
#endif
|
|
556 |
||
557 |
#ifdef __cplusplus
|
|
558 |
/**
|
|
559 |
Provide a handler data getter to simplify coding
|
|
560 |
*/
|
|
561 |
inline
|
|
562 |
void * |
|
563 |
thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton) |
|
564 |
{
|
|
565 |
return *thd_ha_data(thd, hton); |
|
566 |
}
|
|
567 |
||
568 |
/**
|
|
569 |
Provide a handler data setter to simplify coding
|
|
570 |
*/
|
|
571 |
inline
|
|
572 |
void
|
|
573 |
thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton, |
|
574 |
const void *ha_data) |
|
575 |
{
|
|
576 |
*thd_ha_data(thd, hton)= (void*) ha_data; |
|
577 |
}
|
|
578 |
#endif
|
|
579 |
||
580 |
#endif
|
|
581 |