~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2009-08-21 18:46:31 UTC
  • mto: This revision was merged to the branch mainline in revision 1123.
  • Revision ID: brian@gaz-20090821184631-e11gja79070fvhk4
Cleanup around page checksum removal

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
22
 
 
23
 
#include <drizzled/global.h>
24
 
 
25
 
#ifdef __cplusplus
26
 
class THD;
 
20
#ifndef DRIZZLED_PLUGIN_H
 
21
#define DRIZZLED_PLUGIN_H
 
22
 
 
23
#include <drizzled/lex_string.h>
 
24
#include <drizzled/xid.h>
 
25
 
 
26
class Session;
27
27
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;
 
28
struct charset_info_st;
60
29
 
61
30
/*************************************************************************
62
31
  Plugin API. Common for all plugin types.
63
32
*/
64
33
 
65
 
/*
66
 
  The allowable types of plugins
67
 
*/
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 */
76
 
 
77
 
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
78
 
 
79
 
/* 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
83
 
 
84
 
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
85
 
#define PLUGIN_LICENSE_GPL_STRING "GPL"
86
 
#define PLUGIN_LICENSE_BSD_STRING "BSD"
87
 
 
88
 
/*
89
 
  Macros for beginning and ending plugin declarations.  Between
90
 
  mysql_declare_plugin and mysql_declare_plugin_end there should
91
 
  be a st_mysql_plugin struct for each plugin to be declared.
92
 
*/
93
 
 
94
 
 
95
 
#ifndef DRIZZLE_DYNAMIC_PLUGIN
 
34
 
 
35
/*
 
36
  Macros for beginning and ending plugin declarations. Between
 
37
  drizzle_declare_plugin and drizzle_declare_plugin_end there should
 
38
  be a drizzled::plugin::Manifest for each plugin to be declared.
 
39
*/
 
40
 
 
41
 
 
42
#ifndef PANDORA_DYNAMIC_PLUGIN
96
43
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
97
 
struct st_mysql_plugin DECLS[]= {
 
44
drizzled::plugin::Manifest DECLS[]= {
98
45
#else
99
46
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
100
 
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
47
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
101
48
#endif
102
49
 
103
 
#define mysql_declare_plugin(NAME) \
 
50
#define drizzle_declare_plugin(NAME) \
104
51
__DRIZZLE_DECLARE_PLUGIN(NAME, \
105
52
                 builtin_ ## NAME ## _plugin)
106
53
 
107
 
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
54
#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
 
55
 
 
56
 
 
57
 
 
58
/*
 
59
  the following flags are valid for plugin_init()
 
60
*/
 
61
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
 
62
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE    2
 
63
#define PLUGIN_INIT_SKIP_INITIALIZATION  4
 
64
 
 
65
#define INITIAL_LEX_PLUGIN_LIST_SIZE    16
108
66
 
109
67
/*
110
68
  declarations for SHOW STATUS support in plugins
113
71
{
114
72
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
115
73
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
116
 
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
74
  SHOW_ARRAY, SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
 
75
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, 
 
76
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
 
77
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
117
78
};
118
79
 
119
80
struct st_mysql_show_var {
122
83
  enum enum_mysql_show_type type;
123
84
};
124
85
 
 
86
typedef enum enum_mysql_show_type SHOW_TYPE;
 
87
typedef struct st_mysql_show_var SHOW_VAR;
 
88
 
125
89
 
126
90
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
127
 
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
91
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
128
92
 
129
93
struct st_show_var_func_container {
130
94
  mysql_show_var_func func;
142
106
#define PLUGIN_VAR_ENUM         0x0006
143
107
#define PLUGIN_VAR_SET          0x0007
144
108
#define PLUGIN_VAR_UNSIGNED     0x0080
145
 
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
 
109
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
146
110
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
147
111
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
148
112
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
157
121
/*
158
122
  SYNOPSIS
159
123
    (*mysql_var_check_func)()
160
 
      thd               thread handle
 
124
      session               thread handle
161
125
      var               dynamic variable being altered
162
126
      save              pointer to temporary storage
163
127
      value             user provided value
164
128
  RETURN
165
129
    0   user provided value is OK and the update func may be called.
166
130
    any other value indicates error.
167
 
  
 
131
 
168
132
  This function should parse the user provided value and store in the
169
133
  provided temporary storage any data as required by the update func.
170
134
  There is sufficient space in the temporary storage to store a double.
173
137
  automatically at the end of the statement.
174
138
*/
175
139
 
176
 
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
140
typedef int (*mysql_var_check_func)(Session *session,
177
141
                                    struct st_mysql_sys_var *var,
178
142
                                    void *save, struct st_mysql_value *value);
179
143
 
180
144
/*
181
145
  SYNOPSIS
182
146
    (*mysql_var_update_func)()
183
 
      thd               thread handle
 
147
      session               thread handle
184
148
      var               dynamic variable being altered
185
149
      var_ptr           pointer to dynamic variable
186
150
      save              pointer to temporary storage
187
151
   RETURN
188
152
     NONE
189
 
   
 
153
 
190
154
   This function should use the validated value stored in the temporary store
191
155
   and persist it in the provided pointer to the dynamic variable.
192
156
   For example, strings may require memory to be allocated.
193
157
*/
194
 
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
158
typedef void (*mysql_var_update_func)(Session *session,
195
159
                                      struct st_mysql_sys_var *var,
196
160
                                      void *var_ptr, const void *save);
197
161
 
221
185
  for thread variables, the value offset is the first
222
186
  element after the header, the default value is the second.
223
187
*/
224
 
   
 
188
 
225
189
 
226
190
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
227
191
  DRIZZLE_PLUGIN_VAR_HEADER;      \
242
206
  TYPELIB *typelib;             \
243
207
} DRIZZLE_SYSVAR_NAME(name)
244
208
 
245
 
#define DECLARE_THDVAR_FUNC(type) \
246
 
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
209
#define DECLARE_SessionVAR_FUNC(type) \
 
210
  type *(*resolve)(Session *session, int offset)
247
211
 
248
 
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
 
212
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
249
213
  DRIZZLE_PLUGIN_VAR_HEADER;      \
250
214
  int offset;                   \
251
215
  const type def_val;           \
252
 
  DECLARE_THDVAR_FUNC(type);    \
 
216
  DECLARE_SessionVAR_FUNC(type);    \
253
217
} DRIZZLE_SYSVAR_NAME(name)
254
218
 
255
 
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
 
219
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
256
220
  DRIZZLE_PLUGIN_VAR_HEADER;      \
257
221
  int offset;                   \
258
222
  type def_val; type min_val;   \
259
223
  type max_val; type blk_sz;    \
260
 
  DECLARE_THDVAR_FUNC(type);    \
 
224
  DECLARE_SessionVAR_FUNC(type);    \
261
225
} DRIZZLE_SYSVAR_NAME(name)
262
226
 
263
 
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
 
227
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
264
228
  DRIZZLE_PLUGIN_VAR_HEADER;      \
265
229
  int offset;                   \
266
230
  type def_val;                 \
267
 
  DECLARE_THDVAR_FUNC(type);    \
 
231
  DECLARE_SessionVAR_FUNC(type);    \
268
232
  TYPELIB *typelib;             \
269
233
} DRIZZLE_SYSVAR_NAME(name)
270
234
 
323
287
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
324
288
  #name, comment, check, update, &varname, def, typelib }
325
289
 
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), \
 
290
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
291
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
292
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
293
  #name, comment, check, update, -1, def, NULL}
 
294
 
 
295
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
296
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
297
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
298
  #name, comment, check, update, -1, def, NULL}
 
299
 
 
300
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
301
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
302
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
303
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
304
 
 
305
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
306
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
307
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
308
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
309
 
 
310
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
311
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
312
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
313
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
314
 
 
315
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
316
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
317
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
318
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
319
 
 
320
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
321
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
322
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
323
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
324
 
 
325
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
326
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
327
  PLUGIN_VAR_LONGLONG | 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_ENUM(name, opt, comment, check, update, def, typelib) \
 
331
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
 
332
  PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
369
333
  #name, comment, check, update, -1, def, NULL, typelib }
370
334
 
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), \
 
335
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
 
336
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
 
337
  PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
374
338
  #name, comment, check, update, -1, def, NULL, typelib }
375
339
 
376
340
/* accessor macros */
378
342
#define SYSVAR(name) \
379
343
  (*(DRIZZLE_SYSVAR_NAME(name).value))
380
344
 
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)))
384
 
 
385
 
 
386
 
/*
387
 
  Plugin description structure.
388
 
*/
389
 
 
390
 
struct st_mysql_plugin
 
345
/* when session == null, result points to global value */
 
346
#define SessionVAR(session, name) \
 
347
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
 
348
 
 
349
 
 
350
struct StorageEngine;
 
351
 
 
352
 
 
353
class Plugin
391
354
{
392
 
  int type;             /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
393
 
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
394
 
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
395
 
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
396
 
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
397
 
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
398
 
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
399
 
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
400
 
  struct st_mysql_show_var *status_vars;
401
 
  struct st_mysql_sys_var **system_vars;
402
 
  void * __reserved1;   /* reserved for dependency checking             */
 
355
private:
 
356
  std::string name;
 
357
  std::string version;
 
358
  std::string author;
 
359
  std::string description;
 
360
 
 
361
public:
 
362
  Plugin(std::string in_name, std::string in_version,
 
363
         std::string in_author, std::string in_description)
 
364
    : name(in_name), version(in_version),
 
365
    author(in_author), description(in_description)
 
366
  {}
 
367
 
 
368
  virtual ~Plugin() {}
 
369
 
 
370
  virtual void add_functions() {}
 
371
 
403
372
};
404
373
 
405
 
struct handlerton;
406
 
 
407
 
 
408
374
/*************************************************************************
409
375
  st_mysql_value struct for reading values from mysqld.
410
376
  Used by server variables framework to parse user-provided values.
436
402
extern "C" {
437
403
#endif
438
404
 
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);
 
405
int session_in_lock_tables(const Session *session);
 
406
int session_tablespace_op(const Session *session);
 
407
void set_session_proc_info(Session *session, const char *info);
 
408
const char *get_session_proc_info(Session *session);
 
409
int64_t session_test_options(const Session *session, int64_t test_options);
 
410
int session_sql_command(const Session *session);
 
411
void **session_ha_data(const Session *session, const struct StorageEngine *engine);
 
412
int session_tx_isolation(const Session *session);
 
413
/* Increments the row counter, see Session::row_count */
 
414
void session_inc_row_count(Session *session);
 
415
 
 
416
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
 
417
                                    const char *str, unsigned int size,
 
418
                                    int allocate_lex_string);
 
419
 
 
420
 
448
421
 
449
422
/**
450
423
  Create a temporary file.
470
443
  time-consuming loops, and gracefully abort the operation if it is
471
444
  non-zero.
472
445
 
473
 
  @param thd  user thread connection handle
 
446
  @param session  user thread connection handle
474
447
  @retval 0  the connection is active
475
448
  @retval 1  the connection has been killed
476
449
*/
477
 
int thd_killed(const DRIZZLE_THD thd);
 
450
int session_killed(const Session *session);
478
451
 
479
452
 
480
453
/**
481
454
  Return the thread id of a user thread
482
455
 
483
 
  @param thd  user thread connection handle
 
456
  @param session  user thread connection handle
484
457
  @return  thread id
485
458
*/
486
 
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);
487
465
 
488
466
 
489
467
/**
490
468
  Allocate memory in the connection's local memory pool
491
469
 
492
470
  @details
493
 
  When properly used in place of @c my_malloc(), this can significantly
 
471
  When properly used in place of @c malloc(), this can significantly
494
472
  improve concurrency. Don't use this or related functions to allocate
495
473
  large chunks of memory. Use for temporary storage only. The memory
496
474
  will be freed automatically at the end of the statement; no explicit
498
476
 
499
477
  @see alloc_root()
500
478
*/
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);
 
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);
535
496
 
536
497
/**
537
498
  Get the XID for this connection's transaction
538
499
 
539
 
  @param thd  user thread connection handle
 
500
  @param session  user thread connection handle
540
501
  @param xid  location where identifier is stored
541
502
*/
542
 
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
503
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
543
504
 
544
505
/**
545
506
  Invalidate the query cache for a given table.
546
507
 
547
 
  @param thd         user thread connection handle
 
508
  @param session         user thread connection handle
548
509
  @param key         databasename\\0tablename\\0
549
510
  @param key_length  length of key in bytes, including the NUL bytes
550
511
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
551
512
*/
552
 
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
513
void mysql_query_cache_invalidate4(Session *session,
553
514
                                   const char *key, unsigned int key_length,
554
515
                                   int using_trx);
555
516
 
563
524
*/
564
525
inline
565
526
void *
566
 
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
527
session_get_ha_data(const Session *session, const struct StorageEngine *engine)
567
528
{
568
 
  return *thd_ha_data(thd, hton);
 
529
  return *session_ha_data(session, engine);
569
530
}
570
531
 
571
532
/**
573
534
*/
574
535
inline
575
536
void
576
 
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
537
session_set_ha_data(const Session *session, const struct StorageEngine *engine,
577
538
                const void *ha_data)
578
539
{
579
 
  *thd_ha_data(thd, hton)= (void*) ha_data;
 
540
  *session_ha_data(session, engine)= (void*) ha_data;
580
541
}
581
542
#endif
582
543
 
583
 
#endif
 
544
#endif /* _my_plugin_h */
584
545