~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Andrew Hutchings
  • Date: 2010-11-01 22:14:18 UTC
  • mto: This revision was merged to the branch mainline in revision 1907.
  • Revision ID: andrew@linuxjedi.co.uk-20101101221418-9n9gmm4ms7fl8vo5
Fix copyright

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 <drizzled/lex_string.h>
24
 
#include <drizzled/xid.h>
25
 
#include <drizzled/plugin/manifest.h>
26
 
#include <drizzled/plugin/module.h>
 
23
#include <boost/program_options.hpp>
 
24
#include <boost/filesystem.hpp>
 
25
 
 
26
#include "drizzled/module/manifest.h"
 
27
#include "drizzled/module/module.h"
27
28
#include "drizzled/plugin/version.h"
 
29
#include "drizzled/module/context.h"
28
30
#include "drizzled/definitions.h"
29
 
#include "drizzled/plugin/context.h"
30
31
 
 
32
#include "drizzled/lex_string.h"
 
33
#include "drizzled/sys_var.h"
 
34
#include "drizzled/xid.h"
31
35
 
32
36
namespace drizzled
33
37
{
45
49
typedef drizzle_lex_string LEX_STRING;
46
50
struct option;
47
51
 
48
 
extern char *opt_plugin_add;
49
 
extern char *opt_plugin_remove;
50
 
extern char *opt_plugin_load;
51
 
extern char *opt_plugin_dir_ptr;
52
 
extern char opt_plugin_dir[FN_REFLEN];
 
52
extern boost::filesystem::path plugin_dir;
53
53
 
54
54
namespace plugin { class StorageEngine; }
55
55
 
56
56
/*
57
57
  Macros for beginning and ending plugin declarations. Between
58
58
  DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
59
 
  be a plugin::Manifest for each plugin to be declared.
 
59
  be a module::Manifest for each plugin to be declared.
60
60
*/
61
61
 
62
62
 
63
63
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
64
64
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
65
65
#define DRIZZLE_DECLARE_PLUGIN \
66
 
  ::drizzled::plugin::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
 
66
  ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
67
67
 
68
68
 
69
69
#define DRIZZLE_DECLARE_PLUGIN_END
70
 
#define DRIZZLE_PLUGIN(init,system) \
 
70
#define DRIZZLE_PLUGIN(init,system,options) \
71
71
  DRIZZLE_DECLARE_PLUGIN \
72
72
  { \
73
73
    DRIZZLE_VERSION_ID, \
76
76
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
77
77
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
78
78
    PANDORA_MODULE_LICENSE, \
79
 
    init, system, NULL \
 
79
    init, system, options \
80
80
  } 
81
81
 
82
82
 
83
83
/*
84
 
  declarations for SHOW STATUS support in plugins
85
 
*/
86
 
enum enum_mysql_show_type
87
 
{
88
 
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
89
 
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
90
 
  SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
91
 
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS,
92
 
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
93
 
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
94
 
};
95
 
 
96
 
struct drizzle_show_var {
97
 
  const char *name;
98
 
  char *value;
99
 
  enum enum_mysql_show_type type;
100
 
};
101
 
 
102
 
typedef enum enum_mysql_show_type SHOW_TYPE;
103
 
 
104
 
 
105
 
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
106
 
typedef int (*mysql_show_var_func)(drizzle_show_var *, char *);
107
 
 
108
 
struct st_show_var_func_container {
109
 
  mysql_show_var_func func;
110
 
};
111
 
/*
112
84
  declarations for server variables and command line options
113
85
*/
114
86
 
188
160
  mysql_var_check_func check;   \
189
161
  mysql_var_update_func update
190
162
 
191
 
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
163
#define DRIZZLE_SYSVAR_NAME(name) drizzle_sysvar_ ## name
192
164
#define DRIZZLE_SYSVAR(name) \
193
165
  ((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
194
166
 
200
172
*/
201
173
 
202
174
 
 
175
#define DECLARE_DRIZZLE_SYSVAR_BOOL(name) struct { \
 
176
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
177
  bool *value;                  \
 
178
  bool def_val;           \
 
179
} DRIZZLE_SYSVAR_NAME(name)
 
180
 
203
181
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
204
182
  DRIZZLE_PLUGIN_VAR_HEADER;      \
205
183
  type *value;                  \
223
201
  DECLARE_SessionVAR_FUNC(type);    \
224
202
} DRIZZLE_SYSVAR_NAME(name)
225
203
 
 
204
#define DECLARE_DRIZZLE_SessionVAR_BOOL(name) struct { \
 
205
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
206
  int offset;                   \
 
207
  bool def_val;           \
 
208
  DECLARE_SessionVAR_FUNC(bool);    \
 
209
} DRIZZLE_SYSVAR_NAME(name)
 
210
 
226
211
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
227
212
  DRIZZLE_PLUGIN_VAR_HEADER;      \
228
213
  int offset;                   \
244
229
  the following declarations are for use by plugin implementors
245
230
*/
246
231
 
 
232
#define DECLARE_DRIZZLE_SYSVAR_BOOL(name) struct { \
 
233
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
234
  bool *value;                  \
 
235
  bool def_val;           \
 
236
} DRIZZLE_SYSVAR_NAME(name)
 
237
 
 
238
 
247
239
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
248
 
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
240
  DECLARE_DRIZZLE_SYSVAR_BOOL(name) = { \
249
241
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
250
242
  #name, comment, check, update, &varname, def}
251
243
 
 
244
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
245
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
246
  type *value;                  \
 
247
  const type def_val;           \
 
248
} DRIZZLE_SYSVAR_NAME(name)
 
249
 
252
250
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
253
251
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
254
252
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
285
283
  #name, comment, check, update, &varname, def, min, max, blk }
286
284
 
287
285
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
288
 
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
286
DECLARE_DRIZZLE_SessionVAR_BOOL(name) = { \
289
287
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
290
288
  #name, comment, check, update, -1, def, NULL}
291
289
 
371
369
  Miscellaneous functions for plugin implementors
372
370
*/
373
371
 
374
 
#ifdef __cplusplus
375
 
extern "C" {
376
 
#endif
377
 
 
378
 
extern bool plugin_init(plugin::Registry &registry,
379
 
                        int *argc, char **argv,
380
 
                        bool skip_init);
381
 
extern void plugin_shutdown(plugin::Registry &plugins);
 
372
extern bool plugin_init(module::Registry &registry,
 
373
                        boost::program_options::options_description &long_options);
 
374
extern bool plugin_finalize(module::Registry &registry);
382
375
extern void my_print_help_inc_plugins(option *options);
383
376
extern bool plugin_is_ready(const LEX_STRING *name, int type);
384
377
extern void plugin_sessionvar_init(Session *session);
391
384
const char *get_session_proc_info(Session *session);
392
385
int64_t session_test_options(const Session *session, int64_t test_options);
393
386
int session_sql_command(const Session *session);
394
 
int session_tx_isolation(const Session *session);
 
387
enum_tx_isolation session_tx_isolation(const Session *session);
395
388
 
 
389
void compose_plugin_add(std::vector<std::string> options);
 
390
void compose_plugin_remove(std::vector<std::string> options);
 
391
void notify_plugin_load(std::string in_plugin_load);
396
392
 
397
393
 
398
394
/**
426
422
int session_killed(const Session *session);
427
423
 
428
424
 
429
 
/**
430
 
  Return the thread id of a user thread
431
 
 
432
 
  @param session  user thread connection handle
433
 
  @return  thread id
434
 
*/
435
 
unsigned long session_get_thread_id(const Session *session);
436
 
 
437
425
const charset_info_st *session_charset(Session *session);
438
 
int session_non_transactional_update(const Session *session);
439
 
void session_mark_transaction_to_rollback(Session *session, bool all);
440
 
 
441
 
 
442
 
/**
443
 
  Allocate memory in the connection's local memory pool
444
 
 
445
 
  @details
446
 
  When properly used in place of @c malloc(), this can significantly
447
 
  improve concurrency. Don't use this or related functions to allocate
448
 
  large chunks of memory. Use for temporary storage only. The memory
449
 
  will be freed automatically at the end of the statement; no explicit
450
 
  code is required to prevent memory leaks.
451
 
 
452
 
  @see alloc_root()
453
 
*/
454
 
void *session_alloc(Session *session, unsigned int size);
455
 
/**
456
 
  @see session_alloc()
457
 
*/
458
 
void *session_calloc(Session *session, unsigned int size);
459
 
/**
460
 
  @see session_alloc()
461
 
*/
462
 
char *session_strdup(Session *session, const char *str);
463
 
/**
464
 
  @see session_alloc()
465
 
*/
466
 
char *session_strmake(Session *session, const char *str, unsigned int size);
467
 
/**
468
 
  @see session_alloc()
469
 
*/
470
 
void *session_memdup(Session *session, const void* str, unsigned int size);
471
 
 
472
 
/**
473
 
  Get the XID for this connection's transaction
474
 
 
475
 
  @param session  user thread connection handle
476
 
  @param xid  location where identifier is stored
477
 
*/
478
 
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
479
426
 
480
427
/**
481
428
  Invalidate the query cache for a given table.
489
436
                                   const char *key, unsigned int key_length,
490
437
                                   int using_trx);
491
438
 
492
 
#ifdef __cplusplus
493
 
}
494
 
#endif
495
 
 
496
439
} /* namespace drizzled */
497
440
 
498
441
#endif /* DRIZZLED_PLUGIN_H */