~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Stewart Smith
  • Date: 2008-10-15 04:21:24 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: stewart@flamingspork.com-20081015042124-kdmb74bcbky1k1nz
remove my_pthread_[gs]etspecific

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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_PLUGIN_H
21
 
#define DRIZZLED_PLUGIN_H
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
 
#include <drizzled/lex_string.h>
33
 
#include <drizzled/sys_var.h>
34
 
#include <drizzled/xid.h>
35
 
 
36
 
#include <drizzled/visibility.h>
37
 
 
38
 
namespace drizzled
39
 
{
40
 
 
41
 
class Session;
 
20
#ifndef _my_plugin_h
 
21
#define _my_plugin_h
 
22
 
 
23
#include <drizzled/global.h>
 
24
 
 
25
#ifdef __cplusplus
 
26
class THD;
42
27
class Item;
43
 
struct charset_info_st;
 
28
#define DRIZZLE_THD THD*
 
29
#else
 
30
#define DRIZZLE_THD void*
 
31
#endif
 
32
 
 
33
#define DRIZZLE_XIDDATASIZE 128
 
34
/**
 
35
  struct st_mysql_xid is binary compatible with the XID structure as
 
36
  in the X/Open CAE Specification, Distributed Transaction Processing:
 
37
  The XA Specification, X/Open Company Ltd., 1991.
 
38
  http://www.opengroup.org/bookstore/catalog/c193.htm
 
39
 
 
40
  @see XID in sql/handler.h
 
41
*/
 
42
struct st_mysql_xid {
 
43
  long formatID;
 
44
  long gtrid_length;
 
45
  long bqual_length;
 
46
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
 
47
};
 
48
typedef struct st_mysql_xid DRIZZLE_XID;
44
49
 
45
50
/*************************************************************************
46
51
  Plugin API. Common for all plugin types.
47
52
*/
48
53
 
49
 
 
50
 
class sys_var;
51
 
struct option;
52
 
 
53
 
extern boost::filesystem::path plugin_dir;
54
 
 
55
 
namespace plugin { class StorageEngine; }
56
 
 
57
 
/*
58
 
  Macros for beginning and ending plugin declarations. Between
59
 
  DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
60
 
  be a module::Manifest for each plugin to be declared.
61
 
*/
62
 
 
63
 
 
64
 
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
65
 
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
66
 
#define DRIZZLE_DECLARE_PLUGIN \
67
 
  DRIZZLED_API ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
68
 
 
69
 
 
70
 
#define DRIZZLE_DECLARE_PLUGIN_END
71
 
#define DRIZZLE_PLUGIN(init,system,options) \
72
 
  DRIZZLE_DECLARE_PLUGIN \
73
 
  { \
74
 
    DRIZZLE_VERSION_ID, \
75
 
    STRINGIFY_ARG(PANDORA_MODULE_NAME), \
76
 
    STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
77
 
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
78
 
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
79
 
    PANDORA_MODULE_LICENSE, \
80
 
    init, \
81
 
    STRINGIFY_ARG(PANDORA_MODULE_DEPENDENCIES), \
82
 
    options \
83
 
  } 
84
 
 
85
 
 
 
54
/*
 
55
  The allowable types of plugins
 
56
*/
 
57
#define DRIZZLE_DAEMON_PLUGIN          0  /* Daemon / Raw */
 
58
#define DRIZZLE_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine */
 
59
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN  2  /* Information Schema */
 
60
#define DRIZZLE_UDF_PLUGIN             3  /* User-Defined Function */
 
61
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate function */
 
62
#define DRIZZLE_AUDIT_PLUGIN           5  /* Audit */
 
63
#define DRIZZLE_LOGGER_PLUGIN          6  /* Logging */
 
64
#define DRIZZLE_AUTH_PLUGIN            7  /* Authorization */
 
65
 
 
66
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
 
67
 
 
68
/* We use the following strings to define licenses for plugins */
 
69
#define PLUGIN_LICENSE_PROPRIETARY 0
 
70
#define PLUGIN_LICENSE_GPL 1
 
71
#define PLUGIN_LICENSE_BSD 2
 
72
 
 
73
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
 
74
#define PLUGIN_LICENSE_GPL_STRING "GPL"
 
75
#define PLUGIN_LICENSE_BSD_STRING "BSD"
 
76
 
 
77
/*
 
78
  Macros for beginning and ending plugin declarations.  Between
 
79
  mysql_declare_plugin and mysql_declare_plugin_end there should
 
80
  be a st_mysql_plugin struct for each plugin to be declared.
 
81
*/
 
82
 
 
83
 
 
84
#ifndef DRIZZLE_DYNAMIC_PLUGIN
 
85
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
86
struct st_mysql_plugin DECLS[]= {
 
87
#else
 
88
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
89
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
90
#endif
 
91
 
 
92
#define mysql_declare_plugin(NAME) \
 
93
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
94
                 builtin_ ## NAME ## _plugin)
 
95
 
 
96
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
97
 
 
98
/*
 
99
  declarations for SHOW STATUS support in plugins
 
100
*/
 
101
enum enum_mysql_show_type
 
102
{
 
103
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
104
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
105
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
106
};
 
107
 
 
108
struct st_mysql_show_var {
 
109
  const char *name;
 
110
  char *value;
 
111
  enum enum_mysql_show_type type;
 
112
};
 
113
 
 
114
 
 
115
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
116
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
117
 
 
118
struct st_show_var_func_container {
 
119
  mysql_show_var_func func;
 
120
};
86
121
/*
87
122
  declarations for server variables and command line options
88
123
*/
93
128
#define PLUGIN_VAR_LONG         0x0003
94
129
#define PLUGIN_VAR_LONGLONG     0x0004
95
130
#define PLUGIN_VAR_STR          0x0005
 
131
#define PLUGIN_VAR_ENUM         0x0006
 
132
#define PLUGIN_VAR_SET          0x0007
96
133
#define PLUGIN_VAR_UNSIGNED     0x0080
97
 
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
 
134
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
98
135
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
99
136
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
100
137
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
103
140
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
104
141
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
105
142
 
106
 
struct drizzle_sys_var;
107
 
struct drizzle_value;
 
143
struct st_mysql_sys_var;
 
144
struct st_mysql_value;
108
145
 
109
146
/*
110
147
  SYNOPSIS
111
 
    (*var_check_func)()
112
 
      session               thread handle
 
148
    (*mysql_var_check_func)()
 
149
      thd               thread handle
113
150
      var               dynamic variable being altered
114
151
      save              pointer to temporary storage
115
152
      value             user provided value
116
153
  RETURN
117
154
    0   user provided value is OK and the update func may be called.
118
155
    any other value indicates error.
119
 
 
 
156
  
120
157
  This function should parse the user provided value and store in the
121
158
  provided temporary storage any data as required by the update func.
122
159
  There is sufficient space in the temporary storage to store a double.
125
162
  automatically at the end of the statement.
126
163
*/
127
164
 
128
 
typedef int (*var_check_func)(Session *session,
129
 
                                    drizzle_sys_var *var,
130
 
                                    void *save, drizzle_value *value);
 
165
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
166
                                    struct st_mysql_sys_var *var,
 
167
                                    void *save, struct st_mysql_value *value);
131
168
 
132
169
/*
133
170
  SYNOPSIS
134
 
    (*var_update_func)()
135
 
      session               thread handle
 
171
    (*mysql_var_update_func)()
 
172
      thd               thread handle
136
173
      var               dynamic variable being altered
137
174
      var_ptr           pointer to dynamic variable
138
175
      save              pointer to temporary storage
139
176
   RETURN
140
177
     NONE
141
 
 
 
178
   
142
179
   This function should use the validated value stored in the temporary store
143
180
   and persist it in the provided pointer to the dynamic variable.
144
181
   For example, strings may require memory to be allocated.
145
182
*/
146
 
typedef void (*var_update_func)(Session *session,
147
 
                                      drizzle_sys_var *var,
 
183
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
184
                                      struct st_mysql_sys_var *var,
148
185
                                      void *var_ptr, const void *save);
149
186
 
150
187
 
151
 
 
152
 
/*
153
 
  skeleton of a plugin variable - portion of structure common to all.
154
 
*/
155
 
struct drizzle_sys_var
 
188
/* the following declarations are for internal use only */
 
189
 
 
190
 
 
191
#define PLUGIN_VAR_MASK \
 
192
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
193
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
194
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
195
 
 
196
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
197
  int flags;                    \
 
198
  const char *name;             \
 
199
  const char *comment;          \
 
200
  mysql_var_check_func check;   \
 
201
  mysql_var_update_func update
 
202
 
 
203
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
204
#define DRIZZLE_SYSVAR(name) \
 
205
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
206
 
 
207
/*
 
208
  for global variables, the value pointer is the first
 
209
  element after the header, the default value is the second.
 
210
  for thread variables, the value offset is the first
 
211
  element after the header, the default value is the second.
 
212
*/
 
213
   
 
214
 
 
215
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
216
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
217
  type *value;                  \
 
218
  const type def_val;           \
 
219
} DRIZZLE_SYSVAR_NAME(name)
 
220
 
 
221
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
222
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
223
  type *value; type def_val;    \
 
224
  type min_val; type max_val;   \
 
225
  type blk_sz;                  \
 
226
} DRIZZLE_SYSVAR_NAME(name)
 
227
 
 
228
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
 
229
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
230
  type *value; type def_val;    \
 
231
  TYPELIB *typelib;             \
 
232
} DRIZZLE_SYSVAR_NAME(name)
 
233
 
 
234
#define DECLARE_THDVAR_FUNC(type) \
 
235
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
236
 
 
237
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
 
238
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
239
  int offset;                   \
 
240
  const type def_val;           \
 
241
  DECLARE_THDVAR_FUNC(type);    \
 
242
} DRIZZLE_SYSVAR_NAME(name)
 
243
 
 
244
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
 
245
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
246
  int offset;                   \
 
247
  type def_val; type min_val;   \
 
248
  type max_val; type blk_sz;    \
 
249
  DECLARE_THDVAR_FUNC(type);    \
 
250
} DRIZZLE_SYSVAR_NAME(name)
 
251
 
 
252
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
 
253
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
254
  int offset;                   \
 
255
  type def_val;                 \
 
256
  DECLARE_THDVAR_FUNC(type);    \
 
257
  TYPELIB *typelib;             \
 
258
} DRIZZLE_SYSVAR_NAME(name)
 
259
 
 
260
 
 
261
/*
 
262
  the following declarations are for use by plugin implementors
 
263
*/
 
264
 
 
265
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
266
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
267
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
268
  #name, comment, check, update, &varname, def}
 
269
 
 
270
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
271
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
272
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
273
  #name, comment, check, update, &varname, def}
 
274
 
 
275
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
276
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
277
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
278
  #name, comment, check, update, &varname, def, min, max, blk }
 
279
 
 
280
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
281
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
282
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
283
  #name, comment, check, update, &varname, def, min, max, blk }
 
284
 
 
285
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
286
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
287
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
288
  #name, comment, check, update, &varname, def, min, max, blk }
 
289
 
 
290
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
291
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
292
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
293
  #name, comment, check, update, &varname, def, min, max, blk }
 
294
 
 
295
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
296
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
297
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
298
  #name, comment, check, update, &varname, def, min, max, blk }
 
299
 
 
300
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
301
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
302
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
303
  #name, comment, check, update, &varname, def, min, max, blk }
 
304
 
 
305
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
306
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
307
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
308
  #name, comment, check, update, &varname, def, typelib }
 
309
 
 
310
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
311
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
312
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
313
  #name, comment, check, update, &varname, def, typelib }
 
314
 
 
315
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
 
316
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
 
317
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
318
  #name, comment, check, update, -1, def, NULL}
 
319
 
 
320
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
 
321
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
 
322
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
323
  #name, comment, check, update, -1, def, NULL}
 
324
 
 
325
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
326
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
 
327
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
328
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
329
 
 
330
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
331
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
 
332
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
333
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
334
 
 
335
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
336
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
 
337
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
338
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
339
 
 
340
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
341
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
 
342
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
343
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
344
 
 
345
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
346
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
 
347
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
348
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
349
 
 
350
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
351
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
 
352
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
353
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
354
 
 
355
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
356
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
 
357
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
358
  #name, comment, check, update, -1, def, NULL, typelib }
 
359
 
 
360
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
 
361
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
 
362
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
363
  #name, comment, check, update, -1, def, NULL, typelib }
 
364
 
 
365
/* accessor macros */
 
366
 
 
367
#define SYSVAR(name) \
 
368
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
369
 
 
370
/* when thd == null, result points to global value */
 
371
#define THDVAR(thd, name) \
 
372
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(thd, DRIZZLE_SYSVAR_NAME(name).offset)))
 
373
 
 
374
 
 
375
/*
 
376
  Plugin description structure.
 
377
*/
 
378
 
 
379
struct st_mysql_plugin
156
380
{
 
381
  int type;             /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
 
382
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
 
383
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
 
384
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
 
385
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
 
386
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
 
387
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
 
388
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
 
389
  struct st_mysql_show_var *status_vars;
 
390
  struct st_mysql_sys_var **system_vars;
 
391
  void * __reserved1;   /* reserved for dependency checking             */
157
392
};
158
393
 
159
 
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
160
 
 
161
 
struct drizzle_value
 
394
struct handlerton;
 
395
 
 
396
 
 
397
/*************************************************************************
 
398
  st_mysql_value struct for reading values from mysqld.
 
399
  Used by server variables framework to parse user-provided values.
 
400
  Will be used for arguments when implementing UDFs.
 
401
 
 
402
  Note that val_str() returns a string in temporary memory
 
403
  that will be freed at the end of statement. Copy the string
 
404
  if you need it to persist.
 
405
*/
 
406
 
 
407
#define DRIZZLE_VALUE_TYPE_STRING 0
 
408
#define DRIZZLE_VALUE_TYPE_REAL   1
 
409
#define DRIZZLE_VALUE_TYPE_INT    2
 
410
 
 
411
struct st_mysql_value
162
412
{
163
 
  int (*value_type)(drizzle_value *);
164
 
  const char *(*val_str)(drizzle_value *, char *buffer, int *length);
165
 
  int (*val_real)(drizzle_value *, double *realbuf);
166
 
  int (*val_int)(drizzle_value *, int64_t *intbuf);
 
413
  int (*value_type)(struct st_mysql_value *);
 
414
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
415
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
416
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
167
417
};
168
418
 
169
419
 
171
421
  Miscellaneous functions for plugin implementors
172
422
*/
173
423
 
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);
178
 
extern void my_print_help_inc_plugins(option *options);
179
 
extern bool plugin_is_ready(const LEX_STRING *name, int type);
180
 
extern void plugin_sessionvar_init(Session *session);
181
 
extern void plugin_sessionvar_cleanup(Session *session);
182
 
 
183
 
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);
188
 
 
 
424
#ifdef __cplusplus
 
425
extern "C" {
 
426
#endif
 
427
 
 
428
int thd_in_lock_tables(const DRIZZLE_THD thd);
 
429
int thd_tablespace_op(const DRIZZLE_THD thd);
 
430
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
 
431
int thd_sql_command(const DRIZZLE_THD thd);
 
432
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
 
433
int thd_tx_isolation(const DRIZZLE_THD thd);
 
434
/* Increments the row counter, see THD::row_count */
 
435
void thd_inc_row_count(DRIZZLE_THD thd);
189
436
 
190
437
/**
191
438
  Create a temporary file.
197
444
 
198
445
  @param prefix  prefix for temporary file name
199
446
  @retval -1    error
200
 
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
201
 
*/
202
 
DRIZZLED_API int tmpfile(const char *prefix);
203
 
 
204
 
} /* namespace drizzled */
205
 
 
206
 
#endif /* DRIZZLED_PLUGIN_H */
 
447
  @retval >= 0  a file handle that can be passed to dup or my_close
 
448
*/
 
449
int mysql_tmpfile(const char *prefix);
 
450
 
 
451
/**
 
452
  Check the killed state of a connection
 
453
 
 
454
  @details
 
455
  In MySQL support for the KILL statement is cooperative. The KILL
 
456
  statement only sets a "killed" flag. This function returns the value
 
457
  of that flag.  A thread should check it often, especially inside
 
458
  time-consuming loops, and gracefully abort the operation if it is
 
459
  non-zero.
 
460
 
 
461
  @param thd  user thread connection handle
 
462
  @retval 0  the connection is active
 
463
  @retval 1  the connection has been killed
 
464
*/
 
465
int thd_killed(const DRIZZLE_THD thd);
 
466
 
 
467
 
 
468
/**
 
469
  Return the thread id of a user thread
 
470
 
 
471
  @param thd  user thread connection handle
 
472
  @return  thread id
 
473
*/
 
474
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
475
 
 
476
 
 
477
/**
 
478
  Allocate memory in the connection's local memory pool
 
479
 
 
480
  @details
 
481
  When properly used in place of @c my_malloc(), this can significantly
 
482
  improve concurrency. Don't use this or related functions to allocate
 
483
  large chunks of memory. Use for temporary storage only. The memory
 
484
  will be freed automatically at the end of the statement; no explicit
 
485
  code is required to prevent memory leaks.
 
486
 
 
487
  @see alloc_root()
 
488
*/
 
489
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
 
490
/**
 
491
  @see thd_alloc()
 
492
*/
 
493
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
 
494
/**
 
495
  @see thd_alloc()
 
496
*/
 
497
char *thd_strdup(DRIZZLE_THD thd, const char *str);
 
498
/**
 
499
  @see thd_alloc()
 
500
*/
 
501
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
 
502
/**
 
503
  @see thd_alloc()
 
504
*/
 
505
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
 
506
 
 
507
/**
 
508
  Get the XID for this connection's transaction
 
509
 
 
510
  @param thd  user thread connection handle
 
511
  @param xid  location where identifier is stored
 
512
*/
 
513
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
514
 
 
515
/**
 
516
  Invalidate the query cache for a given table.
 
517
 
 
518
  @param thd         user thread connection handle
 
519
  @param key         databasename\\0tablename\\0
 
520
  @param key_length  length of key in bytes, including the NUL bytes
 
521
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
522
*/
 
523
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
524
                                   const char *key, unsigned int key_length,
 
525
                                   int using_trx);
 
526
 
 
527
#ifdef __cplusplus
 
528
}
 
529
#endif
 
530
 
 
531
#ifdef __cplusplus
 
532
/**
 
533
  Provide a handler data getter to simplify coding
 
534
*/
 
535
inline
 
536
void *
 
537
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
538
{
 
539
  return *thd_ha_data(thd, hton);
 
540
}
 
541
 
 
542
/**
 
543
  Provide a handler data setter to simplify coding
 
544
*/
 
545
inline
 
546
void
 
547
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
548
                const void *ha_data)
 
549
{
 
550
  *thd_ha_data(thd, hton)= (void*) ha_data;
 
551
}
 
552
#endif
 
553
 
 
554
#endif
207
555