~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Monty Taylor
  • Date: 2008-12-18 07:42:01 UTC
  • mto: This revision was merged to the branch mainline in revision 714.
  • Revision ID: monty@inaugust.com-20081218074201-4m7d63t72qfuplwx
Fixed max() problem for solaris

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; }
56
 
 
57
 
/*
58
 
  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
 
 
 
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_MAX=PLUGIN_LICENSE_BSD
 
64
};
 
65
 
 
66
const char * const PLUGIN_LICENSE_PROPRIETARY_STRING="PROPRIETARY";
 
67
const char * const PLUGIN_LICENSE_GPL_STRING="GPL";
 
68
const char * const PLUGIN_LICENSE_BSD_STRING="BSD";
 
69
 
 
70
/*
 
71
  Macros for beginning and ending plugin declarations.  Between
 
72
  mysql_declare_plugin and mysql_declare_plugin_end there should
 
73
  be a st_mysql_plugin struct for each plugin to be declared.
 
74
*/
 
75
 
 
76
 
 
77
#ifndef DRIZZLE_DYNAMIC_PLUGIN
 
78
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
79
struct st_mysql_plugin DECLS[]= {
 
80
#else
 
81
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
82
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
83
#endif
 
84
 
 
85
#define mysql_declare_plugin(NAME) \
 
86
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
87
                 builtin_ ## NAME ## _plugin)
 
88
 
 
89
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
90
 
 
91
/*
 
92
  declarations for SHOW STATUS support in plugins
 
93
*/
 
94
enum enum_mysql_show_type
 
95
{
 
96
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
97
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
98
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, SHOW_SIZE
 
99
};
 
100
 
 
101
struct st_mysql_show_var {
 
102
  const char *name;
 
103
  char *value;
 
104
  enum enum_mysql_show_type type;
 
105
};
 
106
 
 
107
 
 
108
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
109
typedef int (*mysql_show_var_func)(Session *, struct st_mysql_show_var *, char *);
 
110
 
 
111
struct st_show_var_func_container {
 
112
  mysql_show_var_func func;
 
113
};
86
114
/*
87
115
  declarations for server variables and command line options
88
116
*/
93
121
#define PLUGIN_VAR_LONG         0x0003
94
122
#define PLUGIN_VAR_LONGLONG     0x0004
95
123
#define PLUGIN_VAR_STR          0x0005
 
124
#define PLUGIN_VAR_ENUM         0x0006
 
125
#define PLUGIN_VAR_SET          0x0007
96
126
#define PLUGIN_VAR_UNSIGNED     0x0080
97
127
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
98
128
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
103
133
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
104
134
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
105
135
 
106
 
struct drizzle_sys_var;
107
 
struct drizzle_value;
 
136
struct st_mysql_sys_var;
 
137
struct st_mysql_value;
108
138
 
109
139
/*
110
140
  SYNOPSIS
111
 
    (*var_check_func)()
 
141
    (*mysql_var_check_func)()
112
142
      session               thread handle
113
143
      var               dynamic variable being altered
114
144
      save              pointer to temporary storage
125
155
  automatically at the end of the statement.
126
156
*/
127
157
 
128
 
typedef int (*var_check_func)(Session *session,
129
 
                                    drizzle_sys_var *var,
130
 
                                    void *save, drizzle_value *value);
 
158
typedef int (*mysql_var_check_func)(Session *session,
 
159
                                    struct st_mysql_sys_var *var,
 
160
                                    void *save, struct st_mysql_value *value);
131
161
 
132
162
/*
133
163
  SYNOPSIS
134
 
    (*var_update_func)()
 
164
    (*mysql_var_update_func)()
135
165
      session               thread handle
136
166
      var               dynamic variable being altered
137
167
      var_ptr           pointer to dynamic variable
143
173
   and persist it in the provided pointer to the dynamic variable.
144
174
   For example, strings may require memory to be allocated.
145
175
*/
146
 
typedef void (*var_update_func)(Session *session,
147
 
                                      drizzle_sys_var *var,
 
176
typedef void (*mysql_var_update_func)(Session *session,
 
177
                                      struct st_mysql_sys_var *var,
148
178
                                      void *var_ptr, const void *save);
149
179
 
150
180
 
151
 
 
152
 
/*
153
 
  skeleton of a plugin variable - portion of structure common to all.
154
 
*/
155
 
struct drizzle_sys_var
 
181
/* the following declarations are for internal use only */
 
182
 
 
183
 
 
184
#define PLUGIN_VAR_MASK \
 
185
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
186
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
187
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
188
 
 
189
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
190
  int flags;                    \
 
191
  const char *name;             \
 
192
  const char *comment;          \
 
193
  mysql_var_check_func check;   \
 
194
  mysql_var_update_func update
 
195
 
 
196
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
197
#define DRIZZLE_SYSVAR(name) \
 
198
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
199
 
 
200
/*
 
201
  for global variables, the value pointer is the first
 
202
  element after the header, the default value is the second.
 
203
  for thread variables, the value offset is the first
 
204
  element after the header, the default value is the second.
 
205
*/
 
206
 
 
207
 
 
208
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
209
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
210
  type *value;                  \
 
211
  const type def_val;           \
 
212
} DRIZZLE_SYSVAR_NAME(name)
 
213
 
 
214
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
215
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
216
  type *value; type def_val;    \
 
217
  type min_val; type max_val;   \
 
218
  type blk_sz;                  \
 
219
} DRIZZLE_SYSVAR_NAME(name)
 
220
 
 
221
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
 
222
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
223
  type *value; type def_val;    \
 
224
  TYPELIB *typelib;             \
 
225
} DRIZZLE_SYSVAR_NAME(name)
 
226
 
 
227
#define DECLARE_SessionVAR_FUNC(type) \
 
228
  type *(*resolve)(Session *session, int offset)
 
229
 
 
230
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
231
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
232
  int offset;                   \
 
233
  const type def_val;           \
 
234
  DECLARE_SessionVAR_FUNC(type);    \
 
235
} DRIZZLE_SYSVAR_NAME(name)
 
236
 
 
237
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
238
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
239
  int offset;                   \
 
240
  type def_val; type min_val;   \
 
241
  type max_val; type blk_sz;    \
 
242
  DECLARE_SessionVAR_FUNC(type);    \
 
243
} DRIZZLE_SYSVAR_NAME(name)
 
244
 
 
245
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
246
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
247
  int offset;                   \
 
248
  type def_val;                 \
 
249
  DECLARE_SessionVAR_FUNC(type);    \
 
250
  TYPELIB *typelib;             \
 
251
} DRIZZLE_SYSVAR_NAME(name)
 
252
 
 
253
 
 
254
/*
 
255
  the following declarations are for use by plugin implementors
 
256
*/
 
257
 
 
258
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
259
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
260
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
261
  #name, comment, check, update, &varname, def}
 
262
 
 
263
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
264
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
265
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
266
  #name, comment, check, update, &varname, def}
 
267
 
 
268
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
269
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
270
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
271
  #name, comment, check, update, &varname, def, min, max, blk }
 
272
 
 
273
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
274
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
275
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
276
  #name, comment, check, update, &varname, def, min, max, blk }
 
277
 
 
278
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
279
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
280
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
281
  #name, comment, check, update, &varname, def, min, max, blk }
 
282
 
 
283
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
284
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
285
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
286
  #name, comment, check, update, &varname, def, min, max, blk }
 
287
 
 
288
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
289
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
290
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
291
  #name, comment, check, update, &varname, def, min, max, blk }
 
292
 
 
293
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
294
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
295
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
296
  #name, comment, check, update, &varname, def, min, max, blk }
 
297
 
 
298
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
299
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
300
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
301
  #name, comment, check, update, &varname, def, typelib }
 
302
 
 
303
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
304
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
305
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
306
  #name, comment, check, update, &varname, def, typelib }
 
307
 
 
308
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
309
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
310
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
311
  #name, comment, check, update, -1, def, NULL}
 
312
 
 
313
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
314
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
315
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
316
  #name, comment, check, update, -1, def, NULL}
 
317
 
 
318
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
319
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
320
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
321
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
322
 
 
323
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
324
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
325
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
326
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
327
 
 
328
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
329
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
330
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
331
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
332
 
 
333
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
334
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
335
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
336
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
337
 
 
338
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
339
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
340
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
341
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
342
 
 
343
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
344
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
345
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
346
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
347
 
 
348
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
349
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
 
350
  PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
351
  #name, comment, check, update, -1, def, NULL, typelib }
 
352
 
 
353
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
 
354
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
 
355
  PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
356
  #name, comment, check, update, -1, def, NULL, typelib }
 
357
 
 
358
/* accessor macros */
 
359
 
 
360
#define SYSVAR(name) \
 
361
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
362
 
 
363
/* when session == null, result points to global value */
 
364
#define SessionVAR(session, name) \
 
365
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
 
366
 
 
367
 
 
368
/*
 
369
  Plugin description structure.
 
370
*/
 
371
 
 
372
struct st_mysql_plugin
156
373
{
 
374
  uint32_t type;        /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
 
375
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
 
376
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
 
377
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
 
378
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
 
379
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
 
380
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
 
381
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
 
382
  struct st_mysql_show_var *status_vars;
 
383
  struct st_mysql_sys_var **system_vars;
 
384
  void *reserved1;   /* reserved for dependency checking             */
157
385
};
158
386
 
159
 
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
160
 
 
161
 
struct drizzle_value
 
387
struct handlerton;
 
388
 
 
389
 
 
390
/*************************************************************************
 
391
  st_mysql_value struct for reading values from mysqld.
 
392
  Used by server variables framework to parse user-provided values.
 
393
  Will be used for arguments when implementing UDFs.
 
394
 
 
395
  Note that val_str() returns a string in temporary memory
 
396
  that will be freed at the end of statement. Copy the string
 
397
  if you need it to persist.
 
398
*/
 
399
 
 
400
#define DRIZZLE_VALUE_TYPE_STRING 0
 
401
#define DRIZZLE_VALUE_TYPE_REAL   1
 
402
#define DRIZZLE_VALUE_TYPE_INT    2
 
403
 
 
404
struct st_mysql_value
162
405
{
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);
 
406
  int (*value_type)(struct st_mysql_value *);
 
407
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
408
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
409
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
167
410
};
168
411
 
169
412
 
171
414
  Miscellaneous functions for plugin implementors
172
415
*/
173
416
 
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);
 
417
#ifdef __cplusplus
 
418
extern "C" {
 
419
#endif
182
420
 
183
421
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);
 
422
int session_tablespace_op(const Session *session);
 
423
void set_session_proc_info(Session *session, const char *info);
 
424
const char *get_session_proc_info(Session *session);
 
425
int64_t session_test_options(const Session *session, int64_t test_options);
 
426
int session_sql_command(const Session *session);
 
427
void **session_ha_data(const Session *session, const struct handlerton *hton);
 
428
int session_tx_isolation(const Session *session);
 
429
/* Increments the row counter, see Session::row_count */
 
430
void session_inc_row_count(Session *session);
 
431
 
 
432
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
 
433
                                    const char *str, unsigned int size,
 
434
                                    int allocate_lex_string);
 
435
 
188
436
 
189
437
 
190
438
/**
197
445
 
198
446
  @param prefix  prefix for temporary file name
199
447
  @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 */
 
448
  @retval >= 0  a file handle that can be passed to dup or my_close
 
449
*/
 
450
int mysql_tmpfile(const char *prefix);
 
451
 
 
452
/**
 
453
  Check the killed state of a connection
 
454
 
 
455
  @details
 
456
  In MySQL support for the KILL statement is cooperative. The KILL
 
457
  statement only sets a "killed" flag. This function returns the value
 
458
  of that flag.  A thread should check it often, especially inside
 
459
  time-consuming loops, and gracefully abort the operation if it is
 
460
  non-zero.
 
461
 
 
462
  @param session  user thread connection handle
 
463
  @retval 0  the connection is active
 
464
  @retval 1  the connection has been killed
 
465
*/
 
466
int session_killed(const Session *session);
 
467
 
 
468
 
 
469
/**
 
470
  Return the thread id of a user thread
 
471
 
 
472
  @param session  user thread connection handle
 
473
  @return  thread id
 
474
*/
 
475
unsigned long session_get_thread_id(const Session *session);
 
476
 
 
477
 
 
478
/**
 
479
  Allocate memory in the connection's local memory pool
 
480
 
 
481
  @details
 
482
  When properly used in place of @c malloc(), this can significantly
 
483
  improve concurrency. Don't use this or related functions to allocate
 
484
  large chunks of memory. Use for temporary storage only. The memory
 
485
  will be freed automatically at the end of the statement; no explicit
 
486
  code is required to prevent memory leaks.
 
487
 
 
488
  @see alloc_root()
 
489
*/
 
490
void *session_alloc(Session *session, unsigned int size);
 
491
/**
 
492
  @see session_alloc()
 
493
*/
 
494
void *session_calloc(Session *session, unsigned int size);
 
495
/**
 
496
  @see session_alloc()
 
497
*/
 
498
char *session_strdup(Session *session, const char *str);
 
499
/**
 
500
  @see session_alloc()
 
501
*/
 
502
char *session_strmake(Session *session, const char *str, unsigned int size);
 
503
/**
 
504
  @see session_alloc()
 
505
*/
 
506
void *session_memdup(Session *session, const void* str, unsigned int size);
 
507
 
 
508
/**
 
509
  Get the XID for this connection's transaction
 
510
 
 
511
  @param session  user thread connection handle
 
512
  @param xid  location where identifier is stored
 
513
*/
 
514
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
 
515
 
 
516
/**
 
517
  Invalidate the query cache for a given table.
 
518
 
 
519
  @param session         user thread connection handle
 
520
  @param key         databasename\\0tablename\\0
 
521
  @param key_length  length of key in bytes, including the NUL bytes
 
522
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
523
*/
 
524
void mysql_query_cache_invalidate4(Session *session,
 
525
                                   const char *key, unsigned int key_length,
 
526
                                   int using_trx);
 
527
 
 
528
#ifdef __cplusplus
 
529
}
 
530
#endif
 
531
 
 
532
#ifdef __cplusplus
 
533
/**
 
534
  Provide a handler data getter to simplify coding
 
535
*/
 
536
inline
 
537
void *
 
538
session_get_ha_data(const Session *session, const struct handlerton *hton)
 
539
{
 
540
  return *session_ha_data(session, hton);
 
541
}
 
542
 
 
543
/**
 
544
  Provide a handler data setter to simplify coding
 
545
*/
 
546
inline
 
547
void
 
548
session_set_ha_data(const Session *session, const struct handlerton *hton,
 
549
                const void *ha_data)
 
550
{
 
551
  *session_ha_data(session, hton)= (void*) ha_data;
 
552
}
 
553
#endif
 
554
 
 
555
#endif /* _my_plugin_h */
207
556