~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: lbieber
  • Date: 2010-10-01 12:16:18 UTC
  • mfrom: (1802.1.1 fix-bug-651256)
  • Revision ID: lbieber@orisndriz08-20101001121618-uqcboygpjwbiglem
Merge Vijay - fix bug 651256 - Remove --help-extended

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
23
#include "drizzled/module/manifest.h"
27
24
#include "drizzled/module/module.h"
28
25
#include "drizzled/plugin/version.h"
30
27
#include "drizzled/definitions.h"
31
28
 
32
29
#include "drizzled/lex_string.h"
33
 
#include "drizzled/sys_var.h"
34
30
#include "drizzled/xid.h"
35
 
 
36
 
#include "drizzled/visibility.h"
 
31
#include <boost/program_options.hpp>
37
32
 
38
33
namespace drizzled
39
34
{
48
43
 
49
44
 
50
45
class sys_var;
 
46
typedef drizzle_lex_string LEX_STRING;
51
47
struct option;
52
48
 
53
 
extern boost::filesystem::path plugin_dir;
 
49
extern char opt_plugin_dir[FN_REFLEN];
54
50
 
55
51
namespace plugin { class StorageEngine; }
56
52
 
64
60
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
65
61
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
66
62
#define DRIZZLE_DECLARE_PLUGIN \
67
 
  DRIZZLED_API ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
 
63
  ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
68
64
 
69
65
 
70
66
#define DRIZZLE_DECLARE_PLUGIN_END
77
73
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
78
74
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
79
75
    PANDORA_MODULE_LICENSE, \
80
 
    init, \
81
 
    STRINGIFY_ARG(PANDORA_MODULE_DEPENDENCIES), \
82
 
    options \
 
76
    init, system, options \
83
77
  } 
84
78
 
85
79
 
86
80
/*
 
81
  declarations for SHOW STATUS support in plugins
 
82
*/
 
83
enum enum_mysql_show_type
 
84
{
 
85
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
86
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
87
  SHOW_FUNC,
 
88
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS,
 
89
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
 
90
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
 
91
};
 
92
 
 
93
struct drizzle_show_var {
 
94
  const char *name;
 
95
  char *value;
 
96
  enum enum_mysql_show_type type;
 
97
};
 
98
 
 
99
typedef enum enum_mysql_show_type SHOW_TYPE;
 
100
 
 
101
 
 
102
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
103
typedef int (*mysql_show_var_func)(drizzle_show_var *, char *);
 
104
 
 
105
struct st_show_var_func_container {
 
106
  mysql_show_var_func func;
 
107
};
 
108
/*
87
109
  declarations for server variables and command line options
88
110
*/
89
111
 
108
130
 
109
131
/*
110
132
  SYNOPSIS
111
 
    (*var_check_func)()
 
133
    (*mysql_var_check_func)()
112
134
      session               thread handle
113
135
      var               dynamic variable being altered
114
136
      save              pointer to temporary storage
125
147
  automatically at the end of the statement.
126
148
*/
127
149
 
128
 
typedef int (*var_check_func)(Session *session,
 
150
typedef int (*mysql_var_check_func)(Session *session,
129
151
                                    drizzle_sys_var *var,
130
152
                                    void *save, drizzle_value *value);
131
153
 
132
154
/*
133
155
  SYNOPSIS
134
 
    (*var_update_func)()
 
156
    (*mysql_var_update_func)()
135
157
      session               thread handle
136
158
      var               dynamic variable being altered
137
159
      var_ptr           pointer to dynamic variable
143
165
   and persist it in the provided pointer to the dynamic variable.
144
166
   For example, strings may require memory to be allocated.
145
167
*/
146
 
typedef void (*var_update_func)(Session *session,
 
168
typedef void (*mysql_var_update_func)(Session *session,
147
169
                                      drizzle_sys_var *var,
148
170
                                      void *var_ptr, const void *save);
149
171
 
150
172
 
 
173
/* the following declarations are for internal use only */
 
174
 
 
175
 
 
176
#define PLUGIN_VAR_MASK \
 
177
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
178
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
179
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
180
 
 
181
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
182
  int flags;                    \
 
183
  const char *name;             \
 
184
  const char *comment;          \
 
185
  mysql_var_check_func check;   \
 
186
  mysql_var_update_func update
 
187
 
 
188
#define DRIZZLE_SYSVAR_NAME(name) drizzle_sysvar_ ## name
 
189
#define DRIZZLE_SYSVAR(name) \
 
190
  ((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
 
191
 
 
192
/*
 
193
  for global variables, the value pointer is the first
 
194
  element after the header, the default value is the second.
 
195
  for thread variables, the value offset is the first
 
196
  element after the header, the default value is the second.
 
197
*/
 
198
 
 
199
 
 
200
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
201
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
202
  type *value;                  \
 
203
  const type def_val;           \
 
204
} DRIZZLE_SYSVAR_NAME(name)
 
205
 
 
206
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
207
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
208
  type *value; type def_val;    \
 
209
  type min_val; type max_val;   \
 
210
  type blk_sz;                  \
 
211
} DRIZZLE_SYSVAR_NAME(name)
 
212
 
 
213
#define DECLARE_SessionVAR_FUNC(type) \
 
214
  type *(*resolve)(Session *session, int offset)
 
215
 
 
216
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
217
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
218
  int offset;                   \
 
219
  const type def_val;           \
 
220
  DECLARE_SessionVAR_FUNC(type);    \
 
221
} DRIZZLE_SYSVAR_NAME(name)
 
222
 
 
223
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
224
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
225
  int offset;                   \
 
226
  type def_val; type min_val;   \
 
227
  type max_val; type blk_sz;    \
 
228
  DECLARE_SessionVAR_FUNC(type);    \
 
229
} DRIZZLE_SYSVAR_NAME(name)
 
230
 
 
231
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
232
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
233
  int offset;                   \
 
234
  type def_val;                 \
 
235
  DECLARE_SessionVAR_FUNC(type);    \
 
236
  TYPELIB *typelib;             \
 
237
} DRIZZLE_SYSVAR_NAME(name)
 
238
 
 
239
 
 
240
/*
 
241
  the following declarations are for use by plugin implementors
 
242
*/
 
243
 
 
244
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
245
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
246
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
247
  #name, comment, check, update, &varname, def}
 
248
 
 
249
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
250
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
251
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
252
  #name, comment, check, update, &varname, def}
 
253
 
 
254
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
255
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
256
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
257
  #name, comment, check, update, &varname, def, min, max, blk }
 
258
 
 
259
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
260
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
261
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
262
  #name, comment, check, update, &varname, def, min, max, blk }
 
263
 
 
264
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
265
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
266
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
267
  #name, comment, check, update, &varname, def, min, max, blk }
 
268
 
 
269
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
270
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
271
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
272
  #name, comment, check, update, &varname, def, min, max, blk }
 
273
 
 
274
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
275
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
276
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
277
  #name, comment, check, update, &varname, def, min, max, blk }
 
278
 
 
279
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
280
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
281
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
282
  #name, comment, check, update, &varname, def, min, max, blk }
 
283
 
 
284
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
285
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
286
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
287
  #name, comment, check, update, -1, def, NULL}
 
288
 
 
289
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
290
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
291
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
292
  #name, comment, check, update, -1, def, NULL}
 
293
 
 
294
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
295
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
296
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
297
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
298
 
 
299
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
300
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
301
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
302
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
303
 
 
304
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
305
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
306
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
307
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
308
 
 
309
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
310
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
311
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
312
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
313
 
 
314
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
315
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
316
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
317
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
318
 
 
319
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
320
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
321
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
322
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
323
 
 
324
/* accessor macros */
 
325
 
 
326
#define SYSVAR(name) \
 
327
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
328
 
 
329
/* when session == null, result points to global value */
 
330
#define SessionVAR(session, name) \
 
331
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
 
332
 
 
333
 
 
334
/*************************************************************************
 
335
  drizzle_value struct for reading values from mysqld.
 
336
  Used by server variables framework to parse user-provided values.
 
337
  Will be used for arguments when implementing UDFs.
 
338
 
 
339
  Note that val_str() returns a string in temporary memory
 
340
  that will be freed at the end of statement. Copy the string
 
341
  if you need it to persist.
 
342
*/
 
343
 
 
344
#define DRIZZLE_VALUE_TYPE_STRING 0
 
345
#define DRIZZLE_VALUE_TYPE_REAL   1
 
346
#define DRIZZLE_VALUE_TYPE_INT    2
151
347
 
152
348
/*
153
349
  skeleton of a plugin variable - portion of structure common to all.
154
350
*/
155
351
struct drizzle_sys_var
156
352
{
 
353
  DRIZZLE_PLUGIN_VAR_HEADER;
157
354
};
158
355
 
159
356
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
174
371
extern bool plugin_init(module::Registry &registry,
175
372
                        boost::program_options::options_description &long_options);
176
373
extern bool plugin_finalize(module::Registry &registry);
177
 
extern void plugin_startup_window(module::Registry &registry, drizzled::Session &session);
178
374
extern void my_print_help_inc_plugins(option *options);
179
375
extern bool plugin_is_ready(const LEX_STRING *name, int type);
180
376
extern void plugin_sessionvar_init(Session *session);
181
377
extern void plugin_sessionvar_cleanup(Session *session);
 
378
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
182
379
 
183
380
int session_in_lock_tables(const Session *session);
184
 
DRIZZLED_API int64_t session_test_options(const Session *session, int64_t test_options);
 
381
int session_tablespace_op(const Session *session);
 
382
void set_session_proc_info(Session *session, const char *info);
 
383
const char *get_session_proc_info(Session *session);
 
384
int64_t session_test_options(const Session *session, int64_t test_options);
 
385
int session_sql_command(const Session *session);
 
386
enum_tx_isolation session_tx_isolation(const Session *session);
 
387
 
185
388
void compose_plugin_add(std::vector<std::string> options);
186
389
void compose_plugin_remove(std::vector<std::string> options);
187
390
void notify_plugin_load(std::string in_plugin_load);
199
402
  @retval -1    error
200
403
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
201
404
*/
202
 
DRIZZLED_API int tmpfile(const char *prefix);
 
405
int mysql_tmpfile(const char *prefix);
 
406
 
 
407
/**
 
408
  Check the killed state of a connection
 
409
 
 
410
  @details
 
411
  In MySQL support for the KILL statement is cooperative. The KILL
 
412
  statement only sets a "killed" flag. This function returns the value
 
413
  of that flag.  A thread should check it often, especially inside
 
414
  time-consuming loops, and gracefully abort the operation if it is
 
415
  non-zero.
 
416
 
 
417
  @param session  user thread connection handle
 
418
  @retval 0  the connection is active
 
419
  @retval 1  the connection has been killed
 
420
*/
 
421
int session_killed(const Session *session);
 
422
 
 
423
 
 
424
const charset_info_st *session_charset(Session *session);
 
425
 
 
426
/**
 
427
  Invalidate the query cache for a given table.
 
428
 
 
429
  @param session         user thread connection handle
 
430
  @param key         databasename\\0tablename\\0
 
431
  @param key_length  length of key in bytes, including the NUL bytes
 
432
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
433
*/
 
434
void mysql_query_cache_invalidate4(Session *session,
 
435
                                   const char *key, unsigned int key_length,
 
436
                                   int using_trx);
203
437
 
204
438
} /* namespace drizzled */
205
439