~vadim-tk/percona-server/flushing-algo

« back to all changes in this revision

Viewing changes to include/mysql/plugin.h

  • Committer: root
  • Date: 2011-10-29 01:34:40 UTC
  • Revision ID: root@hppro1.office.percona.com-20111029013440-qhnf4jk8kdjcf4e0
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
15
 
 
16
#ifndef _my_plugin_h
 
17
#define _my_plugin_h
 
18
 
 
19
/*
 
20
  On Windows, exports from DLL need to be declared
 
21
  Also, plugin needs to be declared as extern "C" because MSVC 
 
22
  unlike other compilers, uses C++ mangling for variables not only
 
23
  for functions.
 
24
*/
 
25
#if defined(_MSC_VER)
 
26
#if defined(MYSQL_DYNAMIC_PLUGIN)
 
27
  #ifdef __cplusplus
 
28
    #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
 
29
  #else
 
30
    #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
 
31
  #endif
 
32
#else /* MYSQL_DYNAMIC_PLUGIN */
 
33
  #ifdef __cplusplus
 
34
    #define  MYSQL_PLUGIN_EXPORT extern "C"
 
35
  #else
 
36
    #define MYSQL_PLUGIN_EXPORT 
 
37
  #endif
 
38
#endif /*MYSQL_DYNAMIC_PLUGIN */
 
39
#else /*_MSC_VER */
 
40
#define MYSQL_PLUGIN_EXPORT
 
41
#endif
 
42
 
 
43
#ifdef __cplusplus
 
44
class THD;
 
45
class Item;
 
46
#define MYSQL_THD THD*
 
47
#else
 
48
#define MYSQL_THD void*
 
49
#endif
 
50
 
 
51
#include <mysql/services.h>
 
52
 
 
53
#define MYSQL_XIDDATASIZE 128
 
54
/**
 
55
  struct st_mysql_xid is binary compatible with the XID structure as
 
56
  in the X/Open CAE Specification, Distributed Transaction Processing:
 
57
  The XA Specification, X/Open Company Ltd., 1991.
 
58
  http://www.opengroup.org/bookstore/catalog/c193.htm
 
59
 
 
60
  @see XID in sql/handler.h
 
61
*/
 
62
struct st_mysql_xid {
 
63
  long formatID;
 
64
  long gtrid_length;
 
65
  long bqual_length;
 
66
  char data[MYSQL_XIDDATASIZE];  /* Not \0-terminated */
 
67
};
 
68
typedef struct st_mysql_xid MYSQL_XID;
 
69
 
 
70
/*************************************************************************
 
71
  Plugin API. Common for all plugin types.
 
72
*/
 
73
 
 
74
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103
 
75
 
 
76
/*
 
77
  The allowable types of plugins
 
78
*/
 
79
#define MYSQL_UDF_PLUGIN             0  /* User-defined function        */
 
80
#define MYSQL_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine               */
 
81
#define MYSQL_FTPARSER_PLUGIN        2  /* Full-text parser plugin      */
 
82
#define MYSQL_DAEMON_PLUGIN          3  /* The daemon/raw plugin type */
 
83
#define MYSQL_INFORMATION_SCHEMA_PLUGIN  4  /* The I_S plugin type */
 
84
#define MYSQL_AUDIT_PLUGIN           5  /* The Audit plugin type        */
 
85
#define MYSQL_REPLICATION_PLUGIN     6  /* The replication plugin type */
 
86
#define MYSQL_AUTHENTICATION_PLUGIN  7  /* The authentication plugin type */
 
87
#define MYSQL_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types   */
 
88
 
 
89
/* We use the following strings to define licenses for plugins */
 
90
#define PLUGIN_LICENSE_PROPRIETARY 0
 
91
#define PLUGIN_LICENSE_GPL 1
 
92
#define PLUGIN_LICENSE_BSD 2
 
93
 
 
94
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
 
95
#define PLUGIN_LICENSE_GPL_STRING "GPL"
 
96
#define PLUGIN_LICENSE_BSD_STRING "BSD"
 
97
 
 
98
/*
 
99
  Macros for beginning and ending plugin declarations.  Between
 
100
  mysql_declare_plugin and mysql_declare_plugin_end there should
 
101
  be a st_mysql_plugin struct for each plugin to be declared.
 
102
*/
 
103
 
 
104
 
 
105
#ifndef MYSQL_DYNAMIC_PLUGIN
 
106
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \
 
107
MYSQL_PLUGIN_EXPORT int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION;                                  \
 
108
MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_mysql_plugin);                                    \
 
109
MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[]= {
 
110
#else
 
111
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \
 
112
MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION;         \
 
113
MYSQL_PLUGIN_EXPORT int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin);          \
 
114
MYSQL_PLUGIN_EXPORT struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
115
#endif
 
116
 
 
117
#define mysql_declare_plugin(NAME) \
 
118
__MYSQL_DECLARE_PLUGIN(NAME, \
 
119
                 builtin_ ## NAME ## _plugin_interface_version, \
 
120
                 builtin_ ## NAME ## _sizeof_struct_st_plugin, \
 
121
                 builtin_ ## NAME ## _plugin)
 
122
 
 
123
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}}
 
124
 
 
125
/*
 
126
  declarations for SHOW STATUS support in plugins
 
127
*/
 
128
enum enum_mysql_show_type
 
129
{
 
130
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
131
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
132
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE,
 
133
  SHOW_always_last
 
134
};
 
135
 
 
136
struct st_mysql_show_var {
 
137
  const char *name;
 
138
  char *value;
 
139
  enum enum_mysql_show_type type;
 
140
};
 
141
 
 
142
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
143
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *);
 
144
 
 
145
 
 
146
/*
 
147
  Constants for plugin flags.
 
148
 */
 
149
 
 
150
#define PLUGIN_OPT_NO_INSTALL   1UL   /* Not dynamically loadable */
 
151
#define PLUGIN_OPT_NO_UNINSTALL 2UL   /* Not dynamically unloadable */
 
152
 
 
153
 
 
154
/*
 
155
  declarations for server variables and command line options
 
156
*/
 
157
 
 
158
 
 
159
#define PLUGIN_VAR_BOOL         0x0001
 
160
#define PLUGIN_VAR_INT          0x0002
 
161
#define PLUGIN_VAR_LONG         0x0003
 
162
#define PLUGIN_VAR_LONGLONG     0x0004
 
163
#define PLUGIN_VAR_STR          0x0005
 
164
#define PLUGIN_VAR_ENUM         0x0006
 
165
#define PLUGIN_VAR_SET          0x0007
 
166
#define PLUGIN_VAR_UNSIGNED     0x0080
 
167
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
 
168
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
 
169
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
 
170
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
 
171
#define PLUGIN_VAR_NOCMDARG     0x1000 /* No argument for cmd line */
 
172
#define PLUGIN_VAR_RQCMDARG     0x0000 /* Argument required for cmd line */
 
173
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
 
174
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
 
175
 
 
176
struct st_mysql_sys_var;
 
177
struct st_mysql_value;
 
178
 
 
179
/*
 
180
  SYNOPSIS
 
181
    (*mysql_var_check_func)()
 
182
      thd               thread handle
 
183
      var               dynamic variable being altered
 
184
      save              pointer to temporary storage
 
185
      value             user provided value
 
186
  RETURN
 
187
    0   user provided value is OK and the update func may be called.
 
188
    any other value indicates error.
 
189
  
 
190
  This function should parse the user provided value and store in the
 
191
  provided temporary storage any data as required by the update func.
 
192
  There is sufficient space in the temporary storage to store a double.
 
193
  Note that the update func may not be called if any other error occurs
 
194
  so any memory allocated should be thread-local so that it may be freed
 
195
  automatically at the end of the statement.
 
196
*/
 
197
 
 
198
typedef int (*mysql_var_check_func)(MYSQL_THD thd,
 
199
                                    struct st_mysql_sys_var *var,
 
200
                                    void *save, struct st_mysql_value *value);
 
201
 
 
202
/*
 
203
  SYNOPSIS
 
204
    (*mysql_var_update_func)()
 
205
      thd               thread handle
 
206
      var               dynamic variable being altered
 
207
      var_ptr           pointer to dynamic variable
 
208
      save              pointer to temporary storage
 
209
   RETURN
 
210
     NONE
 
211
   
 
212
   This function should use the validated value stored in the temporary store
 
213
   and persist it in the provided pointer to the dynamic variable.
 
214
   For example, strings may require memory to be allocated.
 
215
*/
 
216
typedef void (*mysql_var_update_func)(MYSQL_THD thd,
 
217
                                      struct st_mysql_sys_var *var,
 
218
                                      void *var_ptr, const void *save);
 
219
 
 
220
 
 
221
/* the following declarations are for internal use only */
 
222
 
 
223
 
 
224
#define PLUGIN_VAR_MASK \
 
225
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
226
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
227
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
228
 
 
229
#define MYSQL_PLUGIN_VAR_HEADER \
 
230
  int flags;                    \
 
231
  const char *name;             \
 
232
  const char *comment;          \
 
233
  mysql_var_check_func check;   \
 
234
  mysql_var_update_func update
 
235
 
 
236
#define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
237
#define MYSQL_SYSVAR(name) \
 
238
  ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
 
239
 
 
240
/*
 
241
  for global variables, the value pointer is the first
 
242
  element after the header, the default value is the second.
 
243
  for thread variables, the value offset is the first
 
244
  element after the header, the default value is the second.
 
245
*/
 
246
   
 
247
 
 
248
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
 
249
  MYSQL_PLUGIN_VAR_HEADER;      \
 
250
  type *value;                  \
 
251
  const type def_val;           \
 
252
} MYSQL_SYSVAR_NAME(name)
 
253
 
 
254
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
 
255
  MYSQL_PLUGIN_VAR_HEADER;      \
 
256
  type *value; type def_val;    \
 
257
  type min_val; type max_val;   \
 
258
  type blk_sz;                  \
 
259
} MYSQL_SYSVAR_NAME(name)
 
260
 
 
261
#define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
 
262
  MYSQL_PLUGIN_VAR_HEADER;      \
 
263
  type *value; type def_val;    \
 
264
  TYPELIB *typelib;             \
 
265
} MYSQL_SYSVAR_NAME(name)
 
266
 
 
267
#define DECLARE_THDVAR_FUNC(type) \
 
268
  type *(*resolve)(MYSQL_THD thd, int offset)
 
269
 
 
270
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
 
271
  MYSQL_PLUGIN_VAR_HEADER;      \
 
272
  int offset;                   \
 
273
  const type def_val;           \
 
274
  DECLARE_THDVAR_FUNC(type);    \
 
275
} MYSQL_SYSVAR_NAME(name)
 
276
 
 
277
#define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
 
278
  MYSQL_PLUGIN_VAR_HEADER;      \
 
279
  int offset;                   \
 
280
  type def_val; type min_val;   \
 
281
  type max_val; type blk_sz;    \
 
282
  DECLARE_THDVAR_FUNC(type);    \
 
283
} MYSQL_SYSVAR_NAME(name)
 
284
 
 
285
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
 
286
  MYSQL_PLUGIN_VAR_HEADER;      \
 
287
  int offset;                   \
 
288
  type def_val;                 \
 
289
  DECLARE_THDVAR_FUNC(type);    \
 
290
  TYPELIB *typelib;             \
 
291
} MYSQL_SYSVAR_NAME(name)
 
292
 
 
293
 
 
294
/*
 
295
  the following declarations are for use by plugin implementors
 
296
*/
 
297
 
 
298
#define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
299
DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \
 
300
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
301
  #name, comment, check, update, &varname, def}
 
302
 
 
303
#define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
304
DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
 
305
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
306
  #name, comment, check, update, &varname, def}
 
307
 
 
308
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
309
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
 
310
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
311
  #name, comment, check, update, &varname, def, min, max, blk }
 
312
 
 
313
#define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
314
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
 
315
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
316
  #name, comment, check, update, &varname, def, min, max, blk }
 
317
 
 
318
#define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
319
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
 
320
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
321
  #name, comment, check, update, &varname, def, min, max, blk }
 
322
 
 
323
#define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
324
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
 
325
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
326
  #name, comment, check, update, &varname, def, min, max, blk }
 
327
 
 
328
#define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
329
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \
 
330
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
331
  #name, comment, check, update, &varname, def, min, max, blk }
 
332
 
 
333
#define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
334
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
 
335
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
336
  #name, comment, check, update, &varname, def, min, max, blk }
 
337
 
 
338
#define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
339
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
 
340
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
341
  #name, comment, check, update, &varname, def, typelib }
 
342
 
 
343
#define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
344
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \
 
345
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
346
  #name, comment, check, update, &varname, def, typelib }
 
347
 
 
348
#define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
 
349
DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \
 
350
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
351
  #name, comment, check, update, -1, def, NULL}
 
352
 
 
353
#define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
 
354
DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
 
355
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
356
  #name, comment, check, update, -1, def, NULL}
 
357
 
 
358
#define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
359
DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
 
360
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
361
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
362
 
 
363
#define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
364
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
 
365
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
366
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
367
 
 
368
#define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
369
DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
 
370
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
371
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
372
 
 
373
#define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
374
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
 
375
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
376
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
377
 
 
378
#define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
379
DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \
 
380
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
381
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
382
 
 
383
#define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
384
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \
 
385
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
386
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
387
 
 
388
#define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
389
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
 
390
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
391
  #name, comment, check, update, -1, def, NULL, typelib }
 
392
 
 
393
#define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
 
394
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \
 
395
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
396
  #name, comment, check, update, -1, def, NULL, typelib }
 
397
 
 
398
/* accessor macros */
 
399
 
 
400
#define SYSVAR(name) \
 
401
  (*(MYSQL_SYSVAR_NAME(name).value))
 
402
 
 
403
/* when thd == null, result points to global value */
 
404
#define THDVAR(thd, name) \
 
405
  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
 
406
 
 
407
 
 
408
/*
 
409
  Plugin description structure.
 
410
*/
 
411
 
 
412
struct st_mysql_plugin
 
413
{
 
414
  int type;             /* the plugin type (a MYSQL_XXX_PLUGIN value)   */
 
415
  void *info;           /* pointer to type-specific plugin descriptor   */
 
416
  const char *name;     /* plugin name                                  */
 
417
  const char *author;   /* plugin author (for I_S.PLUGINS)              */
 
418
  const char *descr;    /* general descriptive text (for I_S.PLUGINS)   */
 
419
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
 
420
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
 
421
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
 
422
  unsigned int version; /* plugin version (for I_S.PLUGINS)             */
 
423
  struct st_mysql_show_var *status_vars;
 
424
  struct st_mysql_sys_var **system_vars;
 
425
  void * __reserved1;   /* reserved for dependency checking             */
 
426
  unsigned long flags;  /* flags for plugin */
 
427
};
 
428
 
 
429
/*************************************************************************
 
430
  API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
 
431
*/
 
432
#include "plugin_ftparser.h"
 
433
 
 
434
/*************************************************************************
 
435
  API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
 
436
*/
 
437
 
 
438
/* handlertons of different MySQL releases are incompatible */
 
439
#define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
440
 
 
441
/*
 
442
  Here we define only the descriptor structure, that is referred from
 
443
  st_mysql_plugin.
 
444
*/
 
445
 
 
446
struct st_mysql_daemon
 
447
{
 
448
  int interface_version;
 
449
};
 
450
 
 
451
 
 
452
/*************************************************************************
 
453
  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
 
454
*/
 
455
 
 
456
/* handlertons of different MySQL releases are incompatible */
 
457
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
458
 
 
459
/*
 
460
  Here we define only the descriptor structure, that is referred from
 
461
  st_mysql_plugin.
 
462
*/
 
463
 
 
464
struct st_mysql_information_schema
 
465
{
 
466
  int interface_version;
 
467
};
 
468
 
 
469
 
 
470
/*************************************************************************
 
471
  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
 
472
*/
 
473
 
 
474
/* handlertons of different MySQL releases are incompatible */
 
475
#define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
476
 
 
477
/*
 
478
  The real API is in the sql/handler.h
 
479
  Here we define only the descriptor structure, that is referred from
 
480
  st_mysql_plugin.
 
481
*/
 
482
 
 
483
struct st_mysql_storage_engine
 
484
{
 
485
  int interface_version;
 
486
};
 
487
 
 
488
struct handlerton;
 
489
 
 
490
 
 
491
/*
 
492
  API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
 
493
*/
 
494
 #define MYSQL_REPLICATION_INTERFACE_VERSION 0x0100
 
495
 
 
496
 /**
 
497
    Replication plugin descriptor
 
498
 */
 
499
 struct Mysql_replication {
 
500
   int interface_version;
 
501
 };
 
502
 
 
503
/*************************************************************************
 
504
  st_mysql_value struct for reading values from mysqld.
 
505
  Used by server variables framework to parse user-provided values.
 
506
  Will be used for arguments when implementing UDFs.
 
507
 
 
508
  Note that val_str() returns a string in temporary memory
 
509
  that will be freed at the end of statement. Copy the string
 
510
  if you need it to persist.
 
511
*/
 
512
 
 
513
#define MYSQL_VALUE_TYPE_STRING 0
 
514
#define MYSQL_VALUE_TYPE_REAL   1
 
515
#define MYSQL_VALUE_TYPE_INT    2
 
516
 
 
517
struct st_mysql_value
 
518
{
 
519
  int (*value_type)(struct st_mysql_value *);
 
520
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
521
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
522
  int (*val_int)(struct st_mysql_value *, long long *intbuf);
 
523
  int (*is_unsigned)(struct st_mysql_value *);
 
524
};
 
525
 
 
526
 
 
527
/*************************************************************************
 
528
  Miscellaneous functions for plugin implementors
 
529
*/
 
530
 
 
531
#ifdef __cplusplus
 
532
extern "C" {
 
533
#endif
 
534
 
 
535
int thd_in_lock_tables(const MYSQL_THD thd);
 
536
int thd_tablespace_op(const MYSQL_THD thd);
 
537
long long thd_test_options(const MYSQL_THD thd, long long test_options);
 
538
int thd_sql_command(const MYSQL_THD thd);
 
539
const char *thd_proc_info(MYSQL_THD thd, const char *info);
 
540
void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
 
541
void thd_storage_lock_wait(MYSQL_THD thd, long long value);
 
542
int thd_tx_isolation(const MYSQL_THD thd);
 
543
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
 
544
                           unsigned int max_query_len);
 
545
/* Increments the row counter, see THD::row_count */
 
546
void thd_inc_row_count(MYSQL_THD thd);
 
547
 
 
548
void increment_thd_innodb_stats(MYSQL_THD thd,
 
549
                    unsigned long long trx_id,
 
550
                    long io_reads,
 
551
                    long long io_read,
 
552
                    long io_reads_wait_timer,
 
553
                    long lock_que_wait_timer,
 
554
                    long que_wait_timer,
 
555
                    long page_access);
 
556
unsigned long thd_log_slow_verbosity(const MYSQL_THD thd);
 
557
int thd_opt_slow_log();
 
558
#define EXTENDED_SLOWLOG
 
559
 
 
560
#define EXTENDED_FOR_USERSTAT
 
561
 
 
562
/**
 
563
  Create a temporary file.
 
564
 
 
565
  @details
 
566
  The temporary file is created in a location specified by the mysql
 
567
  server configuration (--tmpdir option).  The caller does not need to
 
568
  delete the file, it will be deleted automatically.
 
569
 
 
570
  @param prefix  prefix for temporary file name
 
571
  @retval -1    error
 
572
  @retval >= 0  a file handle that can be passed to dup or my_close
 
573
*/
 
574
int mysql_tmpfile(const char *prefix);
 
575
 
 
576
/**
 
577
  Check the killed state of a connection
 
578
 
 
579
  @details
 
580
  In MySQL support for the KILL statement is cooperative. The KILL
 
581
  statement only sets a "killed" flag. This function returns the value
 
582
  of that flag.  A thread should check it often, especially inside
 
583
  time-consuming loops, and gracefully abort the operation if it is
 
584
  non-zero.
 
585
 
 
586
  @param thd  user thread connection handle
 
587
  @retval 0  the connection is active
 
588
  @retval 1  the connection has been killed
 
589
*/
 
590
int thd_killed(const MYSQL_THD thd);
 
591
 
 
592
 
 
593
/**
 
594
  Return the thread id of a user thread
 
595
 
 
596
  @param thd  user thread connection handle
 
597
  @return  thread id
 
598
*/
 
599
unsigned long thd_get_thread_id(const MYSQL_THD thd);
 
600
 
 
601
/**
 
602
  Get the XID for this connection's transaction
 
603
 
 
604
  @param thd  user thread connection handle
 
605
  @param xid  location where identifier is stored
 
606
*/
 
607
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
 
608
 
 
609
/**
 
610
  Invalidate the query cache for a given table.
 
611
 
 
612
  @param thd         user thread connection handle
 
613
  @param key         databasename\\0tablename\\0
 
614
  @param key_length  length of key in bytes, including the NUL bytes
 
615
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
616
*/
 
617
void mysql_query_cache_invalidate4(MYSQL_THD thd,
 
618
                                   const char *key, unsigned int key_length,
 
619
                                   int using_trx);
 
620
 
 
621
 
 
622
/**
 
623
  Provide a handler data getter to simplify coding
 
624
*/
 
625
void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
 
626
 
 
627
 
 
628
/**
 
629
  Provide a handler data setter to simplify coding
 
630
 
 
631
  @details
 
632
  Set ha_data pointer (storage engine per-connection information).
 
633
 
 
634
  To avoid unclean deactivation (uninstall) of storage engine plugin
 
635
  in the middle of transaction, additional storage engine plugin
 
636
  lock is acquired.
 
637
 
 
638
  If ha_data is not null and storage engine plugin was not locked
 
639
  by thd_set_ha_data() in this connection before, storage engine
 
640
  plugin gets locked.
 
641
 
 
642
  If ha_data is null and storage engine plugin was locked by
 
643
  thd_set_ha_data() in this connection before, storage engine
 
644
  plugin lock gets released.
 
645
 
 
646
  If handlerton::close_connection() didn't reset ha_data, server does
 
647
  it immediately after calling handlerton::close_connection().
 
648
*/
 
649
void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
 
650
                     const void *ha_data);
 
651
 
 
652
int thd_command(const MYSQL_THD thd);
 
653
long long thd_start_time(const MYSQL_THD thd);
 
654
void thd_kill(MYSQL_THD thd);
 
655
#define EXTENDED_FOR_KILLIDLE
 
656
 
 
657
#ifdef __cplusplus
 
658
}
 
659
#endif
 
660
 
 
661
#endif
 
662