~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2010-10-27 23:31:42 UTC
  • mto: (1887.2.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1888.
  • Revision ID: brian@tangent.org-20101027233142-lmo86qafuoz1xmk2
Move table_share over into definition and fix header.

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