1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DRIZZLED_PLUGIN_H
#define DRIZZLED_PLUGIN_H
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include "drizzled/module/manifest.h"
#include "drizzled/module/module.h"
#include "drizzled/plugin/version.h"
#include "drizzled/module/context.h"
#include "drizzled/definitions.h"
#include "drizzled/lex_string.h"
#include "drizzled/sys_var.h"
#include "drizzled/xid.h"
namespace drizzled
{
class Session;
class Item;
struct charset_info_st;
/*************************************************************************
Plugin API. Common for all plugin types.
*/
class sys_var;
typedef drizzle_lex_string LEX_STRING;
struct option;
extern boost::filesystem::path plugin_dir;
namespace plugin { class StorageEngine; }
/*
Macros for beginning and ending plugin declarations. Between
DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
be a module::Manifest for each plugin to be declared.
*/
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
#define DRIZZLE_DECLARE_PLUGIN \
::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)=
#define DRIZZLE_DECLARE_PLUGIN_END
#define DRIZZLE_PLUGIN(init,system,options) \
DRIZZLE_DECLARE_PLUGIN \
{ \
DRIZZLE_VERSION_ID, \
STRINGIFY_ARG(PANDORA_MODULE_NAME), \
STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
PANDORA_MODULE_LICENSE, \
init, system, options \
}
/*
declarations for server variables and command line options
*/
#define PLUGIN_VAR_BOOL 0x0001
#define PLUGIN_VAR_INT 0x0002
#define PLUGIN_VAR_LONG 0x0003
#define PLUGIN_VAR_LONGLONG 0x0004
#define PLUGIN_VAR_STR 0x0005
#define PLUGIN_VAR_UNSIGNED 0x0080
#define PLUGIN_VAR_SessionLOCAL 0x0100 /* Variable is per-connection */
#define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
#define PLUGIN_VAR_NOSYSVAR 0x0400 /* Not a server variable */
#define PLUGIN_VAR_NOCMDOPT 0x0800 /* Not a command line option */
#define PLUGIN_VAR_NOCMDARG 0x1000 /* No argument for cmd line */
#define PLUGIN_VAR_RQCMDARG 0x0000 /* Argument required for cmd line */
#define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */
#define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */
struct drizzle_sys_var;
struct drizzle_value;
/*
SYNOPSIS
(*var_check_func)()
session thread handle
var dynamic variable being altered
save pointer to temporary storage
value user provided value
RETURN
0 user provided value is OK and the update func may be called.
any other value indicates error.
This function should parse the user provided value and store in the
provided temporary storage any data as required by the update func.
There is sufficient space in the temporary storage to store a double.
Note that the update func may not be called if any other error occurs
so any memory allocated should be thread-local so that it may be freed
automatically at the end of the statement.
*/
typedef int (*var_check_func)(Session *session,
drizzle_sys_var *var,
void *save, drizzle_value *value);
/*
SYNOPSIS
(*var_update_func)()
session thread handle
var dynamic variable being altered
var_ptr pointer to dynamic variable
save pointer to temporary storage
RETURN
NONE
This function should use the validated value stored in the temporary store
and persist it in the provided pointer to the dynamic variable.
For example, strings may require memory to be allocated.
*/
typedef void (*var_update_func)(Session *session,
drizzle_sys_var *var,
void *var_ptr, const void *save);
/*
skeleton of a plugin variable - portion of structure common to all.
*/
struct drizzle_sys_var
{
};
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
struct drizzle_value
{
int (*value_type)(drizzle_value *);
const char *(*val_str)(drizzle_value *, char *buffer, int *length);
int (*val_real)(drizzle_value *, double *realbuf);
int (*val_int)(drizzle_value *, int64_t *intbuf);
};
/*************************************************************************
Miscellaneous functions for plugin implementors
*/
extern bool plugin_init(module::Registry ®istry,
boost::program_options::options_description &long_options);
extern bool plugin_finalize(module::Registry ®istry);
extern void my_print_help_inc_plugins(option *options);
extern bool plugin_is_ready(const LEX_STRING *name, int type);
extern void plugin_sessionvar_init(Session *session);
extern void plugin_sessionvar_cleanup(Session *session);
int session_in_lock_tables(const Session *session);
int session_tablespace_op(const Session *session);
void set_session_proc_info(Session *session, const char *info);
const char *get_session_proc_info(Session *session);
int64_t session_test_options(const Session *session, int64_t test_options);
int session_sql_command(const Session *session);
enum_tx_isolation session_tx_isolation(const Session *session);
void compose_plugin_add(std::vector<std::string> options);
void compose_plugin_remove(std::vector<std::string> options);
void notify_plugin_load(std::string in_plugin_load);
/**
Create a temporary file.
@details
The temporary file is created in a location specified by the mysql
server configuration (--tmpdir option). The caller does not need to
delete the file, it will be deleted automatically.
@param prefix prefix for temporary file name
@retval -1 error
@retval >= 0 a file handle that can be passed to dup or internal::my_close
*/
int tmpfile(const char *prefix);
} /* namespace drizzled */
#endif /* DRIZZLED_PLUGIN_H */
|