~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Stewart Smith
  • Date: 2009-10-19 04:17:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1192.
  • Revision ID: stewart@flamingspork.com-20091019041738-bsjyzmittghcomqj
remove some unused PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP related things as errorcheck mutexes are never used (and haven't been since at least MySQL 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef DRIZZLED_PLUGIN_H
21
21
#define DRIZZLED_PLUGIN_H
22
22
 
23
 
#include <boost/program_options.hpp>
24
 
#include <boost/filesystem.hpp>
25
 
 
26
 
#include "drizzled/module/manifest.h"
27
 
#include "drizzled/module/module.h"
28
 
#include "drizzled/plugin/version.h"
29
 
#include "drizzled/module/context.h"
30
 
#include "drizzled/definitions.h"
31
 
 
32
 
#include "drizzled/lex_string.h"
33
 
#include "drizzled/sys_var.h"
34
 
#include "drizzled/xid.h"
35
 
 
36
 
namespace drizzled
37
 
{
 
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/handle.h>
38
28
 
39
29
class Session;
40
30
class Item;
46
36
 
47
37
 
48
38
class sys_var;
49
 
typedef drizzle_lex_string LEX_STRING;
50
 
struct option;
51
 
 
52
 
extern boost::filesystem::path plugin_dir;
53
 
 
54
 
namespace plugin { class StorageEngine; }
 
39
typedef struct st_mysql_lex_string LEX_STRING;
 
40
struct my_option;
 
41
 
 
42
extern char *opt_plugin_load;
 
43
extern char *opt_plugin_dir_ptr;
 
44
extern char opt_plugin_dir[FN_REFLEN];
 
45
 
 
46
namespace drizzled { namespace plugin { class StorageEngine; } }
55
47
 
56
48
/*
57
49
  Macros for beginning and ending plugin declarations. Between
58
 
  DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
59
 
  be a module::Manifest for each plugin to be declared.
60
 
*/
61
 
 
62
 
 
63
 
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
64
 
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
65
 
#define DRIZZLE_DECLARE_PLUGIN \
66
 
  ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
67
 
 
68
 
 
69
 
#define DRIZZLE_DECLARE_PLUGIN_END
70
 
#define DRIZZLE_PLUGIN(init,system,options) \
71
 
  DRIZZLE_DECLARE_PLUGIN \
72
 
  { \
73
 
    DRIZZLE_VERSION_ID, \
74
 
    STRINGIFY_ARG(PANDORA_MODULE_NAME), \
75
 
    STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
76
 
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
77
 
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
78
 
    PANDORA_MODULE_LICENSE, \
79
 
    init, system, options \
80
 
  } 
81
 
 
82
 
 
 
50
  drizzle_declare_plugin and drizzle_declare_plugin_end there should
 
51
  be a drizzled::plugin::Manifest for each plugin to be declared.
 
52
*/
 
53
 
 
54
 
 
55
#ifndef PANDORA_DYNAMIC_PLUGIN
 
56
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
57
drizzled::plugin::Manifest DECLS[]= {
 
58
#else
 
59
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
60
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
 
61
#endif
 
62
 
 
63
#define drizzle_declare_plugin(NAME) \
 
64
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
65
                 builtin_ ## NAME ## _plugin)
 
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
 
79
 
 
80
/*
 
81
  declarations for SHOW STATUS support in plugins
 
82
*/
 
83
enum enum_mysql_show_type
 
84
{
 
85
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
86
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
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
 
91
};
 
92
 
 
93
struct st_mysql_show_var {
 
94
  const char *name;
 
95
  char *value;
 
96
  enum enum_mysql_show_type type;
 
97
};
 
98
 
 
99
typedef enum enum_mysql_show_type SHOW_TYPE;
 
100
typedef struct st_mysql_show_var SHOW_VAR;
 
101
 
 
102
 
 
103
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
104
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
 
105
 
 
106
struct st_show_var_func_container {
 
107
  mysql_show_var_func func;
 
108
};
83
109
/*
84
110
  declarations for server variables and command line options
85
111
*/
90
116
#define PLUGIN_VAR_LONG         0x0003
91
117
#define PLUGIN_VAR_LONGLONG     0x0004
92
118
#define PLUGIN_VAR_STR          0x0005
 
119
#define PLUGIN_VAR_ENUM         0x0006
 
120
#define PLUGIN_VAR_SET          0x0007
93
121
#define PLUGIN_VAR_UNSIGNED     0x0080
94
122
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
95
123
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
100
128
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
101
129
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
102
130
 
103
 
struct drizzle_sys_var;
104
 
struct drizzle_value;
 
131
struct st_mysql_sys_var;
 
132
struct st_mysql_value;
105
133
 
106
134
/*
107
135
  SYNOPSIS
123
151
*/
124
152
 
125
153
typedef int (*mysql_var_check_func)(Session *session,
126
 
                                    drizzle_sys_var *var,
127
 
                                    void *save, drizzle_value *value);
 
154
                                    struct st_mysql_sys_var *var,
 
155
                                    void *save, struct st_mysql_value *value);
128
156
 
129
157
/*
130
158
  SYNOPSIS
141
169
   For example, strings may require memory to be allocated.
142
170
*/
143
171
typedef void (*mysql_var_update_func)(Session *session,
144
 
                                      drizzle_sys_var *var,
 
172
                                      struct st_mysql_sys_var *var,
145
173
                                      void *var_ptr, const void *save);
146
174
 
147
175
 
148
 
 
149
 
/*
150
 
  skeleton of a plugin variable - portion of structure common to all.
151
 
*/
152
 
struct drizzle_sys_var
153
 
{
154
 
};
155
 
 
156
 
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
157
 
 
158
 
struct drizzle_value
159
 
{
160
 
  int (*value_type)(drizzle_value *);
161
 
  const char *(*val_str)(drizzle_value *, char *buffer, int *length);
162
 
  int (*val_real)(drizzle_value *, double *realbuf);
163
 
  int (*val_int)(drizzle_value *, int64_t *intbuf);
 
176
/* the following declarations are for internal use only */
 
177
 
 
178
 
 
179
#define PLUGIN_VAR_MASK \
 
180
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
181
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
182
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
183
 
 
184
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
185
  int flags;                    \
 
186
  const char *name;             \
 
187
  const char *comment;          \
 
188
  mysql_var_check_func check;   \
 
189
  mysql_var_update_func update
 
190
 
 
191
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
192
#define DRIZZLE_SYSVAR(name) \
 
193
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
194
 
 
195
/*
 
196
  for global variables, the value pointer is the first
 
197
  element after the header, the default value is the second.
 
198
  for thread variables, the value offset is the first
 
199
  element after the header, the default value is the second.
 
200
*/
 
201
 
 
202
 
 
203
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
204
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
205
  type *value;                  \
 
206
  const type def_val;           \
 
207
} DRIZZLE_SYSVAR_NAME(name)
 
208
 
 
209
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
210
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
211
  type *value; type def_val;    \
 
212
  type min_val; type max_val;   \
 
213
  type blk_sz;                  \
 
214
} DRIZZLE_SYSVAR_NAME(name)
 
215
 
 
216
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
 
217
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
218
  type *value; type def_val;    \
 
219
  TYPELIB *typelib;             \
 
220
} DRIZZLE_SYSVAR_NAME(name)
 
221
 
 
222
#define DECLARE_SessionVAR_FUNC(type) \
 
223
  type *(*resolve)(Session *session, int offset)
 
224
 
 
225
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
226
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
227
  int offset;                   \
 
228
  const type def_val;           \
 
229
  DECLARE_SessionVAR_FUNC(type);    \
 
230
} DRIZZLE_SYSVAR_NAME(name)
 
231
 
 
232
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
233
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
234
  int offset;                   \
 
235
  type def_val; type min_val;   \
 
236
  type max_val; type blk_sz;    \
 
237
  DECLARE_SessionVAR_FUNC(type);    \
 
238
} DRIZZLE_SYSVAR_NAME(name)
 
239
 
 
240
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
241
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
242
  int offset;                   \
 
243
  type def_val;                 \
 
244
  DECLARE_SessionVAR_FUNC(type);    \
 
245
  TYPELIB *typelib;             \
 
246
} DRIZZLE_SYSVAR_NAME(name)
 
247
 
 
248
 
 
249
/*
 
250
  the following declarations are for use by plugin implementors
 
251
*/
 
252
 
 
253
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
254
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
255
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
256
  #name, comment, check, update, &varname, def}
 
257
 
 
258
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
259
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
260
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
261
  #name, comment, check, update, &varname, def}
 
262
 
 
263
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
264
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
265
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
266
  #name, comment, check, update, &varname, def, min, max, blk }
 
267
 
 
268
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
269
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
270
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
271
  #name, comment, check, update, &varname, def, min, max, blk }
 
272
 
 
273
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
274
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
275
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
276
  #name, comment, check, update, &varname, def, min, max, blk }
 
277
 
 
278
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
279
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
280
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
281
  #name, comment, check, update, &varname, def, min, max, blk }
 
282
 
 
283
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
284
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
285
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
286
  #name, comment, check, update, &varname, def, min, max, blk }
 
287
 
 
288
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
289
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
290
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
291
  #name, comment, check, update, &varname, def, min, max, blk }
 
292
 
 
293
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
294
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
295
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
296
  #name, comment, check, update, &varname, def, typelib }
 
297
 
 
298
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
299
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
300
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
301
  #name, comment, check, update, &varname, def, typelib }
 
302
 
 
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), \
 
346
  #name, comment, check, update, -1, def, NULL, typelib }
 
347
 
 
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), \
 
351
  #name, comment, check, update, -1, def, NULL, typelib }
 
352
 
 
353
/* accessor macros */
 
354
 
 
355
#define SYSVAR(name) \
 
356
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
357
 
 
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)))
 
361
 
 
362
 
 
363
/*************************************************************************
 
364
  st_mysql_value struct for reading values from mysqld.
 
365
  Used by server variables framework to parse user-provided values.
 
366
  Will be used for arguments when implementing UDFs.
 
367
 
 
368
  Note that val_str() returns a string in temporary memory
 
369
  that will be freed at the end of statement. Copy the string
 
370
  if you need it to persist.
 
371
*/
 
372
 
 
373
#define DRIZZLE_VALUE_TYPE_STRING 0
 
374
#define DRIZZLE_VALUE_TYPE_REAL   1
 
375
#define DRIZZLE_VALUE_TYPE_INT    2
 
376
 
 
377
struct st_mysql_value
 
378
{
 
379
  int (*value_type)(struct st_mysql_value *);
 
380
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
381
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
382
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
164
383
};
165
384
 
166
385
 
168
387
  Miscellaneous functions for plugin implementors
169
388
*/
170
389
 
171
 
extern bool plugin_init(module::Registry &registry,
172
 
                        boost::program_options::options_description &long_options);
173
 
extern bool plugin_finalize(module::Registry &registry);
174
 
extern void my_print_help_inc_plugins(option *options);
 
390
#ifdef __cplusplus
 
391
extern "C" {
 
392
#endif
 
393
 
 
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);
175
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);
176
402
extern void plugin_sessionvar_init(Session *session);
177
403
extern void plugin_sessionvar_cleanup(Session *session);
178
404
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
183
409
const char *get_session_proc_info(Session *session);
184
410
int64_t session_test_options(const Session *session, int64_t test_options);
185
411
int session_sql_command(const Session *session);
186
 
enum_tx_isolation session_tx_isolation(const Session *session);
187
 
 
188
 
void compose_plugin_add(std::vector<std::string> options);
189
 
void compose_plugin_remove(std::vector<std::string> options);
190
 
void notify_plugin_load(std::string in_plugin_load);
 
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
 
191
421
 
192
422
 
193
423
/**
200
430
 
201
431
  @param prefix  prefix for temporary file name
202
432
  @retval -1    error
203
 
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
 
433
  @retval >= 0  a file handle that can be passed to dup or my_close
204
434
*/
205
435
int mysql_tmpfile(const char *prefix);
206
436
 
207
 
} /* namespace drizzled */
208
 
 
209
 
#endif /* DRIZZLED_PLUGIN_H */
 
437
/**
 
438
  Check the killed state of a connection
 
439
 
 
440
  @details
 
441
  In MySQL support for the KILL statement is cooperative. The KILL
 
442
  statement only sets a "killed" flag. This function returns the value
 
443
  of that flag.  A thread should check it often, especially inside
 
444
  time-consuming loops, and gracefully abort the operation if it is
 
445
  non-zero.
 
446
 
 
447
  @param session  user thread connection handle
 
448
  @retval 0  the connection is active
 
449
  @retval 1  the connection has been killed
 
450
*/
 
451
int session_killed(const Session *session);
 
452
 
 
453
 
 
454
/**
 
455
  Return the thread id of a user thread
 
456
 
 
457
  @param session  user thread connection handle
 
458
  @return  thread id
 
459
*/
 
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);
 
466
 
 
467
 
 
468
/**
 
469
  Allocate memory in the connection's local memory pool
 
470
 
 
471
  @details
 
472
  When properly used in place of @c malloc(), this can significantly
 
473
  improve concurrency. Don't use this or related functions to allocate
 
474
  large chunks of memory. Use for temporary storage only. The memory
 
475
  will be freed automatically at the end of the statement; no explicit
 
476
  code is required to prevent memory leaks.
 
477
 
 
478
  @see alloc_root()
 
479
*/
 
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);
 
497
 
 
498
/**
 
499
  Get the XID for this connection's transaction
 
500
 
 
501
  @param session  user thread connection handle
 
502
  @param xid  location where identifier is stored
 
503
*/
 
504
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
 
505
 
 
506
/**
 
507
  Invalidate the query cache for a given table.
 
508
 
 
509
  @param session         user thread connection handle
 
510
  @param key         databasename\\0tablename\\0
 
511
  @param key_length  length of key in bytes, including the NUL bytes
 
512
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
513
*/
 
514
void mysql_query_cache_invalidate4(Session *session,
 
515
                                   const char *key, unsigned int key_length,
 
516
                                   int using_trx);
 
517
 
 
518
#ifdef __cplusplus
 
519
}
 
520
#endif
 
521
 
 
522
#ifdef __cplusplus
 
523
/**
 
524
  Provide a handler data getter to simplify coding
 
525
*/
 
526
inline
 
527
void *
 
528
session_get_ha_data(const Session *session, const drizzled::plugin::StorageEngine *engine)
 
529
{
 
530
  return *session_ha_data(session, engine);
 
531
}
 
532
 
 
533
/**
 
534
  Provide a handler data setter to simplify coding
 
535
*/
 
536
inline
 
537
void
 
538
session_set_ha_data(const Session *session, const drizzled::plugin::StorageEngine *engine,
 
539
                const void *ha_data)
 
540
{
 
541
  *session_ha_data(session, engine)= (void*) ha_data;
 
542
}
 
543
#endif
 
544
 
 
545
#endif /* _my_plugin_h */
210
546