~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Joe Daly
  • Date: 2010-05-21 02:16:56 UTC
  • mto: This revision was merged to the branch mainline in revision 1555.
  • Revision ID: skinny.moey@gmail.com-20100521021656-bx6piitfh77jnl28
add statistics_variables.h

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