~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_PLUGIN_H
21
 
#define DRIZZLED_PLUGIN_H
22
 
 
23
 
#include <boost/program_options.hpp>
24
 
#include <boost/filesystem.hpp>
25
 
 
26
 
#include "drizzled/module/manifest.h"
27
 
#include "drizzled/module/module.h"
28
 
#include "drizzled/plugin/version.h"
29
 
#include "drizzled/module/context.h"
30
 
#include "drizzled/definitions.h"
31
 
 
32
 
#include "drizzled/lex_string.h"
33
 
#include "drizzled/sys_var.h"
34
 
#include "drizzled/xid.h"
35
 
 
36
 
namespace drizzled
37
 
{
38
 
 
39
 
class Session;
 
20
#ifndef _my_plugin_h
 
21
#define _my_plugin_h
 
22
 
 
23
#include <drizzled/global.h>
 
24
 
 
25
#ifdef __cplusplus
 
26
class THD;
40
27
class Item;
41
 
struct charset_info_st;
 
28
#define DRIZZLE_THD THD*
 
29
#else
 
30
#define DRIZZLE_THD void*
 
31
#endif
 
32
 
 
33
#define DRIZZLE_XIDDATASIZE 128
 
34
/**
 
35
  struct st_mysql_xid is binary compatible with the XID structure as
 
36
  in the X/Open CAE Specification, Distributed Transaction Processing:
 
37
  The XA Specification, X/Open Company Ltd., 1991.
 
38
  http://www.opengroup.org/bookstore/catalog/c193.htm
 
39
 
 
40
  @see XID in sql/handler.h
 
41
*/
 
42
struct st_mysql_xid {
 
43
  long formatID;
 
44
  long gtrid_length;
 
45
  long bqual_length;
 
46
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
 
47
};
 
48
typedef struct st_mysql_xid DRIZZLE_XID;
42
49
 
43
50
/*************************************************************************
44
51
  Plugin API. Common for all plugin types.
45
52
*/
46
53
 
47
 
 
48
 
class sys_var;
49
 
typedef drizzle_lex_string LEX_STRING;
50
 
struct option;
51
 
 
52
 
extern boost::filesystem::path plugin_dir;
53
 
 
54
 
namespace plugin { class StorageEngine; }
55
 
 
56
 
/*
57
 
  Macros for beginning and ending plugin declarations. Between
58
 
  DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
59
 
  be a module::Manifest for each plugin to be declared.
60
 
*/
61
 
 
62
 
 
63
 
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
64
 
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
65
 
#define DRIZZLE_DECLARE_PLUGIN \
66
 
  ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
67
 
 
68
 
 
69
 
#define DRIZZLE_DECLARE_PLUGIN_END
70
 
#define DRIZZLE_PLUGIN(init,system,options) \
71
 
  DRIZZLE_DECLARE_PLUGIN \
72
 
  { \
73
 
    DRIZZLE_VERSION_ID, \
74
 
    STRINGIFY_ARG(PANDORA_MODULE_NAME), \
75
 
    STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
76
 
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
77
 
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
78
 
    PANDORA_MODULE_LICENSE, \
79
 
    init, system, options \
80
 
  } 
81
 
 
82
 
 
 
54
/*
 
55
  The allowable types of plugins
 
56
*/
 
57
#define DRIZZLE_DAEMON_PLUGIN          0  /* Daemon / Raw */
 
58
#define DRIZZLE_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine */
 
59
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN  2  /* Information Schema */
 
60
#define DRIZZLE_UDF_PLUGIN             3  /* User-Defined Function */
 
61
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate function */
 
62
#define DRIZZLE_AUDIT_PLUGIN           5  /* Audit */
 
63
#define DRIZZLE_LOGGER_PLUGIN          6  /* Logging */
 
64
#define DRIZZLE_AUTH_PLUGIN            7  /* Authorization */
 
65
 
 
66
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
 
67
 
 
68
/* We use the following strings to define licenses for plugins */
 
69
#define PLUGIN_LICENSE_PROPRIETARY 0
 
70
#define PLUGIN_LICENSE_GPL 1
 
71
#define PLUGIN_LICENSE_BSD 2
 
72
 
 
73
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
 
74
#define PLUGIN_LICENSE_GPL_STRING "GPL"
 
75
#define PLUGIN_LICENSE_BSD_STRING "BSD"
 
76
 
 
77
/*
 
78
  Macros for beginning and ending plugin declarations.  Between
 
79
  mysql_declare_plugin and mysql_declare_plugin_end there should
 
80
  be a st_mysql_plugin struct for each plugin to be declared.
 
81
*/
 
82
 
 
83
 
 
84
#ifndef DRIZZLE_DYNAMIC_PLUGIN
 
85
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
86
struct st_mysql_plugin DECLS[]= {
 
87
#else
 
88
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
89
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
90
#endif
 
91
 
 
92
#define mysql_declare_plugin(NAME) \
 
93
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
94
                 builtin_ ## NAME ## _plugin)
 
95
 
 
96
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
97
 
 
98
/*
 
99
  declarations for SHOW STATUS support in plugins
 
100
*/
 
101
enum enum_mysql_show_type
 
102
{
 
103
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
104
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
105
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
106
};
 
107
 
 
108
struct st_mysql_show_var {
 
109
  const char *name;
 
110
  char *value;
 
111
  enum enum_mysql_show_type type;
 
112
};
 
113
 
 
114
 
 
115
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
116
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
117
 
 
118
struct st_show_var_func_container {
 
119
  mysql_show_var_func func;
 
120
};
83
121
/*
84
122
  declarations for server variables and command line options
85
123
*/
90
128
#define PLUGIN_VAR_LONG         0x0003
91
129
#define PLUGIN_VAR_LONGLONG     0x0004
92
130
#define PLUGIN_VAR_STR          0x0005
 
131
#define PLUGIN_VAR_ENUM         0x0006
 
132
#define PLUGIN_VAR_SET          0x0007
93
133
#define PLUGIN_VAR_UNSIGNED     0x0080
94
 
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
 
134
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
95
135
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
96
136
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
97
137
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
100
140
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
101
141
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
102
142
 
103
 
struct drizzle_sys_var;
104
 
struct drizzle_value;
 
143
struct st_mysql_sys_var;
 
144
struct st_mysql_value;
105
145
 
106
146
/*
107
147
  SYNOPSIS
108
148
    (*mysql_var_check_func)()
109
 
      session               thread handle
 
149
      thd               thread handle
110
150
      var               dynamic variable being altered
111
151
      save              pointer to temporary storage
112
152
      value             user provided value
113
153
  RETURN
114
154
    0   user provided value is OK and the update func may be called.
115
155
    any other value indicates error.
116
 
 
 
156
  
117
157
  This function should parse the user provided value and store in the
118
158
  provided temporary storage any data as required by the update func.
119
159
  There is sufficient space in the temporary storage to store a double.
122
162
  automatically at the end of the statement.
123
163
*/
124
164
 
125
 
typedef int (*mysql_var_check_func)(Session *session,
126
 
                                    drizzle_sys_var *var,
127
 
                                    void *save, drizzle_value *value);
 
165
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
166
                                    struct st_mysql_sys_var *var,
 
167
                                    void *save, struct st_mysql_value *value);
128
168
 
129
169
/*
130
170
  SYNOPSIS
131
171
    (*mysql_var_update_func)()
132
 
      session               thread handle
 
172
      thd               thread handle
133
173
      var               dynamic variable being altered
134
174
      var_ptr           pointer to dynamic variable
135
175
      save              pointer to temporary storage
136
176
   RETURN
137
177
     NONE
138
 
 
 
178
   
139
179
   This function should use the validated value stored in the temporary store
140
180
   and persist it in the provided pointer to the dynamic variable.
141
181
   For example, strings may require memory to be allocated.
142
182
*/
143
 
typedef void (*mysql_var_update_func)(Session *session,
144
 
                                      drizzle_sys_var *var,
 
183
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
184
                                      struct st_mysql_sys_var *var,
145
185
                                      void *var_ptr, const void *save);
146
186
 
147
187
 
148
 
 
149
 
/*
150
 
  skeleton of a plugin variable - portion of structure common to all.
151
 
*/
152
 
struct drizzle_sys_var
 
188
/* the following declarations are for internal use only */
 
189
 
 
190
 
 
191
#define PLUGIN_VAR_MASK \
 
192
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
193
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
194
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
195
 
 
196
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
197
  int flags;                    \
 
198
  const char *name;             \
 
199
  const char *comment;          \
 
200
  mysql_var_check_func check;   \
 
201
  mysql_var_update_func update
 
202
 
 
203
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
204
#define DRIZZLE_SYSVAR(name) \
 
205
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
206
 
 
207
/*
 
208
  for global variables, the value pointer is the first
 
209
  element after the header, the default value is the second.
 
210
  for thread variables, the value offset is the first
 
211
  element after the header, the default value is the second.
 
212
*/
 
213
   
 
214
 
 
215
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
216
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
217
  type *value;                  \
 
218
  const type def_val;           \
 
219
} DRIZZLE_SYSVAR_NAME(name)
 
220
 
 
221
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
222
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
223
  type *value; type def_val;    \
 
224
  type min_val; type max_val;   \
 
225
  type blk_sz;                  \
 
226
} DRIZZLE_SYSVAR_NAME(name)
 
227
 
 
228
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
 
229
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
230
  type *value; type def_val;    \
 
231
  TYPELIB *typelib;             \
 
232
} DRIZZLE_SYSVAR_NAME(name)
 
233
 
 
234
#define DECLARE_THDVAR_FUNC(type) \
 
235
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
236
 
 
237
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
 
238
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
239
  int offset;                   \
 
240
  const type def_val;           \
 
241
  DECLARE_THDVAR_FUNC(type);    \
 
242
} DRIZZLE_SYSVAR_NAME(name)
 
243
 
 
244
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
 
245
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
246
  int offset;                   \
 
247
  type def_val; type min_val;   \
 
248
  type max_val; type blk_sz;    \
 
249
  DECLARE_THDVAR_FUNC(type);    \
 
250
} DRIZZLE_SYSVAR_NAME(name)
 
251
 
 
252
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
 
253
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
254
  int offset;                   \
 
255
  type def_val;                 \
 
256
  DECLARE_THDVAR_FUNC(type);    \
 
257
  TYPELIB *typelib;             \
 
258
} DRIZZLE_SYSVAR_NAME(name)
 
259
 
 
260
 
 
261
/*
 
262
  the following declarations are for use by plugin implementors
 
263
*/
 
264
 
 
265
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
266
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
267
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
268
  #name, comment, check, update, &varname, def}
 
269
 
 
270
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
271
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
272
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
273
  #name, comment, check, update, &varname, def}
 
274
 
 
275
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
276
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
277
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
278
  #name, comment, check, update, &varname, def, min, max, blk }
 
279
 
 
280
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
281
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
282
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
283
  #name, comment, check, update, &varname, def, min, max, blk }
 
284
 
 
285
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
286
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
287
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
288
  #name, comment, check, update, &varname, def, min, max, blk }
 
289
 
 
290
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
291
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
292
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
293
  #name, comment, check, update, &varname, def, min, max, blk }
 
294
 
 
295
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
296
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
297
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
298
  #name, comment, check, update, &varname, def, min, max, blk }
 
299
 
 
300
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
301
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
302
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
303
  #name, comment, check, update, &varname, def, min, max, blk }
 
304
 
 
305
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
306
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
307
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
308
  #name, comment, check, update, &varname, def, typelib }
 
309
 
 
310
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
311
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
312
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
313
  #name, comment, check, update, &varname, def, typelib }
 
314
 
 
315
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
 
316
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
 
317
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
318
  #name, comment, check, update, -1, def, NULL}
 
319
 
 
320
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
 
321
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
 
322
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
323
  #name, comment, check, update, -1, def, NULL}
 
324
 
 
325
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
326
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
 
327
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
328
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
329
 
 
330
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
331
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
 
332
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
333
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
334
 
 
335
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
336
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
 
337
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
338
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
339
 
 
340
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
341
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
 
342
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
343
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
344
 
 
345
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
346
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
 
347
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
348
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
349
 
 
350
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
351
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
 
352
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
353
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
354
 
 
355
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
356
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
 
357
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
358
  #name, comment, check, update, -1, def, NULL, typelib }
 
359
 
 
360
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
 
361
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
 
362
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
363
  #name, comment, check, update, -1, def, NULL, typelib }
 
364
 
 
365
/* accessor macros */
 
366
 
 
367
#define SYSVAR(name) \
 
368
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
369
 
 
370
/* when thd == null, result points to global value */
 
371
#define THDVAR(thd, name) \
 
372
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(thd, DRIZZLE_SYSVAR_NAME(name).offset)))
 
373
 
 
374
 
 
375
/*
 
376
  Plugin description structure.
 
377
*/
 
378
 
 
379
struct st_mysql_plugin
153
380
{
 
381
  int type;             /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
 
382
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
 
383
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
 
384
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
 
385
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
 
386
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
 
387
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
 
388
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
 
389
  struct st_mysql_show_var *status_vars;
 
390
  struct st_mysql_sys_var **system_vars;
 
391
  void * __reserved1;   /* reserved for dependency checking             */
154
392
};
155
393
 
156
 
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
157
 
 
158
 
struct drizzle_value
 
394
struct handlerton;
 
395
 
 
396
 
 
397
/*************************************************************************
 
398
  st_mysql_value struct for reading values from mysqld.
 
399
  Used by server variables framework to parse user-provided values.
 
400
  Will be used for arguments when implementing UDFs.
 
401
 
 
402
  Note that val_str() returns a string in temporary memory
 
403
  that will be freed at the end of statement. Copy the string
 
404
  if you need it to persist.
 
405
*/
 
406
 
 
407
#define DRIZZLE_VALUE_TYPE_STRING 0
 
408
#define DRIZZLE_VALUE_TYPE_REAL   1
 
409
#define DRIZZLE_VALUE_TYPE_INT    2
 
410
 
 
411
struct st_mysql_value
159
412
{
160
 
  int (*value_type)(drizzle_value *);
161
 
  const char *(*val_str)(drizzle_value *, char *buffer, int *length);
162
 
  int (*val_real)(drizzle_value *, double *realbuf);
163
 
  int (*val_int)(drizzle_value *, int64_t *intbuf);
 
413
  int (*value_type)(struct st_mysql_value *);
 
414
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
415
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
416
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
164
417
};
165
418
 
166
419
 
168
421
  Miscellaneous functions for plugin implementors
169
422
*/
170
423
 
171
 
extern bool plugin_init(module::Registry &registry,
172
 
                        boost::program_options::options_description &long_options);
173
 
extern bool plugin_finalize(module::Registry &registry);
174
 
extern void my_print_help_inc_plugins(option *options);
175
 
extern bool plugin_is_ready(const LEX_STRING *name, int type);
176
 
extern void plugin_sessionvar_init(Session *session);
177
 
extern void plugin_sessionvar_cleanup(Session *session);
178
 
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
179
 
 
180
 
int session_in_lock_tables(const Session *session);
181
 
int session_tablespace_op(const Session *session);
182
 
void set_session_proc_info(Session *session, const char *info);
183
 
const char *get_session_proc_info(Session *session);
184
 
int64_t session_test_options(const Session *session, int64_t test_options);
185
 
int session_sql_command(const Session *session);
186
 
enum_tx_isolation session_tx_isolation(const Session *session);
187
 
 
188
 
void compose_plugin_add(std::vector<std::string> options);
189
 
void compose_plugin_remove(std::vector<std::string> options);
190
 
void notify_plugin_load(std::string in_plugin_load);
191
 
 
 
424
#ifdef __cplusplus
 
425
extern "C" {
 
426
#endif
 
427
 
 
428
int thd_in_lock_tables(const DRIZZLE_THD thd);
 
429
int thd_tablespace_op(const DRIZZLE_THD thd);
 
430
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
 
431
int thd_sql_command(const DRIZZLE_THD thd);
 
432
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
 
433
int thd_tx_isolation(const DRIZZLE_THD thd);
 
434
/* Increments the row counter, see THD::row_count */
 
435
void thd_inc_row_count(DRIZZLE_THD thd);
192
436
 
193
437
/**
194
438
  Create a temporary file.
200
444
 
201
445
  @param prefix  prefix for temporary file name
202
446
  @retval -1    error
203
 
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
 
447
  @retval >= 0  a file handle that can be passed to dup or my_close
204
448
*/
205
449
int mysql_tmpfile(const char *prefix);
206
450
 
207
 
} /* namespace drizzled */
208
 
 
209
 
#endif /* DRIZZLED_PLUGIN_H */
 
451
/**
 
452
  Check the killed state of a connection
 
453
 
 
454
  @details
 
455
  In MySQL support for the KILL statement is cooperative. The KILL
 
456
  statement only sets a "killed" flag. This function returns the value
 
457
  of that flag.  A thread should check it often, especially inside
 
458
  time-consuming loops, and gracefully abort the operation if it is
 
459
  non-zero.
 
460
 
 
461
  @param thd  user thread connection handle
 
462
  @retval 0  the connection is active
 
463
  @retval 1  the connection has been killed
 
464
*/
 
465
int thd_killed(const DRIZZLE_THD thd);
 
466
 
 
467
 
 
468
/**
 
469
  Return the thread id of a user thread
 
470
 
 
471
  @param thd  user thread connection handle
 
472
  @return  thread id
 
473
*/
 
474
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
475
 
 
476
 
 
477
/**
 
478
  Allocate memory in the connection's local memory pool
 
479
 
 
480
  @details
 
481
  When properly used in place of @c my_malloc(), this can significantly
 
482
  improve concurrency. Don't use this or related functions to allocate
 
483
  large chunks of memory. Use for temporary storage only. The memory
 
484
  will be freed automatically at the end of the statement; no explicit
 
485
  code is required to prevent memory leaks.
 
486
 
 
487
  @see alloc_root()
 
488
*/
 
489
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
 
490
/**
 
491
  @see thd_alloc()
 
492
*/
 
493
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
 
494
/**
 
495
  @see thd_alloc()
 
496
*/
 
497
char *thd_strdup(DRIZZLE_THD thd, const char *str);
 
498
/**
 
499
  @see thd_alloc()
 
500
*/
 
501
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
 
502
/**
 
503
  @see thd_alloc()
 
504
*/
 
505
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
 
506
 
 
507
/**
 
508
  Get the XID for this connection's transaction
 
509
 
 
510
  @param thd  user thread connection handle
 
511
  @param xid  location where identifier is stored
 
512
*/
 
513
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
514
 
 
515
/**
 
516
  Invalidate the query cache for a given table.
 
517
 
 
518
  @param thd         user thread connection handle
 
519
  @param key         databasename\\0tablename\\0
 
520
  @param key_length  length of key in bytes, including the NUL bytes
 
521
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
522
*/
 
523
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
524
                                   const char *key, unsigned int key_length,
 
525
                                   int using_trx);
 
526
 
 
527
#ifdef __cplusplus
 
528
}
 
529
#endif
 
530
 
 
531
#ifdef __cplusplus
 
532
/**
 
533
  Provide a handler data getter to simplify coding
 
534
*/
 
535
inline
 
536
void *
 
537
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
538
{
 
539
  return *thd_ha_data(thd, hton);
 
540
}
 
541
 
 
542
/**
 
543
  Provide a handler data setter to simplify coding
 
544
*/
 
545
inline
 
546
void
 
547
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
548
                const void *ha_data)
 
549
{
 
550
  *thd_ha_data(thd, hton)= (void*) ha_data;
 
551
}
 
552
#endif
 
553
 
 
554
#endif
210
555