20
20
#ifndef DRIZZLED_PLUGIN_H
21
21
#define DRIZZLED_PLUGIN_H
23
#include <boost/program_options.hpp>
24
#include <boost/filesystem.hpp>
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"
32
#include "drizzled/lex_string.h"
33
#include "drizzled/sys_var.h"
34
#include "drizzled/xid.h"
23
#include <drizzled/lex_string.h>
24
#include <drizzled/xid.h>
41
struct charset_info_st;
43
29
/*************************************************************************
44
30
Plugin API. Common for all plugin types.
49
typedef drizzle_lex_string LEX_STRING;
52
extern boost::filesystem::path plugin_dir;
54
namespace plugin { class StorageEngine; }
34
/* We use the following strings to define licenses for plugins */
35
enum plugin_license_type {
36
PLUGIN_LICENSE_PROPRIETARY,
40
PLUGIN_LICENSE_MAX=PLUGIN_LICENSE_LGPL
43
const char * const PLUGIN_LICENSE_PROPRIETARY_STRING="PROPRIETARY";
44
const char * const PLUGIN_LICENSE_GPL_STRING="GPL";
45
const char * const PLUGIN_LICENSE_BSD_STRING="BSD";
46
const char * const PLUGIN_LICENSE_LGPL_STRING="LGPL";
57
49
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.
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)=
69
#define DRIZZLE_DECLARE_PLUGIN_END
70
#define DRIZZLE_PLUGIN(init,system,options) \
71
DRIZZLE_DECLARE_PLUGIN \
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 \
50
drizzle_declare_plugin and drizzle_declare_plugin_end there should
51
be a drizzled_plugin_manifest struct for each plugin to be declared.
55
#ifndef DRIZZLE_DYNAMIC_PLUGIN
56
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
57
struct drizzled_plugin_manifest DECLS[]= {
59
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
60
struct drizzled_plugin_manifest _mysql_plugin_declarations_[]= {
63
#define drizzle_declare_plugin(NAME) \
64
__DRIZZLE_DECLARE_PLUGIN(NAME, \
65
builtin_ ## NAME ## _plugin)
67
#define drizzle_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0}}
70
the following flags are valid for plugin_init()
72
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
73
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
74
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
76
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
79
declarations for SHOW STATUS support in plugins
81
enum enum_mysql_show_type
83
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
84
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
85
SHOW_ARRAY, SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
86
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE,
87
SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
88
SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
91
struct st_mysql_show_var {
94
enum enum_mysql_show_type type;
97
typedef enum enum_mysql_show_type SHOW_TYPE;
98
typedef struct st_mysql_show_var SHOW_VAR;
101
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
102
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
104
struct st_show_var_func_container {
105
mysql_show_var_func func;
84
108
declarations for server variables and command line options
141
167
For example, strings may require memory to be allocated.
143
169
typedef void (*mysql_var_update_func)(Session *session,
144
drizzle_sys_var *var,
170
struct st_mysql_sys_var *var,
145
171
void *var_ptr, const void *save);
150
skeleton of a plugin variable - portion of structure common to all.
152
struct drizzle_sys_var
174
/* the following declarations are for internal use only */
177
#define PLUGIN_VAR_MASK \
178
(PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
179
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
180
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
182
#define DRIZZLE_PLUGIN_VAR_HEADER \
185
const char *comment; \
186
mysql_var_check_func check; \
187
mysql_var_update_func update
189
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
190
#define DRIZZLE_SYSVAR(name) \
191
((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
194
for global variables, the value pointer is the first
195
element after the header, the default value is the second.
196
for thread variables, the value offset is the first
197
element after the header, the default value is the second.
201
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
202
DRIZZLE_PLUGIN_VAR_HEADER; \
204
const type def_val; \
205
} DRIZZLE_SYSVAR_NAME(name)
207
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
208
DRIZZLE_PLUGIN_VAR_HEADER; \
209
type *value; type def_val; \
210
type min_val; type max_val; \
212
} DRIZZLE_SYSVAR_NAME(name)
214
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
215
DRIZZLE_PLUGIN_VAR_HEADER; \
216
type *value; type def_val; \
218
} DRIZZLE_SYSVAR_NAME(name)
220
#define DECLARE_SessionVAR_FUNC(type) \
221
type *(*resolve)(Session *session, int offset)
223
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
224
DRIZZLE_PLUGIN_VAR_HEADER; \
226
const type def_val; \
227
DECLARE_SessionVAR_FUNC(type); \
228
} DRIZZLE_SYSVAR_NAME(name)
230
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
231
DRIZZLE_PLUGIN_VAR_HEADER; \
233
type def_val; type min_val; \
234
type max_val; type blk_sz; \
235
DECLARE_SessionVAR_FUNC(type); \
236
} DRIZZLE_SYSVAR_NAME(name)
238
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
239
DRIZZLE_PLUGIN_VAR_HEADER; \
242
DECLARE_SessionVAR_FUNC(type); \
244
} DRIZZLE_SYSVAR_NAME(name)
248
the following declarations are for use by plugin implementors
251
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
252
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
253
PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
254
#name, comment, check, update, &varname, def}
256
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
257
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
258
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
259
#name, comment, check, update, &varname, def}
261
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
262
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
263
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
264
#name, comment, check, update, &varname, def, min, max, blk }
266
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
267
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
268
PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
269
#name, comment, check, update, &varname, def, min, max, blk }
271
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
272
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
273
PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
274
#name, comment, check, update, &varname, def, min, max, blk }
276
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
277
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
278
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
279
#name, comment, check, update, &varname, def, min, max, blk }
281
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
282
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
283
PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
284
#name, comment, check, update, &varname, def, min, max, blk }
286
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
287
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
288
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
289
#name, comment, check, update, &varname, def, min, max, blk }
291
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
292
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
293
PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
294
#name, comment, check, update, &varname, def, typelib }
296
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
297
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
298
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
299
#name, comment, check, update, &varname, def, typelib }
301
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
302
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
303
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
304
#name, comment, check, update, -1, def, NULL}
306
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
307
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
308
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
309
#name, comment, check, update, -1, def, NULL}
311
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
312
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
313
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
314
#name, comment, check, update, -1, def, min, max, blk, NULL }
316
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
317
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
318
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
319
#name, comment, check, update, -1, def, min, max, blk, NULL }
321
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
322
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
323
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
324
#name, comment, check, update, -1, def, min, max, blk, NULL }
326
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
327
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
328
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
329
#name, comment, check, update, -1, def, min, max, blk, NULL }
331
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
332
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
333
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
334
#name, comment, check, update, -1, def, min, max, blk, NULL }
336
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
337
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
338
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
339
#name, comment, check, update, -1, def, min, max, blk, NULL }
341
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
342
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
343
PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
344
#name, comment, check, update, -1, def, NULL, typelib }
346
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
347
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
348
PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
349
#name, comment, check, update, -1, def, NULL, typelib }
351
/* accessor macros */
353
#define SYSVAR(name) \
354
(*(DRIZZLE_SYSVAR_NAME(name).value))
356
/* when session == null, result points to global value */
357
#define SessionVAR(session, name) \
358
(*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
361
struct StorageEngine;
370
std::string description;
373
Plugin(std::string in_name, std::string in_version,
374
std::string in_author, std::string in_description)
375
: name(in_name), version(in_version),
376
author(in_author), description(in_description)
381
virtual void add_functions() {}
156
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
385
/*************************************************************************
386
st_mysql_value struct for reading values from mysqld.
387
Used by server variables framework to parse user-provided values.
388
Will be used for arguments when implementing UDFs.
390
Note that val_str() returns a string in temporary memory
391
that will be freed at the end of statement. Copy the string
392
if you need it to persist.
395
#define DRIZZLE_VALUE_TYPE_STRING 0
396
#define DRIZZLE_VALUE_TYPE_REAL 1
397
#define DRIZZLE_VALUE_TYPE_INT 2
399
struct st_mysql_value
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);
401
int (*value_type)(struct st_mysql_value *);
402
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
403
int (*val_real)(struct st_mysql_value *, double *realbuf);
404
int (*val_int)(struct st_mysql_value *, int64_t *intbuf);