~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

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/module.h>
 
27
#include "drizzled/plugin/version.h"
 
28
#include "drizzled/definitions.h"
 
29
 
 
30
 
 
31
class Session;
23
32
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;
 
33
struct charset_info_st;
56
34
 
57
35
/*************************************************************************
58
36
  Plugin API. Common for all plugin types.
59
37
*/
60
38
 
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[]= {
94
 
#else
95
 
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
96
 
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
97
 
#endif
98
 
 
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}}
 
39
 
 
40
class sys_var;
 
41
typedef drizzle_lex_string LEX_STRING;
 
42
struct my_option;
 
43
 
 
44
extern char *opt_plugin_add;
 
45
extern char *opt_plugin_load;
 
46
extern char *opt_plugin_dir_ptr;
 
47
extern char opt_plugin_dir[FN_REFLEN];
 
48
 
 
49
namespace drizzled { namespace plugin { class StorageEngine; } }
 
50
 
 
51
/*
 
52
  Macros for beginning and ending plugin declarations. Between
 
53
  DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
 
54
  be a drizzled::plugin::Manifest for each plugin to be declared.
 
55
*/
 
56
 
 
57
 
 
58
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
 
59
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
 
60
#define DRIZZLE_DECLARE_PLUGIN \
 
61
           drizzled::plugin::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
 
62
 
 
63
 
 
64
#define DRIZZLE_DECLARE_PLUGIN_END
 
65
#define DRIZZLE_PLUGIN(init,deinit,status,system) \
 
66
  DRIZZLE_DECLARE_PLUGIN \
 
67
  { \
 
68
    DRIZZLE_VERSION_ID, \
 
69
    STRINGIFY_ARG(PANDORA_MODULE_NAME), \
 
70
    STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
 
71
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
 
72
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
 
73
    PANDORA_MODULE_LICENSE, \
 
74
    init, deinit, status, system, NULL \
 
75
  } 
 
76
 
104
77
 
105
78
/*
106
79
  declarations for SHOW STATUS support in plugins
109
82
{
110
83
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
111
84
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
112
 
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
85
  SHOW_ARRAY, SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
 
86
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, 
 
87
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
 
88
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
113
89
};
114
90
 
115
 
struct st_mysql_show_var {
 
91
struct drizzle_show_var {
116
92
  const char *name;
117
93
  char *value;
118
94
  enum enum_mysql_show_type type;
119
95
};
120
96
 
 
97
typedef enum enum_mysql_show_type SHOW_TYPE;
 
98
typedef drizzle_show_var SHOW_VAR;
 
99
 
121
100
 
122
101
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
123
 
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
102
typedef int (*mysql_show_var_func)(drizzle_show_var *, char *);
124
103
 
125
104
struct st_show_var_func_container {
126
105
  mysql_show_var_func func;
138
117
#define PLUGIN_VAR_ENUM         0x0006
139
118
#define PLUGIN_VAR_SET          0x0007
140
119
#define PLUGIN_VAR_UNSIGNED     0x0080
141
 
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
 
120
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
142
121
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
143
122
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
144
123
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
147
126
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
148
127
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
149
128
 
150
 
struct st_mysql_sys_var;
151
 
struct st_mysql_value;
 
129
struct drizzle_sys_var;
 
130
struct drizzle_value;
152
131
 
153
132
/*
154
133
  SYNOPSIS
155
134
    (*mysql_var_check_func)()
156
 
      thd               thread handle
 
135
      session               thread handle
157
136
      var               dynamic variable being altered
158
137
      save              pointer to temporary storage
159
138
      value             user provided value
160
139
  RETURN
161
140
    0   user provided value is OK and the update func may be called.
162
141
    any other value indicates error.
163
 
  
 
142
 
164
143
  This function should parse the user provided value and store in the
165
144
  provided temporary storage any data as required by the update func.
166
145
  There is sufficient space in the temporary storage to store a double.
169
148
  automatically at the end of the statement.
170
149
*/
171
150
 
172
 
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
173
 
                                    struct st_mysql_sys_var *var,
174
 
                                    void *save, struct st_mysql_value *value);
 
151
typedef int (*mysql_var_check_func)(Session *session,
 
152
                                    drizzle_sys_var *var,
 
153
                                    void *save, drizzle_value *value);
175
154
 
176
155
/*
177
156
  SYNOPSIS
178
157
    (*mysql_var_update_func)()
179
 
      thd               thread handle
 
158
      session               thread handle
180
159
      var               dynamic variable being altered
181
160
      var_ptr           pointer to dynamic variable
182
161
      save              pointer to temporary storage
183
162
   RETURN
184
163
     NONE
185
 
   
 
164
 
186
165
   This function should use the validated value stored in the temporary store
187
166
   and persist it in the provided pointer to the dynamic variable.
188
167
   For example, strings may require memory to be allocated.
189
168
*/
190
 
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
191
 
                                      struct st_mysql_sys_var *var,
 
169
typedef void (*mysql_var_update_func)(Session *session,
 
170
                                      drizzle_sys_var *var,
192
171
                                      void *var_ptr, const void *save);
193
172
 
194
173
 
209
188
 
210
189
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
211
190
#define DRIZZLE_SYSVAR(name) \
212
 
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
191
  ((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
213
192
 
214
193
/*
215
194
  for global variables, the value pointer is the first
217
196
  for thread variables, the value offset is the first
218
197
  element after the header, the default value is the second.
219
198
*/
220
 
   
 
199
 
221
200
 
222
201
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
223
202
  DRIZZLE_PLUGIN_VAR_HEADER;      \
238
217
  TYPELIB *typelib;             \
239
218
} DRIZZLE_SYSVAR_NAME(name)
240
219
 
241
 
#define DECLARE_THDVAR_FUNC(type) \
242
 
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
220
#define DECLARE_SessionVAR_FUNC(type) \
 
221
  type *(*resolve)(Session *session, int offset)
243
222
 
244
 
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
 
223
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
245
224
  DRIZZLE_PLUGIN_VAR_HEADER;      \
246
225
  int offset;                   \
247
226
  const type def_val;           \
248
 
  DECLARE_THDVAR_FUNC(type);    \
 
227
  DECLARE_SessionVAR_FUNC(type);    \
249
228
} DRIZZLE_SYSVAR_NAME(name)
250
229
 
251
 
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
 
230
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
252
231
  DRIZZLE_PLUGIN_VAR_HEADER;      \
253
232
  int offset;                   \
254
233
  type def_val; type min_val;   \
255
234
  type max_val; type blk_sz;    \
256
 
  DECLARE_THDVAR_FUNC(type);    \
 
235
  DECLARE_SessionVAR_FUNC(type);    \
257
236
} DRIZZLE_SYSVAR_NAME(name)
258
237
 
259
 
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
 
238
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
260
239
  DRIZZLE_PLUGIN_VAR_HEADER;      \
261
240
  int offset;                   \
262
241
  type def_val;                 \
263
 
  DECLARE_THDVAR_FUNC(type);    \
 
242
  DECLARE_SessionVAR_FUNC(type);    \
264
243
  TYPELIB *typelib;             \
265
244
} DRIZZLE_SYSVAR_NAME(name)
266
245
 
319
298
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
320
299
  #name, comment, check, update, &varname, def, typelib }
321
300
 
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), \
 
301
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
302
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
303
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
304
  #name, comment, check, update, -1, def, NULL}
 
305
 
 
306
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
307
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
308
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
309
  #name, comment, check, update, -1, def, NULL}
 
310
 
 
311
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
312
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
313
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
314
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
315
 
 
316
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
317
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
318
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
319
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
320
 
 
321
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
322
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
323
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
324
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
325
 
 
326
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
327
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
328
  PLUGIN_VAR_LONG | 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_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
332
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
333
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
334
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
335
 
 
336
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
337
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
338
  PLUGIN_VAR_LONGLONG | 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_ENUM(name, opt, comment, check, update, def, typelib) \
 
342
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
 
343
  PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
365
344
  #name, comment, check, update, -1, def, NULL, typelib }
366
345
 
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), \
 
346
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
 
347
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
 
348
  PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
370
349
  #name, comment, check, update, -1, def, NULL, typelib }
371
350
 
372
351
/* accessor macros */
374
353
#define SYSVAR(name) \
375
354
  (*(DRIZZLE_SYSVAR_NAME(name).value))
376
355
 
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;
 
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)))
402
359
 
403
360
 
404
361
/*************************************************************************
405
 
  st_mysql_value struct for reading values from mysqld.
 
362
  drizzle_value struct for reading values from mysqld.
406
363
  Used by server variables framework to parse user-provided values.
407
364
  Will be used for arguments when implementing UDFs.
408
365
 
415
372
#define DRIZZLE_VALUE_TYPE_REAL   1
416
373
#define DRIZZLE_VALUE_TYPE_INT    2
417
374
 
418
 
struct st_mysql_value
419
 
{
420
 
  int (*value_type)(struct st_mysql_value *);
421
 
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
422
 
  int (*val_real)(struct st_mysql_value *, double *realbuf);
423
 
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
 
375
/*
 
376
  skeleton of a plugin variable - portion of structure common to all.
 
377
*/
 
378
struct drizzle_sys_var
 
379
{
 
380
  DRIZZLE_PLUGIN_VAR_HEADER;
 
381
};
 
382
 
 
383
void plugin_opt_set_limits(my_option *options, const drizzle_sys_var *opt);
 
384
 
 
385
struct drizzle_value
 
386
{
 
387
  int (*value_type)(drizzle_value *);
 
388
  const char *(*val_str)(drizzle_value *, char *buffer, int *length);
 
389
  int (*val_real)(drizzle_value *, double *realbuf);
 
390
  int (*val_int)(drizzle_value *, int64_t *intbuf);
424
391
};
425
392
 
426
393
 
432
399
extern "C" {
433
400
#endif
434
401
 
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);
 
402
extern bool plugin_init(drizzled::plugin::Registry &registry,
 
403
                        int *argc, char **argv,
 
404
                        bool skip_init);
 
405
extern void plugin_shutdown(drizzled::plugin::Registry &plugins);
 
406
extern void my_print_help_inc_plugins(my_option *options);
 
407
extern bool plugin_is_ready(const LEX_STRING *name, int type);
 
408
extern void plugin_sessionvar_init(Session *session);
 
409
extern void plugin_sessionvar_cleanup(Session *session);
 
410
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
 
411
 
 
412
int session_in_lock_tables(const Session *session);
 
413
int session_tablespace_op(const Session *session);
 
414
void set_session_proc_info(Session *session, const char *info);
 
415
const char *get_session_proc_info(Session *session);
 
416
int64_t session_test_options(const Session *session, int64_t test_options);
 
417
int session_sql_command(const Session *session);
 
418
int session_tx_isolation(const Session *session);
 
419
 
 
420
 
444
421
 
445
422
/**
446
423
  Create a temporary file.
466
443
  time-consuming loops, and gracefully abort the operation if it is
467
444
  non-zero.
468
445
 
469
 
  @param thd  user thread connection handle
 
446
  @param session  user thread connection handle
470
447
  @retval 0  the connection is active
471
448
  @retval 1  the connection has been killed
472
449
*/
473
 
int thd_killed(const DRIZZLE_THD thd);
 
450
int session_killed(const Session *session);
474
451
 
475
452
 
476
453
/**
477
454
  Return the thread id of a user thread
478
455
 
479
 
  @param thd  user thread connection handle
 
456
  @param session  user thread connection handle
480
457
  @return  thread id
481
458
*/
482
 
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
459
unsigned long session_get_thread_id(const Session *session);
 
460
 
 
461
const charset_info_st *session_charset(Session *session);
 
462
char **session_query(Session *session);
 
463
int session_non_transactional_update(const Session *session);
 
464
void session_mark_transaction_to_rollback(Session *session, bool all);
483
465
 
484
466
 
485
467
/**
486
468
  Allocate memory in the connection's local memory pool
487
469
 
488
470
  @details
489
 
  When properly used in place of @c my_malloc(), this can significantly
 
471
  When properly used in place of @c malloc(), this can significantly
490
472
  improve concurrency. Don't use this or related functions to allocate
491
473
  large chunks of memory. Use for temporary storage only. The memory
492
474
  will be freed automatically at the end of the statement; no explicit
494
476
 
495
477
  @see alloc_root()
496
478
*/
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);
 
479
void *session_alloc(Session *session, unsigned int size);
 
480
/**
 
481
  @see session_alloc()
 
482
*/
 
483
void *session_calloc(Session *session, unsigned int size);
 
484
/**
 
485
  @see session_alloc()
 
486
*/
 
487
char *session_strdup(Session *session, const char *str);
 
488
/**
 
489
  @see session_alloc()
 
490
*/
 
491
char *session_strmake(Session *session, const char *str, unsigned int size);
 
492
/**
 
493
  @see session_alloc()
 
494
*/
 
495
void *session_memdup(Session *session, const void* str, unsigned int size);
531
496
 
532
497
/**
533
498
  Get the XID for this connection's transaction
534
499
 
535
 
  @param thd  user thread connection handle
 
500
  @param session  user thread connection handle
536
501
  @param xid  location where identifier is stored
537
502
*/
538
 
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
503
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
539
504
 
540
505
/**
541
506
  Invalidate the query cache for a given table.
542
507
 
543
 
  @param thd         user thread connection handle
 
508
  @param session         user thread connection handle
544
509
  @param key         databasename\\0tablename\\0
545
510
  @param key_length  length of key in bytes, including the NUL bytes
546
511
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
547
512
*/
548
 
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
513
void mysql_query_cache_invalidate4(Session *session,
549
514
                                   const char *key, unsigned int key_length,
550
515
                                   int using_trx);
551
516
 
553
518
}
554
519
#endif
555
520
 
556
 
#ifdef __cplusplus
557
 
/**
558
 
  Provide a handler data getter to simplify coding
559
 
*/
560
 
inline
561
 
void *
562
 
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
563
 
{
564
 
  return *thd_ha_data(thd, hton);
565
 
}
566
 
 
567
 
/**
568
 
  Provide a handler data setter to simplify coding
569
 
*/
570
 
inline
571
 
void
572
 
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
573
 
                const void *ha_data)
574
 
{
575
 
  *thd_ha_data(thd, hton)= (void*) ha_data;
576
 
}
577
 
#endif
578
 
 
579
 
#endif
 
521
#endif /* DRIZZLED_PLUGIN_H */
580
522