23
23
#include <drizzled/lex_string.h>
24
24
#include <drizzled/xid.h>
25
#include <drizzled/plugin/manifest.h>
26
#include <drizzled/plugin/module.h>
27
#include "drizzled/plugin/version.h"
28
#include "drizzled/definitions.h"
29
#include "drizzled/plugin/context.h"
45
typedef drizzle_lex_string LEX_STRING;
48
extern char *opt_plugin_add;
49
extern char *opt_plugin_remove;
50
extern char *opt_plugin_load;
51
extern char *opt_plugin_dir_ptr;
52
extern char opt_plugin_dir[FN_REFLEN];
54
namespace plugin { class StorageEngine; }
36
57
Macros for beginning and ending plugin declarations. Between
37
drizzle_declare_plugin and drizzle_declare_plugin_end there should
38
be a drizzled::plugin::Manifest for each plugin to be declared.
42
#ifndef PANDORA_DYNAMIC_PLUGIN
43
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
44
drizzled::plugin::Manifest DECLS[]= {
46
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
47
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
50
#define drizzle_declare_plugin(NAME) \
51
__DRIZZLE_DECLARE_PLUGIN(NAME, \
52
builtin_ ## NAME ## _plugin)
54
#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
59
the following flags are valid for plugin_init()
61
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
62
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
63
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
65
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
58
DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
59
be a plugin::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::plugin::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)=
69
#define DRIZZLE_DECLARE_PLUGIN_END
70
#define DRIZZLE_PLUGIN(init,system) \
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, \
68
84
declarations for SHOW STATUS support in plugins
72
88
SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
73
89
SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
74
SHOW_ARRAY, SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
75
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE,
90
SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
91
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS,
76
92
SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
77
93
SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
80
struct st_mysql_show_var {
96
struct drizzle_show_var {
83
99
enum enum_mysql_show_type type;
86
102
typedef enum enum_mysql_show_type SHOW_TYPE;
87
typedef struct st_mysql_show_var SHOW_VAR;
90
105
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
91
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
106
typedef int (*mysql_show_var_func)(drizzle_show_var *, char *);
93
108
struct st_show_var_func_container {
94
109
mysql_show_var_func func;
103
118
#define PLUGIN_VAR_LONG 0x0003
104
119
#define PLUGIN_VAR_LONGLONG 0x0004
105
120
#define PLUGIN_VAR_STR 0x0005
106
#define PLUGIN_VAR_ENUM 0x0006
107
#define PLUGIN_VAR_SET 0x0007
108
121
#define PLUGIN_VAR_UNSIGNED 0x0080
109
122
#define PLUGIN_VAR_SessionLOCAL 0x0100 /* Variable is per-connection */
110
123
#define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
201
214
} DRIZZLE_SYSVAR_NAME(name)
203
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
204
DRIZZLE_PLUGIN_VAR_HEADER; \
205
type *value; type def_val; \
207
} DRIZZLE_SYSVAR_NAME(name)
209
216
#define DECLARE_SessionVAR_FUNC(type) \
210
217
type *(*resolve)(Session *session, int offset)
277
284
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
278
285
#name, comment, check, update, &varname, def, min, max, blk }
280
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
281
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
282
PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
283
#name, comment, check, update, &varname, def, typelib }
285
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
286
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
287
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
288
#name, comment, check, update, &varname, def, typelib }
290
287
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
291
288
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
292
289
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
327
324
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
328
325
#name, comment, check, update, -1, def, min, max, blk, NULL }
330
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
331
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
332
PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
333
#name, comment, check, update, -1, def, NULL, typelib }
335
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
336
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
337
PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
338
#name, comment, check, update, -1, def, NULL, typelib }
340
327
/* accessor macros */
342
329
#define SYSVAR(name) \
347
334
(*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
350
struct StorageEngine;
359
std::string description;
362
Plugin(std::string in_name, std::string in_version,
363
std::string in_author, std::string in_description)
364
: name(in_name), version(in_version),
365
author(in_author), description(in_description)
370
virtual void add_functions() {}
374
337
/*************************************************************************
375
st_mysql_value struct for reading values from mysqld.
338
drizzle_value struct for reading values from mysqld.
376
339
Used by server variables framework to parse user-provided values.
377
340
Will be used for arguments when implementing UDFs.
385
348
#define DRIZZLE_VALUE_TYPE_REAL 1
386
349
#define DRIZZLE_VALUE_TYPE_INT 2
388
struct st_mysql_value
390
int (*value_type)(struct st_mysql_value *);
391
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
392
int (*val_real)(struct st_mysql_value *, double *realbuf);
393
int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
352
skeleton of a plugin variable - portion of structure common to all.
354
struct drizzle_sys_var
356
DRIZZLE_PLUGIN_VAR_HEADER;
359
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
363
int (*value_type)(drizzle_value *);
364
const char *(*val_str)(drizzle_value *, char *buffer, int *length);
365
int (*val_real)(drizzle_value *, double *realbuf);
366
int (*val_int)(drizzle_value *, int64_t *intbuf);
378
extern bool plugin_init(plugin::Registry ®istry,
379
int *argc, char **argv,
381
extern void plugin_shutdown(plugin::Registry &plugins);
382
extern void my_print_help_inc_plugins(option *options);
383
extern bool plugin_is_ready(const LEX_STRING *name, int type);
384
extern void plugin_sessionvar_init(Session *session);
385
extern void plugin_sessionvar_cleanup(Session *session);
386
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
405
388
int session_in_lock_tables(const Session *session);
406
389
int session_tablespace_op(const Session *session);
407
390
void set_session_proc_info(Session *session, const char *info);
408
391
const char *get_session_proc_info(Session *session);
409
392
int64_t session_test_options(const Session *session, int64_t test_options);
410
393
int session_sql_command(const Session *session);
411
void **session_ha_data(const Session *session, const struct StorageEngine *engine);
412
394
int session_tx_isolation(const Session *session);
413
/* Increments the row counter, see Session::row_count */
414
void session_inc_row_count(Session *session);
416
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
417
const char *str, unsigned int size,
418
int allocate_lex_string);
523
Provide a handler data getter to simplify coding
527
session_get_ha_data(const Session *session, const struct StorageEngine *engine)
529
return *session_ha_data(session, engine);
533
Provide a handler data setter to simplify coding
537
session_set_ha_data(const Session *session, const struct StorageEngine *engine,
540
*session_ha_data(session, engine)= (void*) ha_data;
544
#endif /* _my_plugin_h */
496
} /* namespace drizzled */
498
#endif /* DRIZZLED_PLUGIN_H */