~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2009-08-04 06:21:17 UTC
  • mfrom: (1108.2.2 merge)
  • Revision ID: brian@gaz-20090804062117-fef8x6y3ydzrvab3
Merge Brian

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