~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 20:26:28 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321202628-nh6qsi825m4d4av6
Removing the queues.[h,cc] files from the mysys directory. The only place
where they are needed now is in the MyISAM storage engine. Thus, I moved the
files there and updated the files in the MyISAM storage engine
appropriately.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef _my_plugin_h
21
 
#define _my_plugin_h
 
20
#ifndef DRIZZLED_PLUGIN_H
 
21
#define DRIZZLED_PLUGIN_H
22
22
 
23
23
#include <drizzled/global.h>
 
24
#include <drizzled/lex_string.h>
 
25
#include <drizzled/xid.h>
24
26
 
25
 
#ifdef __cplusplus
26
 
class THD;
 
27
class Session;
27
28
class Item;
28
 
#define DRIZZLE_THD THD*
29
 
#else
30
 
#define DRIZZLE_THD void*
31
 
#endif
32
 
 
33
 
 
34
 
#ifndef _m_string_h
35
 
/* This definition must match the one given in m_string.h */
36
 
struct st_mysql_lex_string
37
 
{
38
 
  char *str;
39
 
  unsigned int length;
40
 
};
41
 
#endif /* _m_string_h */
42
 
typedef struct st_mysql_lex_string DRIZZLE_LEX_STRING;
43
 
 
44
 
#define DRIZZLE_XIDDATASIZE 128
45
 
/**
46
 
  struct st_mysql_xid is binary compatible with the XID structure as
47
 
  in the X/Open CAE Specification, Distributed Transaction Processing:
48
 
  The XA Specification, X/Open Company Ltd., 1991.
49
 
  http://www.opengroup.org/bookstore/catalog/c193.htm
50
 
 
51
 
  @see XID in sql/handler.h
52
 
*/
53
 
struct st_mysql_xid {
54
 
  long formatID;
55
 
  long gtrid_length;
56
 
  long bqual_length;
57
 
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
58
 
};
59
 
typedef struct st_mysql_xid DRIZZLE_XID;
60
29
 
61
30
/*************************************************************************
62
31
  Plugin API. Common for all plugin types.
65
34
/*
66
35
  The allowable types of plugins
67
36
*/
68
 
#define DRIZZLE_DAEMON_PLUGIN          0  /* Daemon / Raw */
69
 
#define DRIZZLE_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine */
70
 
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN  2  /* Information Schema */
71
 
#define DRIZZLE_UDF_PLUGIN             3  /* User-Defined Function */
72
 
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate function */
73
 
#define DRIZZLE_AUDIT_PLUGIN           5  /* Audit */
74
 
#define DRIZZLE_LOGGER_PLUGIN          6  /* Logging */
75
 
#define DRIZZLE_AUTH_PLUGIN            7  /* Authorization */
 
37
enum drizzle_plugin_type {
 
38
  DRIZZLE_DAEMON_PLUGIN,                /* Daemon / Raw */
 
39
  DRIZZLE_STORAGE_ENGINE_PLUGIN,        /* Storage Engine */
 
40
  DRIZZLE_INFORMATION_SCHEMA_PLUGIN,    /* Information Schema */
 
41
  DRIZZLE_UDF_PLUGIN,                   /* User-Defined Function */
 
42
  DRIZZLE_UDA_PLUGIN,                   /* User-Defined Aggregate Function */
 
43
  DRIZZLE_AUDIT_PLUGIN,                 /* Audit */
 
44
  DRIZZLE_LOGGER_PLUGIN,                /* Query Logging */
 
45
  DRIZZLE_ERRMSG_PLUGIN,                /* Error Messages */
 
46
  DRIZZLE_AUTH_PLUGIN,                  /* Authorization */
 
47
  DRIZZLE_CONFIGVAR_PLUGIN,             /* Configuration Variables */
 
48
  DRIZZLE_QCACHE_PLUGIN,                /* Query Cache */
 
49
  DRIZZLE_PARSER_PLUGIN,                /* Language Parser */
 
50
  DRIZZLE_SCHEDULING_PLUGIN,            /* Thread and Session Scheduling */
 
51
  DRIZZLE_REPLICATOR_PLUGIN,            /* Database Replication */
 
52
  DRIZZLE_PLUGIN_MAX=DRIZZLE_REPLICATOR_PLUGIN
 
53
};
76
54
 
77
 
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
 
55
/* The number of plugin types */
 
56
const uint32_t DRIZZLE_MAX_PLUGIN_TYPE_NUM=DRIZZLE_PLUGIN_MAX+1;
78
57
 
79
58
/* We use the following strings to define licenses for plugins */
80
 
#define PLUGIN_LICENSE_PROPRIETARY 0
81
 
#define PLUGIN_LICENSE_GPL 1
82
 
#define PLUGIN_LICENSE_BSD 2
 
59
enum plugin_license_type {
 
60
  PLUGIN_LICENSE_PROPRIETARY,
 
61
  PLUGIN_LICENSE_GPL,
 
62
  PLUGIN_LICENSE_BSD,
 
63
  PLUGIN_LICENSE_LGPL,
 
64
  PLUGIN_LICENSE_MAX=PLUGIN_LICENSE_LGPL
 
65
};
83
66
 
84
 
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
85
 
#define PLUGIN_LICENSE_GPL_STRING "GPL"
86
 
#define PLUGIN_LICENSE_BSD_STRING "BSD"
 
67
const char * const PLUGIN_LICENSE_PROPRIETARY_STRING="PROPRIETARY";
 
68
const char * const PLUGIN_LICENSE_GPL_STRING="GPL";
 
69
const char * const PLUGIN_LICENSE_BSD_STRING="BSD";
 
70
const char * const PLUGIN_LICENSE_LGPL_STRING="LGPL";
87
71
 
88
72
/*
89
 
  Macros for beginning and ending plugin declarations.  Between
90
 
  mysql_declare_plugin and mysql_declare_plugin_end there should
 
73
  Macros for beginning and ending plugin declarations. Between
 
74
  drizzle_declare_plugin and drizzle_declare_plugin_end there should
91
75
  be a st_mysql_plugin struct for each plugin to be declared.
92
76
*/
93
77
 
100
84
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
101
85
#endif
102
86
 
103
 
#define mysql_declare_plugin(NAME) \
 
87
#define drizzle_declare_plugin(NAME) \
104
88
__DRIZZLE_DECLARE_PLUGIN(NAME, \
105
89
                 builtin_ ## NAME ## _plugin)
106
90
 
107
 
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
91
#define drizzle_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
108
92
 
109
93
/*
110
94
  declarations for SHOW STATUS support in plugins
113
97
{
114
98
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
115
99
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
116
 
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
100
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, SHOW_SIZE
117
101
};
118
102
 
119
103
struct st_mysql_show_var {
124
108
 
125
109
 
126
110
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
127
 
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
111
typedef int (*mysql_show_var_func)(Session *, struct st_mysql_show_var *, char *);
128
112
 
129
113
struct st_show_var_func_container {
130
114
  mysql_show_var_func func;
142
126
#define PLUGIN_VAR_ENUM         0x0006
143
127
#define PLUGIN_VAR_SET          0x0007
144
128
#define PLUGIN_VAR_UNSIGNED     0x0080
145
 
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
 
129
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
146
130
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
147
131
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
148
132
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
157
141
/*
158
142
  SYNOPSIS
159
143
    (*mysql_var_check_func)()
160
 
      thd               thread handle
 
144
      session               thread handle
161
145
      var               dynamic variable being altered
162
146
      save              pointer to temporary storage
163
147
      value             user provided value
164
148
  RETURN
165
149
    0   user provided value is OK and the update func may be called.
166
150
    any other value indicates error.
167
 
  
 
151
 
168
152
  This function should parse the user provided value and store in the
169
153
  provided temporary storage any data as required by the update func.
170
154
  There is sufficient space in the temporary storage to store a double.
173
157
  automatically at the end of the statement.
174
158
*/
175
159
 
176
 
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
160
typedef int (*mysql_var_check_func)(Session *session,
177
161
                                    struct st_mysql_sys_var *var,
178
162
                                    void *save, struct st_mysql_value *value);
179
163
 
180
164
/*
181
165
  SYNOPSIS
182
166
    (*mysql_var_update_func)()
183
 
      thd               thread handle
 
167
      session               thread handle
184
168
      var               dynamic variable being altered
185
169
      var_ptr           pointer to dynamic variable
186
170
      save              pointer to temporary storage
187
171
   RETURN
188
172
     NONE
189
 
   
 
173
 
190
174
   This function should use the validated value stored in the temporary store
191
175
   and persist it in the provided pointer to the dynamic variable.
192
176
   For example, strings may require memory to be allocated.
193
177
*/
194
 
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
178
typedef void (*mysql_var_update_func)(Session *session,
195
179
                                      struct st_mysql_sys_var *var,
196
180
                                      void *var_ptr, const void *save);
197
181
 
221
205
  for thread variables, the value offset is the first
222
206
  element after the header, the default value is the second.
223
207
*/
224
 
   
 
208
 
225
209
 
226
210
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
227
211
  DRIZZLE_PLUGIN_VAR_HEADER;      \
242
226
  TYPELIB *typelib;             \
243
227
} DRIZZLE_SYSVAR_NAME(name)
244
228
 
245
 
#define DECLARE_THDVAR_FUNC(type) \
246
 
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
229
#define DECLARE_SessionVAR_FUNC(type) \
 
230
  type *(*resolve)(Session *session, int offset)
247
231
 
248
 
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
 
232
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
249
233
  DRIZZLE_PLUGIN_VAR_HEADER;      \
250
234
  int offset;                   \
251
235
  const type def_val;           \
252
 
  DECLARE_THDVAR_FUNC(type);    \
 
236
  DECLARE_SessionVAR_FUNC(type);    \
253
237
} DRIZZLE_SYSVAR_NAME(name)
254
238
 
255
 
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
 
239
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
256
240
  DRIZZLE_PLUGIN_VAR_HEADER;      \
257
241
  int offset;                   \
258
242
  type def_val; type min_val;   \
259
243
  type max_val; type blk_sz;    \
260
 
  DECLARE_THDVAR_FUNC(type);    \
 
244
  DECLARE_SessionVAR_FUNC(type);    \
261
245
} DRIZZLE_SYSVAR_NAME(name)
262
246
 
263
 
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
 
247
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
264
248
  DRIZZLE_PLUGIN_VAR_HEADER;      \
265
249
  int offset;                   \
266
250
  type def_val;                 \
267
 
  DECLARE_THDVAR_FUNC(type);    \
 
251
  DECLARE_SessionVAR_FUNC(type);    \
268
252
  TYPELIB *typelib;             \
269
253
} DRIZZLE_SYSVAR_NAME(name)
270
254
 
323
307
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
324
308
  #name, comment, check, update, &varname, def, typelib }
325
309
 
326
 
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
327
 
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
328
 
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
329
 
  #name, comment, check, update, -1, def, NULL}
330
 
 
331
 
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
332
 
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
333
 
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
334
 
  #name, comment, check, update, -1, def, NULL}
335
 
 
336
 
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
337
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
338
 
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
339
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
340
 
 
341
 
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
342
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
343
 
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
344
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
345
 
 
346
 
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
347
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
348
 
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
349
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
350
 
 
351
 
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
352
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
353
 
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
354
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
355
 
 
356
 
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
357
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
358
 
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
359
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
360
 
 
361
 
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
362
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
363
 
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
364
 
  #name, comment, check, update, -1, def, min, max, blk, NULL }
365
 
 
366
 
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
367
 
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
368
 
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
310
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
311
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
312
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
313
  #name, comment, check, update, -1, def, NULL}
 
314
 
 
315
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
316
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
317
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
318
  #name, comment, check, update, -1, def, NULL}
 
319
 
 
320
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
321
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
322
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
323
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
324
 
 
325
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
326
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
327
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
328
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
329
 
 
330
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
331
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
332
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
333
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
334
 
 
335
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
336
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
337
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
338
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
339
 
 
340
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
341
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
342
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
343
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
344
 
 
345
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
346
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
347
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
348
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
349
 
 
350
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
351
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
 
352
  PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
369
353
  #name, comment, check, update, -1, def, NULL, typelib }
370
354
 
371
 
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
372
 
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
373
 
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
355
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
 
356
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
 
357
  PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
374
358
  #name, comment, check, update, -1, def, NULL, typelib }
375
359
 
376
360
/* accessor macros */
378
362
#define SYSVAR(name) \
379
363
  (*(DRIZZLE_SYSVAR_NAME(name).value))
380
364
 
381
 
/* when thd == null, result points to global value */
382
 
#define THDVAR(thd, name) \
383
 
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(thd, DRIZZLE_SYSVAR_NAME(name).offset)))
 
365
/* when session == null, result points to global value */
 
366
#define SessionVAR(session, name) \
 
367
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
384
368
 
385
369
 
386
370
/*
389
373
 
390
374
struct st_mysql_plugin
391
375
{
392
 
  int type;             /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
 
376
  uint32_t type;        /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
393
377
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
394
378
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
395
379
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
399
383
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
400
384
  struct st_mysql_show_var *status_vars;
401
385
  struct st_mysql_sys_var **system_vars;
402
 
  void * __reserved1;   /* reserved for dependency checking             */
 
386
  void *reserved1;   /* reserved for dependency checking             */
403
387
};
404
388
 
405
389
struct handlerton;
406
390
 
407
391
 
 
392
class Plugin
 
393
{
 
394
private:
 
395
  std::string name;
 
396
  std::string version;
 
397
  std::string author;
 
398
  std::string description;
 
399
 
 
400
public:
 
401
  Plugin(std::string in_name, std::string in_version,
 
402
         std::string in_author, std::string in_description)
 
403
    : name(in_name), version(in_version),
 
404
    author(in_author), description(in_description)
 
405
  {}
 
406
 
 
407
  virtual ~Plugin() {}
 
408
 
 
409
  virtual void add_functions() {}
 
410
 
 
411
};
 
412
 
408
413
/*************************************************************************
409
414
  st_mysql_value struct for reading values from mysqld.
410
415
  Used by server variables framework to parse user-provided values.
436
441
extern "C" {
437
442
#endif
438
443
 
439
 
int thd_in_lock_tables(const DRIZZLE_THD thd);
440
 
int thd_tablespace_op(const DRIZZLE_THD thd);
441
 
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
442
 
int thd_sql_command(const DRIZZLE_THD thd);
443
 
const char *thd_proc_info(DRIZZLE_THD thd, const char *info);
444
 
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
445
 
int thd_tx_isolation(const DRIZZLE_THD thd);
446
 
/* Increments the row counter, see THD::row_count */
447
 
void thd_inc_row_count(DRIZZLE_THD thd);
 
444
int session_in_lock_tables(const Session *session);
 
445
int session_tablespace_op(const Session *session);
 
446
void set_session_proc_info(Session *session, const char *info);
 
447
const char *get_session_proc_info(Session *session);
 
448
int64_t session_test_options(const Session *session, int64_t test_options);
 
449
int session_sql_command(const Session *session);
 
450
void **session_ha_data(const Session *session, const struct handlerton *hton);
 
451
int session_tx_isolation(const Session *session);
 
452
/* Increments the row counter, see Session::row_count */
 
453
void session_inc_row_count(Session *session);
 
454
 
 
455
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
 
456
                                    const char *str, unsigned int size,
 
457
                                    int allocate_lex_string);
 
458
 
 
459
 
448
460
 
449
461
/**
450
462
  Create a temporary file.
470
482
  time-consuming loops, and gracefully abort the operation if it is
471
483
  non-zero.
472
484
 
473
 
  @param thd  user thread connection handle
 
485
  @param session  user thread connection handle
474
486
  @retval 0  the connection is active
475
487
  @retval 1  the connection has been killed
476
488
*/
477
 
int thd_killed(const DRIZZLE_THD thd);
 
489
int session_killed(const Session *session);
478
490
 
479
491
 
480
492
/**
481
493
  Return the thread id of a user thread
482
494
 
483
 
  @param thd  user thread connection handle
 
495
  @param session  user thread connection handle
484
496
  @return  thread id
485
497
*/
486
 
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
498
unsigned long session_get_thread_id(const Session *session);
487
499
 
488
500
 
489
501
/**
490
502
  Allocate memory in the connection's local memory pool
491
503
 
492
504
  @details
493
 
  When properly used in place of @c my_malloc(), this can significantly
 
505
  When properly used in place of @c malloc(), this can significantly
494
506
  improve concurrency. Don't use this or related functions to allocate
495
507
  large chunks of memory. Use for temporary storage only. The memory
496
508
  will be freed automatically at the end of the statement; no explicit
498
510
 
499
511
  @see alloc_root()
500
512
*/
501
 
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
502
 
/**
503
 
  @see thd_alloc()
504
 
*/
505
 
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
506
 
/**
507
 
  @see thd_alloc()
508
 
*/
509
 
char *thd_strdup(DRIZZLE_THD thd, const char *str);
510
 
/**
511
 
  @see thd_alloc()
512
 
*/
513
 
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
514
 
/**
515
 
  @see thd_alloc()
516
 
*/
517
 
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
518
 
 
519
 
/**
520
 
  Create a LEX_STRING in this connection's local memory pool
521
 
 
522
 
  @param thd      user thread connection handle
523
 
  @param lex_str  pointer to LEX_STRING object to be initialized
524
 
  @param str      initializer to be copied into lex_str
525
 
  @param size     length of str, in bytes
526
 
  @param allocate_lex_string  flag: if TRUE, allocate new LEX_STRING object,
527
 
                              instead of using lex_str value
528
 
  @return  NULL on failure, or pointer to the LEX_STRING object
529
 
 
530
 
  @see thd_alloc()
531
 
*/
532
 
DRIZZLE_LEX_STRING *thd_make_lex_string(DRIZZLE_THD thd, DRIZZLE_LEX_STRING *lex_str,
533
 
                                      const char *str, unsigned int size,
534
 
                                      int allocate_lex_string);
 
513
void *session_alloc(Session *session, unsigned int size);
 
514
/**
 
515
  @see session_alloc()
 
516
*/
 
517
void *session_calloc(Session *session, unsigned int size);
 
518
/**
 
519
  @see session_alloc()
 
520
*/
 
521
char *session_strdup(Session *session, const char *str);
 
522
/**
 
523
  @see session_alloc()
 
524
*/
 
525
char *session_strmake(Session *session, const char *str, unsigned int size);
 
526
/**
 
527
  @see session_alloc()
 
528
*/
 
529
void *session_memdup(Session *session, const void* str, unsigned int size);
535
530
 
536
531
/**
537
532
  Get the XID for this connection's transaction
538
533
 
539
 
  @param thd  user thread connection handle
 
534
  @param session  user thread connection handle
540
535
  @param xid  location where identifier is stored
541
536
*/
542
 
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
537
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
543
538
 
544
539
/**
545
540
  Invalidate the query cache for a given table.
546
541
 
547
 
  @param thd         user thread connection handle
 
542
  @param session         user thread connection handle
548
543
  @param key         databasename\\0tablename\\0
549
544
  @param key_length  length of key in bytes, including the NUL bytes
550
545
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
551
546
*/
552
 
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
547
void mysql_query_cache_invalidate4(Session *session,
553
548
                                   const char *key, unsigned int key_length,
554
549
                                   int using_trx);
555
550
 
563
558
*/
564
559
inline
565
560
void *
566
 
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
561
session_get_ha_data(const Session *session, const struct handlerton *hton)
567
562
{
568
 
  return *thd_ha_data(thd, hton);
 
563
  return *session_ha_data(session, hton);
569
564
}
570
565
 
571
566
/**
573
568
*/
574
569
inline
575
570
void
576
 
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
571
session_set_ha_data(const Session *session, const struct handlerton *hton,
577
572
                const void *ha_data)
578
573
{
579
 
  *thd_ha_data(thd, hton)= (void*) ha_data;
 
574
  *session_ha_data(session, hton)= (void*) ha_data;
580
575
}
581
576
#endif
582
577
 
583
 
#endif
 
578
#endif /* _my_plugin_h */
584
579