~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2009-05-30 22:30:05 UTC
  • mto: This revision was merged to the branch mainline in revision 1045.
  • Revision ID: brian@gaz-20090530223005-hmylm6iywddfentm
A lot of little cleanups (most based off lcov)

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