~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

pandora-build v0.42 - Started splitting out plugin system into pandora-build

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>
38
25
 
39
26
class Session;
40
27
class Item;
41
 
struct charset_info_st;
42
28
 
43
29
/*************************************************************************
44
30
  Plugin API. Common for all plugin types.
45
31
*/
46
32
 
47
33
 
48
 
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; }
55
 
 
56
34
/*
57
35
  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
 
 
 
36
  drizzle_declare_plugin and drizzle_declare_plugin_end there should
 
37
  be a drizzled::plugin::Manifest for each plugin to be declared.
 
38
*/
 
39
 
 
40
 
 
41
#ifndef PANDORA_DYNAMIC_PLUGIN
 
42
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
43
drizzled::plugin::Manifest DECLS[]= {
 
44
#else
 
45
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
46
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
 
47
#endif
 
48
 
 
49
#define drizzle_declare_plugin(NAME) \
 
50
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
51
                 builtin_ ## NAME ## _plugin)
 
52
 
 
53
#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
 
54
 
 
55
 
 
56
 
 
57
/*
 
58
  the following flags are valid for plugin_init()
 
59
*/
 
60
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
 
61
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE    2
 
62
#define PLUGIN_INIT_SKIP_INITIALIZATION  4
 
63
 
 
64
#define INITIAL_LEX_PLUGIN_LIST_SIZE    16
 
65
 
 
66
/*
 
67
  declarations for SHOW STATUS support in plugins
 
68
*/
 
69
enum enum_mysql_show_type
 
70
{
 
71
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
72
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
73
  SHOW_ARRAY, SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG,
 
74
  SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, 
 
75
  SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_INT_NOFLUSH,
 
76
  SHOW_LONGLONG_STATUS, SHOW_DOUBLE, SHOW_SIZE
 
77
};
 
78
 
 
79
struct st_mysql_show_var {
 
80
  const char *name;
 
81
  char *value;
 
82
  enum enum_mysql_show_type type;
 
83
};
 
84
 
 
85
typedef enum enum_mysql_show_type SHOW_TYPE;
 
86
typedef struct st_mysql_show_var SHOW_VAR;
 
87
 
 
88
 
 
89
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
90
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
 
91
 
 
92
struct st_show_var_func_container {
 
93
  mysql_show_var_func func;
 
94
};
83
95
/*
84
96
  declarations for server variables and command line options
85
97
*/
90
102
#define PLUGIN_VAR_LONG         0x0003
91
103
#define PLUGIN_VAR_LONGLONG     0x0004
92
104
#define PLUGIN_VAR_STR          0x0005
 
105
#define PLUGIN_VAR_ENUM         0x0006
 
106
#define PLUGIN_VAR_SET          0x0007
93
107
#define PLUGIN_VAR_UNSIGNED     0x0080
94
108
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
95
109
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
100
114
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
101
115
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
102
116
 
103
 
struct drizzle_sys_var;
104
 
struct drizzle_value;
 
117
struct st_mysql_sys_var;
 
118
struct st_mysql_value;
105
119
 
106
120
/*
107
121
  SYNOPSIS
123
137
*/
124
138
 
125
139
typedef int (*mysql_var_check_func)(Session *session,
126
 
                                    drizzle_sys_var *var,
127
 
                                    void *save, drizzle_value *value);
 
140
                                    struct st_mysql_sys_var *var,
 
141
                                    void *save, struct st_mysql_value *value);
128
142
 
129
143
/*
130
144
  SYNOPSIS
141
155
   For example, strings may require memory to be allocated.
142
156
*/
143
157
typedef void (*mysql_var_update_func)(Session *session,
144
 
                                      drizzle_sys_var *var,
 
158
                                      struct st_mysql_sys_var *var,
145
159
                                      void *var_ptr, const void *save);
146
160
 
147
161
 
148
 
 
149
 
/*
150
 
  skeleton of a plugin variable - portion of structure common to all.
151
 
*/
152
 
struct drizzle_sys_var
 
162
/* the following declarations are for internal use only */
 
163
 
 
164
 
 
165
#define PLUGIN_VAR_MASK \
 
166
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
167
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
168
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
169
 
 
170
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
171
  int flags;                    \
 
172
  const char *name;             \
 
173
  const char *comment;          \
 
174
  mysql_var_check_func check;   \
 
175
  mysql_var_update_func update
 
176
 
 
177
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
178
#define DRIZZLE_SYSVAR(name) \
 
179
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
180
 
 
181
/*
 
182
  for global variables, the value pointer is the first
 
183
  element after the header, the default value is the second.
 
184
  for thread variables, the value offset is the first
 
185
  element after the header, the default value is the second.
 
186
*/
 
187
 
 
188
 
 
189
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
190
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
191
  type *value;                  \
 
192
  const type def_val;           \
 
193
} DRIZZLE_SYSVAR_NAME(name)
 
194
 
 
195
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
196
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
197
  type *value; type def_val;    \
 
198
  type min_val; type max_val;   \
 
199
  type blk_sz;                  \
 
200
} DRIZZLE_SYSVAR_NAME(name)
 
201
 
 
202
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
 
203
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
204
  type *value; type def_val;    \
 
205
  TYPELIB *typelib;             \
 
206
} DRIZZLE_SYSVAR_NAME(name)
 
207
 
 
208
#define DECLARE_SessionVAR_FUNC(type) \
 
209
  type *(*resolve)(Session *session, int offset)
 
210
 
 
211
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
212
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
213
  int offset;                   \
 
214
  const type def_val;           \
 
215
  DECLARE_SessionVAR_FUNC(type);    \
 
216
} DRIZZLE_SYSVAR_NAME(name)
 
217
 
 
218
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
219
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
220
  int offset;                   \
 
221
  type def_val; type min_val;   \
 
222
  type max_val; type blk_sz;    \
 
223
  DECLARE_SessionVAR_FUNC(type);    \
 
224
} DRIZZLE_SYSVAR_NAME(name)
 
225
 
 
226
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
227
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
228
  int offset;                   \
 
229
  type def_val;                 \
 
230
  DECLARE_SessionVAR_FUNC(type);    \
 
231
  TYPELIB *typelib;             \
 
232
} DRIZZLE_SYSVAR_NAME(name)
 
233
 
 
234
 
 
235
/*
 
236
  the following declarations are for use by plugin implementors
 
237
*/
 
238
 
 
239
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
240
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
241
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
242
  #name, comment, check, update, &varname, def}
 
243
 
 
244
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
245
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
246
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
247
  #name, comment, check, update, &varname, def}
 
248
 
 
249
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
250
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
251
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
252
  #name, comment, check, update, &varname, def, min, max, blk }
 
253
 
 
254
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
255
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
256
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
257
  #name, comment, check, update, &varname, def, min, max, blk }
 
258
 
 
259
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
260
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
261
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
262
  #name, comment, check, update, &varname, def, min, max, blk }
 
263
 
 
264
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
265
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
266
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
267
  #name, comment, check, update, &varname, def, min, max, blk }
 
268
 
 
269
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
270
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
271
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
272
  #name, comment, check, update, &varname, def, min, max, blk }
 
273
 
 
274
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
275
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
276
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
277
  #name, comment, check, update, &varname, def, min, max, blk }
 
278
 
 
279
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
280
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
281
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
282
  #name, comment, check, update, &varname, def, typelib }
 
283
 
 
284
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
285
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
286
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
287
  #name, comment, check, update, &varname, def, typelib }
 
288
 
 
289
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
290
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
 
291
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
292
  #name, comment, check, update, -1, def, NULL}
 
293
 
 
294
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
295
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
296
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
297
  #name, comment, check, update, -1, def, NULL}
 
298
 
 
299
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
300
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
301
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
302
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
303
 
 
304
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
305
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
306
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
307
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
308
 
 
309
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
310
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
311
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
312
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
313
 
 
314
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
315
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
316
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
317
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
318
 
 
319
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
320
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
321
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
322
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
323
 
 
324
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
325
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
326
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
327
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
328
 
 
329
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
330
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
 
331
  PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
332
  #name, comment, check, update, -1, def, NULL, typelib }
 
333
 
 
334
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
 
335
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
 
336
  PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
337
  #name, comment, check, update, -1, def, NULL, typelib }
 
338
 
 
339
/* accessor macros */
 
340
 
 
341
#define SYSVAR(name) \
 
342
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
343
 
 
344
/* when session == null, result points to global value */
 
345
#define SessionVAR(session, name) \
 
346
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
 
347
 
 
348
 
 
349
struct StorageEngine;
 
350
 
 
351
 
 
352
class Plugin
153
353
{
 
354
private:
 
355
  std::string name;
 
356
  std::string version;
 
357
  std::string author;
 
358
  std::string description;
 
359
 
 
360
public:
 
361
  Plugin(std::string in_name, std::string in_version,
 
362
         std::string in_author, std::string in_description)
 
363
    : name(in_name), version(in_version),
 
364
    author(in_author), description(in_description)
 
365
  {}
 
366
 
 
367
  virtual ~Plugin() {}
 
368
 
 
369
  virtual void add_functions() {}
 
370
 
154
371
};
155
372
 
156
 
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
157
 
 
158
 
struct drizzle_value
 
373
/*************************************************************************
 
374
  st_mysql_value struct for reading values from mysqld.
 
375
  Used by server variables framework to parse user-provided values.
 
376
  Will be used for arguments when implementing UDFs.
 
377
 
 
378
  Note that val_str() returns a string in temporary memory
 
379
  that will be freed at the end of statement. Copy the string
 
380
  if you need it to persist.
 
381
*/
 
382
 
 
383
#define DRIZZLE_VALUE_TYPE_STRING 0
 
384
#define DRIZZLE_VALUE_TYPE_REAL   1
 
385
#define DRIZZLE_VALUE_TYPE_INT    2
 
386
 
 
387
struct st_mysql_value
159
388
{
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);
 
389
  int (*value_type)(struct st_mysql_value *);
 
390
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
391
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
392
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
164
393
};
165
394
 
166
395
 
168
397
  Miscellaneous functions for plugin implementors
169
398
*/
170
399
 
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);
175
 
extern bool plugin_is_ready(const LEX_STRING *name, int type);
176
 
extern void plugin_sessionvar_init(Session *session);
177
 
extern void plugin_sessionvar_cleanup(Session *session);
178
 
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
 
400
#ifdef __cplusplus
 
401
extern "C" {
 
402
#endif
179
403
 
180
404
int session_in_lock_tables(const Session *session);
181
405
int session_tablespace_op(const Session *session);
183
407
const char *get_session_proc_info(Session *session);
184
408
int64_t session_test_options(const Session *session, int64_t test_options);
185
409
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);
 
410
void **session_ha_data(const Session *session, const struct StorageEngine *engine);
 
411
int session_tx_isolation(const Session *session);
 
412
/* Increments the row counter, see Session::row_count */
 
413
void session_inc_row_count(Session *session);
 
414
 
 
415
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
 
416
                                    const char *str, unsigned int size,
 
417
                                    int allocate_lex_string);
 
418
 
191
419
 
192
420
 
193
421
/**
200
428
 
201
429
  @param prefix  prefix for temporary file name
202
430
  @retval -1    error
203
 
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
 
431
  @retval >= 0  a file handle that can be passed to dup or my_close
204
432
*/
205
433
int mysql_tmpfile(const char *prefix);
206
434
 
207
 
} /* namespace drizzled */
208
 
 
209
 
#endif /* DRIZZLED_PLUGIN_H */
 
435
/**
 
436
  Check the killed state of a connection
 
437
 
 
438
  @details
 
439
  In MySQL support for the KILL statement is cooperative. The KILL
 
440
  statement only sets a "killed" flag. This function returns the value
 
441
  of that flag.  A thread should check it often, especially inside
 
442
  time-consuming loops, and gracefully abort the operation if it is
 
443
  non-zero.
 
444
 
 
445
  @param session  user thread connection handle
 
446
  @retval 0  the connection is active
 
447
  @retval 1  the connection has been killed
 
448
*/
 
449
int session_killed(const Session *session);
 
450
 
 
451
 
 
452
/**
 
453
  Return the thread id of a user thread
 
454
 
 
455
  @param session  user thread connection handle
 
456
  @return  thread id
 
457
*/
 
458
unsigned long session_get_thread_id(const Session *session);
 
459
 
 
460
const charset_info_st *session_charset(Session *session);
 
461
char **session_query(Session *session);
 
462
int session_non_transactional_update(const Session *session);
 
463
void session_mark_transaction_to_rollback(Session *session, bool all);
 
464
 
 
465
 
 
466
/**
 
467
  Allocate memory in the connection's local memory pool
 
468
 
 
469
  @details
 
470
  When properly used in place of @c malloc(), this can significantly
 
471
  improve concurrency. Don't use this or related functions to allocate
 
472
  large chunks of memory. Use for temporary storage only. The memory
 
473
  will be freed automatically at the end of the statement; no explicit
 
474
  code is required to prevent memory leaks.
 
475
 
 
476
  @see alloc_root()
 
477
*/
 
478
void *session_alloc(Session *session, unsigned int size);
 
479
/**
 
480
  @see session_alloc()
 
481
*/
 
482
void *session_calloc(Session *session, unsigned int size);
 
483
/**
 
484
  @see session_alloc()
 
485
*/
 
486
char *session_strdup(Session *session, const char *str);
 
487
/**
 
488
  @see session_alloc()
 
489
*/
 
490
char *session_strmake(Session *session, const char *str, unsigned int size);
 
491
/**
 
492
  @see session_alloc()
 
493
*/
 
494
void *session_memdup(Session *session, const void* str, unsigned int size);
 
495
 
 
496
/**
 
497
  Get the XID for this connection's transaction
 
498
 
 
499
  @param session  user thread connection handle
 
500
  @param xid  location where identifier is stored
 
501
*/
 
502
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
 
503
 
 
504
/**
 
505
  Invalidate the query cache for a given table.
 
506
 
 
507
  @param session         user thread connection handle
 
508
  @param key         databasename\\0tablename\\0
 
509
  @param key_length  length of key in bytes, including the NUL bytes
 
510
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
511
*/
 
512
void mysql_query_cache_invalidate4(Session *session,
 
513
                                   const char *key, unsigned int key_length,
 
514
                                   int using_trx);
 
515
 
 
516
#ifdef __cplusplus
 
517
}
 
518
#endif
 
519
 
 
520
#ifdef __cplusplus
 
521
/**
 
522
  Provide a handler data getter to simplify coding
 
523
*/
 
524
inline
 
525
void *
 
526
session_get_ha_data(const Session *session, const struct StorageEngine *engine)
 
527
{
 
528
  return *session_ha_data(session, engine);
 
529
}
 
530
 
 
531
/**
 
532
  Provide a handler data setter to simplify coding
 
533
*/
 
534
inline
 
535
void
 
536
session_set_ha_data(const Session *session, const struct StorageEngine *engine,
 
537
                const void *ha_data)
 
538
{
 
539
  *session_ha_data(session, engine)= (void*) ha_data;
 
540
}
 
541
#endif
 
542
 
 
543
#endif /* _my_plugin_h */
210
544