~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2010-10-07 20:00:40 UTC
  • mto: (1822.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1823.
  • Revision ID: brian@tangent.org-20101007200040-st5l46s5i445vxoz
We no longer needed to look at the share when removing tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef DRIZZLED_PLUGIN_H
21
21
#define DRIZZLED_PLUGIN_H
22
22
 
23
 
#include <boost/program_options.hpp>
24
 
#include <boost/filesystem.hpp>
25
 
 
26
23
#include "drizzled/module/manifest.h"
27
24
#include "drizzled/module/module.h"
28
25
#include "drizzled/plugin/version.h"
30
27
#include "drizzled/definitions.h"
31
28
 
32
29
#include "drizzled/lex_string.h"
33
 
#include "drizzled/sys_var.h"
34
30
#include "drizzled/xid.h"
 
31
#include <boost/program_options.hpp>
35
32
 
36
33
namespace drizzled
37
34
{
49
46
typedef drizzle_lex_string LEX_STRING;
50
47
struct option;
51
48
 
52
 
extern boost::filesystem::path plugin_dir;
 
49
extern char opt_plugin_dir[FN_REFLEN];
53
50
 
54
51
namespace plugin { class StorageEngine; }
55
52
 
81
78
 
82
79
 
83
80
/*
 
81
  declarations for SHOW STATUS support in plugins
 
82
*/
 
83
enum enum_mysql_show_type
 
84
{
 
85
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
86
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
87
  SHOW_FUNC,
 
88
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS,
 
89
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
 
90
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
 
91
};
 
92
 
 
93
struct drizzle_show_var {
 
94
  const char *name;
 
95
  char *value;
 
96
  enum enum_mysql_show_type type;
 
97
};
 
98
 
 
99
typedef enum enum_mysql_show_type SHOW_TYPE;
 
100
 
 
101
 
 
102
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
103
typedef int (*mysql_show_var_func)(drizzle_show_var *, char *);
 
104
 
 
105
struct st_show_var_func_container {
 
106
  mysql_show_var_func func;
 
107
};
 
108
/*
84
109
  declarations for server variables and command line options
85
110
*/
86
111
 
145
170
                                      void *var_ptr, const void *save);
146
171
 
147
172
 
 
173
/* the following declarations are for internal use only */
 
174
 
 
175
 
 
176
#define PLUGIN_VAR_MASK \
 
177
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
178
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
179
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
180
 
 
181
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
182
  int flags;                    \
 
183
  const char *name;             \
 
184
  const char *comment;          \
 
185
  mysql_var_check_func check;   \
 
186
  mysql_var_update_func update
 
187
 
 
188
#define DRIZZLE_SYSVAR_NAME(name) drizzle_sysvar_ ## name
 
189
#define DRIZZLE_SYSVAR(name) \
 
190
  ((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
 
191
 
 
192
/*
 
193
  for global variables, the value pointer is the first
 
194
  element after the header, the default value is the second.
 
195
  for thread variables, the value offset is the first
 
196
  element after the header, the default value is the second.
 
197
*/
 
198
 
 
199
 
 
200
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
201
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
202
  type *value;                  \
 
203
  const type def_val;           \
 
204
} DRIZZLE_SYSVAR_NAME(name)
 
205
 
 
206
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
207
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
208
  type *value; type def_val;    \
 
209
  type min_val; type max_val;   \
 
210
  type blk_sz;                  \
 
211
} DRIZZLE_SYSVAR_NAME(name)
 
212
 
 
213
#define DECLARE_SessionVAR_FUNC(type) \
 
214
  type *(*resolve)(Session *session, int offset)
 
215
 
 
216
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
217
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
218
  int offset;                   \
 
219
  const type def_val;           \
 
220
  DECLARE_SessionVAR_FUNC(type);    \
 
221
} DRIZZLE_SYSVAR_NAME(name)
 
222
 
 
223
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
224
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
225
  int offset;                   \
 
226
  type def_val; type min_val;   \
 
227
  type max_val; type blk_sz;    \
 
228
  DECLARE_SessionVAR_FUNC(type);    \
 
229
} DRIZZLE_SYSVAR_NAME(name)
 
230
 
 
231
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
232
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
233
  int offset;                   \
 
234
  type def_val;                 \
 
235
  DECLARE_SessionVAR_FUNC(type);    \
 
236
  TYPELIB *typelib;             \
 
237
} DRIZZLE_SYSVAR_NAME(name)
 
238
 
 
239
 
 
240
/*
 
241
  the following declarations are for use by plugin implementors
 
242
*/
 
243
 
 
244
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
245
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
246
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
247
  #name, comment, check, update, &varname, def}
 
248
 
 
249
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
250
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
251
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
252
  #name, comment, check, update, &varname, def}
 
253
 
 
254
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
255
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
256
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
257
  #name, comment, check, update, &varname, def, min, max, blk }
 
258
 
 
259
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
260
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
261
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
262
  #name, comment, check, update, &varname, def, min, max, blk }
 
263
 
 
264
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
265
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
266
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
267
  #name, comment, check, update, &varname, def, min, max, blk }
 
268
 
 
269
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
270
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
271
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
272
  #name, comment, check, update, &varname, def, min, max, blk }
 
273
 
 
274
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
275
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
276
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
277
  #name, comment, check, update, &varname, def, min, max, blk }
 
278
 
 
279
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
280
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
281
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
282
  #name, comment, check, update, &varname, def, min, max, blk }
 
283
 
 
284
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
285
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
286
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
287
  #name, comment, check, update, -1, def, NULL}
 
288
 
 
289
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
290
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
291
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
292
  #name, comment, check, update, -1, def, NULL}
 
293
 
 
294
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
295
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
296
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
297
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
298
 
 
299
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
300
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
301
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
302
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
303
 
 
304
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
305
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
306
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
307
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
308
 
 
309
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
310
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
311
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
312
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
313
 
 
314
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
315
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
316
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
317
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
318
 
 
319
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
320
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
321
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
322
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
323
 
 
324
/* accessor macros */
 
325
 
 
326
#define SYSVAR(name) \
 
327
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
328
 
 
329
/* when session == null, result points to global value */
 
330
#define SessionVAR(session, name) \
 
331
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
 
332
 
 
333
 
 
334
/*************************************************************************
 
335
  drizzle_value struct for reading values from mysqld.
 
336
  Used by server variables framework to parse user-provided values.
 
337
  Will be used for arguments when implementing UDFs.
 
338
 
 
339
  Note that val_str() returns a string in temporary memory
 
340
  that will be freed at the end of statement. Copy the string
 
341
  if you need it to persist.
 
342
*/
 
343
 
 
344
#define DRIZZLE_VALUE_TYPE_STRING 0
 
345
#define DRIZZLE_VALUE_TYPE_REAL   1
 
346
#define DRIZZLE_VALUE_TYPE_INT    2
148
347
 
149
348
/*
150
349
  skeleton of a plugin variable - portion of structure common to all.
151
350
*/
152
351
struct drizzle_sys_var
153
352
{
 
353
  DRIZZLE_PLUGIN_VAR_HEADER;
154
354
};
155
355
 
156
356
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
204
404
*/
205
405
int mysql_tmpfile(const char *prefix);
206
406
 
 
407
/**
 
408
  Check the killed state of a connection
 
409
 
 
410
  @details
 
411
  In MySQL support for the KILL statement is cooperative. The KILL
 
412
  statement only sets a "killed" flag. This function returns the value
 
413
  of that flag.  A thread should check it often, especially inside
 
414
  time-consuming loops, and gracefully abort the operation if it is
 
415
  non-zero.
 
416
 
 
417
  @param session  user thread connection handle
 
418
  @retval 0  the connection is active
 
419
  @retval 1  the connection has been killed
 
420
*/
 
421
int session_killed(const Session *session);
 
422
 
 
423
 
 
424
const charset_info_st *session_charset(Session *session);
 
425
 
 
426
/**
 
427
  Invalidate the query cache for a given table.
 
428
 
 
429
  @param session         user thread connection handle
 
430
  @param key         databasename\\0tablename\\0
 
431
  @param key_length  length of key in bytes, including the NUL bytes
 
432
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
433
*/
 
434
void mysql_query_cache_invalidate4(Session *session,
 
435
                                   const char *key, unsigned int key_length,
 
436
                                   int using_trx);
 
437
 
207
438
} /* namespace drizzled */
208
439
 
209
440
#endif /* DRIZZLED_PLUGIN_H */