~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
macros.
Add PANDORA_DRIZZLE_BUILD to run the extra checks that drizzle needs that 
plugins would also need to run so we can just use that macro in generated
external plugin builds.
Added support to register_plugins for external plugin building.
Renamed register_plugins.py to pandora-plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2005 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
#ifndef _my_plugin_h
17
 
#define _my_plugin_h
18
 
 
19
 
#include <drizzled/global.h>
20
 
 
21
 
#ifdef __cplusplus
22
 
class THD;
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef DRIZZLED_PLUGIN_H
 
21
#define DRIZZLED_PLUGIN_H
 
22
 
 
23
#include <drizzled/lex_string.h>
 
24
#include <drizzled/xid.h>
 
25
#include <drizzled/plugin/manifest.h>
 
26
#include <drizzled/plugin/library.h>
 
27
#include <drizzled/plugin/module.h>
 
28
 
 
29
class Session;
23
30
class Item;
24
 
#define DRIZZLE_THD THD*
25
 
#else
26
 
#define DRIZZLE_THD void*
27
 
#endif
28
 
 
29
 
 
30
 
#ifndef _m_string_h
31
 
/* This definition must match the one given in m_string.h */
32
 
struct st_mysql_lex_string
33
 
{
34
 
  char *str;
35
 
  unsigned int length;
36
 
};
37
 
#endif /* _m_string_h */
38
 
typedef struct st_mysql_lex_string DRIZZLE_LEX_STRING;
39
 
 
40
 
#define DRIZZLE_XIDDATASIZE 128
41
 
/**
42
 
  struct st_mysql_xid is binary compatible with the XID structure as
43
 
  in the X/Open CAE Specification, Distributed Transaction Processing:
44
 
  The XA Specification, X/Open Company Ltd., 1991.
45
 
  http://www.opengroup.org/bookstore/catalog/c193.htm
46
 
 
47
 
  @see XID in sql/handler.h
48
 
*/
49
 
struct st_mysql_xid {
50
 
  long formatID;
51
 
  long gtrid_length;
52
 
  long bqual_length;
53
 
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
54
 
};
55
 
typedef struct st_mysql_xid DRIZZLE_XID;
 
31
struct charset_info_st;
56
32
 
57
33
/*************************************************************************
58
34
  Plugin API. Common for all plugin types.
59
35
*/
60
36
 
61
 
/*
62
 
  The allowable types of plugins
63
 
*/
64
 
#define DRIZZLE_DAEMON_PLUGIN          0  /* Daemon / Raw */
65
 
#define DRIZZLE_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine */
66
 
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN  2  /* Information Schema */
67
 
#define DRIZZLE_UDF_PLUGIN             3  /* User-Defined Function */
68
 
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate function */
69
 
#define DRIZZLE_AUDIT_PLUGIN           5  /* Audit */
70
 
#define DRIZZLE_LOGGER_PLUGIN          6  /* Logging */
71
 
#define DRIZZLE_AUTH_PLUGIN            7  /* Authorization */
72
 
 
73
 
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
74
 
 
75
 
/* We use the following strings to define licenses for plugins */
76
 
#define PLUGIN_LICENSE_PROPRIETARY 0
77
 
#define PLUGIN_LICENSE_GPL 1
78
 
#define PLUGIN_LICENSE_BSD 2
79
 
 
80
 
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
81
 
#define PLUGIN_LICENSE_GPL_STRING "GPL"
82
 
#define PLUGIN_LICENSE_BSD_STRING "BSD"
83
 
 
84
 
/*
85
 
  Macros for beginning and ending plugin declarations.  Between
86
 
  mysql_declare_plugin and mysql_declare_plugin_end there should
87
 
  be a st_mysql_plugin struct for each plugin to be declared.
88
 
*/
89
 
 
90
 
 
91
 
#ifndef DRIZZLE_DYNAMIC_PLUGIN
92
 
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
93
 
struct st_mysql_plugin DECLS[]= {
 
37
 
 
38
class sys_var;
 
39
typedef struct st_mysql_lex_string LEX_STRING;
 
40
struct my_option;
 
41
 
 
42
extern char *opt_plugin_add;
 
43
extern char *opt_plugin_load;
 
44
extern char *opt_plugin_dir_ptr;
 
45
extern char opt_plugin_dir[FN_REFLEN];
 
46
 
 
47
namespace drizzled { namespace plugin { class StorageEngine; } }
 
48
 
 
49
/*
 
50
  Macros for beginning and ending plugin declarations. Between
 
51
  drizzle_declare_plugin and drizzle_declare_plugin_end there should
 
52
  be a drizzled::plugin::Manifest for each plugin to be declared.
 
53
*/
 
54
 
 
55
 
 
56
#if defined(PANDORA_DYNAMIC_PLUGIN)
 
57
# define drizzle_declare_plugin \
 
58
    drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
94
59
#else
95
 
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
96
 
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
60
# define PANDORA_BUILTIN_NAME(x) builtin_ ## x ## _plugin
 
61
# define PANDORA_NAME(x) PANDORA_BUILTIN_NAME(x)
 
62
# define drizzle_declare_plugin \
 
63
           drizzled::plugin::Manifest PANDORA_NAME(PANDORA_MODULE_NAME)[]= {
97
64
#endif
98
65
 
99
 
#define mysql_declare_plugin(NAME) \
100
 
__DRIZZLE_DECLARE_PLUGIN(NAME, \
101
 
                 builtin_ ## NAME ## _plugin)
102
 
 
103
 
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
66
 
 
67
#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
 
68
 
 
69
 
 
70
 
 
71
/*
 
72
  the following flags are valid for plugin_init()
 
73
*/
 
74
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
 
75
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE    2
 
76
#define PLUGIN_INIT_SKIP_INITIALIZATION  4
 
77
 
 
78
#define INITIAL_LEX_PLUGIN_LIST_SIZE    16
104
79
 
105
80
/*
106
81
  declarations for SHOW STATUS support in plugins
109
84
{
110
85
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
111
86
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
112
 
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
87
  SHOW_ARRAY, SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
 
88
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, 
 
89
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
 
90
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
113
91
};
114
92
 
115
93
struct st_mysql_show_var {
118
96
  enum enum_mysql_show_type type;
119
97
};
120
98
 
 
99
typedef enum enum_mysql_show_type SHOW_TYPE;
 
100
typedef struct st_mysql_show_var SHOW_VAR;
 
101
 
121
102
 
122
103
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
123
 
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
104
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
124
105
 
125
106
struct st_show_var_func_container {
126
107
  mysql_show_var_func func;
138
119
#define PLUGIN_VAR_ENUM         0x0006
139
120
#define PLUGIN_VAR_SET          0x0007
140
121
#define PLUGIN_VAR_UNSIGNED     0x0080
141
 
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
 
122
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
142
123
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
143
124
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
144
125
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
153
134
/*
154
135
  SYNOPSIS
155
136
    (*mysql_var_check_func)()
156
 
      thd               thread handle
 
137
      session               thread handle
157
138
      var               dynamic variable being altered
158
139
      save              pointer to temporary storage
159
140
      value             user provided value
160
141
  RETURN
161
142
    0   user provided value is OK and the update func may be called.
162
143
    any other value indicates error.
163
 
  
 
144
 
164
145
  This function should parse the user provided value and store in the
165
146
  provided temporary storage any data as required by the update func.
166
147
  There is sufficient space in the temporary storage to store a double.
169
150
  automatically at the end of the statement.
170
151
*/
171
152
 
172
 
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
153
typedef int (*mysql_var_check_func)(Session *session,
173
154
                                    struct st_mysql_sys_var *var,
174
155
                                    void *save, struct st_mysql_value *value);
175
156
 
176
157
/*
177
158
  SYNOPSIS
178
159
    (*mysql_var_update_func)()
179
 
      thd               thread handle
 
160
      session               thread handle
180
161
      var               dynamic variable being altered
181
162
      var_ptr           pointer to dynamic variable
182
163
      save              pointer to temporary storage
183
164
   RETURN
184
165
     NONE
185
 
   
 
166
 
186
167
   This function should use the validated value stored in the temporary store
187
168
   and persist it in the provided pointer to the dynamic variable.
188
169
   For example, strings may require memory to be allocated.
189
170
*/
190
 
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
171
typedef void (*mysql_var_update_func)(Session *session,
191
172
                                      struct st_mysql_sys_var *var,
192
173
                                      void *var_ptr, const void *save);
193
174
 
217
198
  for thread variables, the value offset is the first
218
199
  element after the header, the default value is the second.
219
200
*/
220
 
   
 
201
 
221
202
 
222
203
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
223
204
  DRIZZLE_PLUGIN_VAR_HEADER;      \
238
219
  TYPELIB *typelib;             \
239
220
} DRIZZLE_SYSVAR_NAME(name)
240
221
 
241
 
#define DECLARE_THDVAR_FUNC(type) \
242
 
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
222
#define DECLARE_SessionVAR_FUNC(type) \
 
223
  type *(*resolve)(Session *session, int offset)
243
224
 
244
 
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
 
225
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
245
226
  DRIZZLE_PLUGIN_VAR_HEADER;      \
246
227
  int offset;                   \
247
228
  const type def_val;           \
248
 
  DECLARE_THDVAR_FUNC(type);    \
 
229
  DECLARE_SessionVAR_FUNC(type);    \
249
230
} DRIZZLE_SYSVAR_NAME(name)
250
231
 
251
 
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
 
232
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
252
233
  DRIZZLE_PLUGIN_VAR_HEADER;      \
253
234
  int offset;                   \
254
235
  type def_val; type min_val;   \
255
236
  type max_val; type blk_sz;    \
256
 
  DECLARE_THDVAR_FUNC(type);    \
 
237
  DECLARE_SessionVAR_FUNC(type);    \
257
238
} DRIZZLE_SYSVAR_NAME(name)
258
239
 
259
 
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
 
240
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
260
241
  DRIZZLE_PLUGIN_VAR_HEADER;      \
261
242
  int offset;                   \
262
243
  type def_val;                 \
263
 
  DECLARE_THDVAR_FUNC(type);    \
 
244
  DECLARE_SessionVAR_FUNC(type);    \
264
245
  TYPELIB *typelib;             \
265
246
} DRIZZLE_SYSVAR_NAME(name)
266
247
 
319
300
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
320
301
  #name, comment, check, update, &varname, def, typelib }
321
302
 
322
 
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
323
 
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
324
 
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
325
 
  #name, comment, check, update, -1, def, NULL}
326
 
 
327
 
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
328
 
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
329
 
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
330
 
  #name, comment, check, update, -1, def, NULL}
331
 
 
332
 
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
333
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
334
 
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
335
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
336
 
 
337
 
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
338
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
339
 
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
340
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
341
 
 
342
 
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
343
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
344
 
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
345
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
346
 
 
347
 
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
348
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
349
 
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
350
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
351
 
 
352
 
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
353
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
354
 
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
355
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
356
 
 
357
 
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
358
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
359
 
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
360
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
361
 
 
362
 
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
363
 
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
364
 
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
303
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
304
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
305
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
306
  #name, comment, check, update, -1, def, NULL}
 
307
 
 
308
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
309
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
310
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
311
  #name, comment, check, update, -1, def, NULL}
 
312
 
 
313
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
314
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
315
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
316
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
317
 
 
318
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
319
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
320
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
321
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
322
 
 
323
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
324
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
325
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
326
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
327
 
 
328
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
329
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
330
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
331
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
332
 
 
333
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
334
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
335
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
336
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
337
 
 
338
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
339
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
340
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
341
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
342
 
 
343
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
344
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
 
345
  PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
365
346
  #name, comment, check, update, -1, def, NULL, typelib }
366
347
 
367
 
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
368
 
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
369
 
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
348
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
 
349
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
 
350
  PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
370
351
  #name, comment, check, update, -1, def, NULL, typelib }
371
352
 
372
353
/* accessor macros */
374
355
#define SYSVAR(name) \
375
356
  (*(DRIZZLE_SYSVAR_NAME(name).value))
376
357
 
377
 
/* when thd == null, result points to global value */
378
 
#define THDVAR(thd, name) \
379
 
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(thd, DRIZZLE_SYSVAR_NAME(name).offset)))
380
 
 
381
 
 
382
 
/*
383
 
  Plugin description structure.
384
 
*/
385
 
 
386
 
struct st_mysql_plugin
387
 
{
388
 
  int type;             /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
389
 
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
390
 
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
391
 
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
392
 
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
393
 
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
394
 
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
395
 
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
396
 
  struct st_mysql_show_var *status_vars;
397
 
  struct st_mysql_sys_var **system_vars;
398
 
  void * __reserved1;   /* reserved for dependency checking             */
399
 
};
400
 
 
401
 
struct handlerton;
 
358
/* when session == null, result points to global value */
 
359
#define SessionVAR(session, name) \
 
360
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
402
361
 
403
362
 
404
363
/*************************************************************************
432
391
extern "C" {
433
392
#endif
434
393
 
435
 
int thd_in_lock_tables(const DRIZZLE_THD thd);
436
 
int thd_tablespace_op(const DRIZZLE_THD thd);
437
 
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
438
 
int thd_sql_command(const DRIZZLE_THD thd);
439
 
const char *thd_proc_info(DRIZZLE_THD thd, const char *info);
440
 
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
441
 
int thd_tx_isolation(const DRIZZLE_THD thd);
442
 
/* Increments the row counter, see THD::row_count */
443
 
void thd_inc_row_count(DRIZZLE_THD thd);
 
394
extern int plugin_init(drizzled::plugin::Registry &plugins,
 
395
                       int *argc, char **argv, int init_flags);
 
396
extern void plugin_shutdown(drizzled::plugin::Registry &plugins);
 
397
extern void my_print_help_inc_plugins(my_option *options);
 
398
extern bool plugin_is_ready(const LEX_STRING *name, int type);
 
399
extern bool mysql_install_plugin(Session *session, const LEX_STRING *name,
 
400
                                 const LEX_STRING *dl);
 
401
extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name);
 
402
extern void plugin_sessionvar_init(Session *session);
 
403
extern void plugin_sessionvar_cleanup(Session *session);
 
404
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
 
405
 
 
406
int session_in_lock_tables(const Session *session);
 
407
int session_tablespace_op(const Session *session);
 
408
void set_session_proc_info(Session *session, const char *info);
 
409
const char *get_session_proc_info(Session *session);
 
410
int64_t session_test_options(const Session *session, int64_t test_options);
 
411
int session_sql_command(const Session *session);
 
412
void **session_ha_data(const Session *session, const drizzled::plugin::StorageEngine *engine);
 
413
int session_tx_isolation(const Session *session);
 
414
/* Increments the row counter, see Session::row_count */
 
415
void session_inc_row_count(Session *session);
 
416
 
 
417
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
 
418
                                    const char *str, unsigned int size,
 
419
                                    int allocate_lex_string);
 
420
 
 
421
 
444
422
 
445
423
/**
446
424
  Create a temporary file.
466
444
  time-consuming loops, and gracefully abort the operation if it is
467
445
  non-zero.
468
446
 
469
 
  @param thd  user thread connection handle
 
447
  @param session  user thread connection handle
470
448
  @retval 0  the connection is active
471
449
  @retval 1  the connection has been killed
472
450
*/
473
 
int thd_killed(const DRIZZLE_THD thd);
 
451
int session_killed(const Session *session);
474
452
 
475
453
 
476
454
/**
477
455
  Return the thread id of a user thread
478
456
 
479
 
  @param thd  user thread connection handle
 
457
  @param session  user thread connection handle
480
458
  @return  thread id
481
459
*/
482
 
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
460
unsigned long session_get_thread_id(const Session *session);
 
461
 
 
462
const charset_info_st *session_charset(Session *session);
 
463
char **session_query(Session *session);
 
464
int session_non_transactional_update(const Session *session);
 
465
void session_mark_transaction_to_rollback(Session *session, bool all);
483
466
 
484
467
 
485
468
/**
486
469
  Allocate memory in the connection's local memory pool
487
470
 
488
471
  @details
489
 
  When properly used in place of @c my_malloc(), this can significantly
 
472
  When properly used in place of @c malloc(), this can significantly
490
473
  improve concurrency. Don't use this or related functions to allocate
491
474
  large chunks of memory. Use for temporary storage only. The memory
492
475
  will be freed automatically at the end of the statement; no explicit
494
477
 
495
478
  @see alloc_root()
496
479
*/
497
 
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
498
 
/**
499
 
  @see thd_alloc()
500
 
*/
501
 
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
502
 
/**
503
 
  @see thd_alloc()
504
 
*/
505
 
char *thd_strdup(DRIZZLE_THD thd, const char *str);
506
 
/**
507
 
  @see thd_alloc()
508
 
*/
509
 
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
510
 
/**
511
 
  @see thd_alloc()
512
 
*/
513
 
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
514
 
 
515
 
/**
516
 
  Create a LEX_STRING in this connection's local memory pool
517
 
 
518
 
  @param thd      user thread connection handle
519
 
  @param lex_str  pointer to LEX_STRING object to be initialized
520
 
  @param str      initializer to be copied into lex_str
521
 
  @param size     length of str, in bytes
522
 
  @param allocate_lex_string  flag: if TRUE, allocate new LEX_STRING object,
523
 
                              instead of using lex_str value
524
 
  @return  NULL on failure, or pointer to the LEX_STRING object
525
 
 
526
 
  @see thd_alloc()
527
 
*/
528
 
DRIZZLE_LEX_STRING *thd_make_lex_string(DRIZZLE_THD thd, DRIZZLE_LEX_STRING *lex_str,
529
 
                                      const char *str, unsigned int size,
530
 
                                      int allocate_lex_string);
 
480
void *session_alloc(Session *session, unsigned int size);
 
481
/**
 
482
  @see session_alloc()
 
483
*/
 
484
void *session_calloc(Session *session, unsigned int size);
 
485
/**
 
486
  @see session_alloc()
 
487
*/
 
488
char *session_strdup(Session *session, const char *str);
 
489
/**
 
490
  @see session_alloc()
 
491
*/
 
492
char *session_strmake(Session *session, const char *str, unsigned int size);
 
493
/**
 
494
  @see session_alloc()
 
495
*/
 
496
void *session_memdup(Session *session, const void* str, unsigned int size);
531
497
 
532
498
/**
533
499
  Get the XID for this connection's transaction
534
500
 
535
 
  @param thd  user thread connection handle
 
501
  @param session  user thread connection handle
536
502
  @param xid  location where identifier is stored
537
503
*/
538
 
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
504
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
539
505
 
540
506
/**
541
507
  Invalidate the query cache for a given table.
542
508
 
543
 
  @param thd         user thread connection handle
 
509
  @param session         user thread connection handle
544
510
  @param key         databasename\\0tablename\\0
545
511
  @param key_length  length of key in bytes, including the NUL bytes
546
512
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
547
513
*/
548
 
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
514
void mysql_query_cache_invalidate4(Session *session,
549
515
                                   const char *key, unsigned int key_length,
550
516
                                   int using_trx);
551
517
 
559
525
*/
560
526
inline
561
527
void *
562
 
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
528
session_get_ha_data(const Session *session, const drizzled::plugin::StorageEngine *engine)
563
529
{
564
 
  return *thd_ha_data(thd, hton);
 
530
  return *session_ha_data(session, engine);
565
531
}
566
532
 
567
533
/**
569
535
*/
570
536
inline
571
537
void
572
 
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
538
session_set_ha_data(const Session *session, const drizzled::plugin::StorageEngine *engine,
573
539
                const void *ha_data)
574
540
{
575
 
  *thd_ha_data(thd, hton)= (void*) ha_data;
 
541
  *session_ha_data(session, engine)= (void*) ha_data;
576
542
}
577
543
#endif
578
544
 
579
 
#endif
 
545
#endif /* DRIZZLED_PLUGIN_H */
580
546