~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Mark Atwood
  • Date: 2009-03-04 01:02:00 UTC
  • mto: (968.2.20 mordred)
  • mto: This revision was merged to the branch mainline in revision 971.
  • Revision ID: me@mark.atwood.name-20090304010200-t1n4xxdoil2yae9a
add gearman logging plugin

Show diffs side-by-side

added added

removed removed

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