~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2010-10-21 08:55:44 UTC
  • mto: (1866.1.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: brian@tangent.org-20101021085544-chpce06zm4tdaqdi
This creates a function for seeing which catalog you are in. It also
refactors some of the functions to be in the utility_function collect.

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 <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"
 
31
#include <boost/program_options.hpp>
 
32
#include <boost/filesystem.hpp>
35
33
 
36
34
namespace drizzled
37
35
{
81
79
 
82
80
 
83
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
/*
84
110
  declarations for server variables and command line options
85
111
*/
86
112
 
145
171
                                      void *var_ptr, const void *save);
146
172
 
147
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
148
374
 
149
375
/*
150
376
  skeleton of a plugin variable - portion of structure common to all.
151
377
*/
152
378
struct drizzle_sys_var
153
379
{
 
380
  DRIZZLE_PLUGIN_VAR_HEADER;
154
381
};
155
382
 
156
383
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
204
431
*/
205
432
int mysql_tmpfile(const char *prefix);
206
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);
 
464
 
207
465
} /* namespace drizzled */
208
466
 
209
467
#endif /* DRIZZLED_PLUGIN_H */