~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Brian Aker
  • Date: 2009-09-27 21:52:36 UTC
  • mfrom: (1138.1.1 build)
  • Revision ID: brian@gaz-20090927215236-5nx5q6u1ub8uf0l6
Merge Monty (fix for distcheck)

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;
45
32
*/
46
33
 
47
34
 
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
35
/*
57
36
  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
 
 
 
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
 
43
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
44
drizzled::plugin::Manifest DECLS[]= {
 
45
#else
 
46
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
47
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
 
48
#endif
 
49
 
 
50
#define drizzle_declare_plugin(NAME) \
 
51
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
52
                 builtin_ ## NAME ## _plugin)
 
53
 
 
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
 
66
 
 
67
/*
 
68
  declarations for SHOW STATUS support in plugins
 
69
*/
 
70
enum enum_mysql_show_type
 
71
{
 
72
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
73
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
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
 
78
};
 
79
 
 
80
struct st_mysql_show_var {
 
81
  const char *name;
 
82
  char *value;
 
83
  enum enum_mysql_show_type type;
 
84
};
 
85
 
 
86
typedef enum enum_mysql_show_type SHOW_TYPE;
 
87
typedef struct st_mysql_show_var SHOW_VAR;
 
88
 
 
89
 
 
90
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
91
typedef int (*mysql_show_var_func)(struct st_mysql_show_var *, char *);
 
92
 
 
93
struct st_show_var_func_container {
 
94
  mysql_show_var_func func;
 
95
};
83
96
/*
84
97
  declarations for server variables and command line options
85
98
*/
90
103
#define PLUGIN_VAR_LONG         0x0003
91
104
#define PLUGIN_VAR_LONGLONG     0x0004
92
105
#define PLUGIN_VAR_STR          0x0005
 
106
#define PLUGIN_VAR_ENUM         0x0006
 
107
#define PLUGIN_VAR_SET          0x0007
93
108
#define PLUGIN_VAR_UNSIGNED     0x0080
94
109
#define PLUGIN_VAR_SessionLOCAL     0x0100 /* Variable is per-connection */
95
110
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
100
115
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
101
116
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
102
117
 
103
 
struct drizzle_sys_var;
104
 
struct drizzle_value;
 
118
struct st_mysql_sys_var;
 
119
struct st_mysql_value;
105
120
 
106
121
/*
107
122
  SYNOPSIS
123
138
*/
124
139
 
125
140
typedef int (*mysql_var_check_func)(Session *session,
126
 
                                    drizzle_sys_var *var,
127
 
                                    void *save, drizzle_value *value);
 
141
                                    struct st_mysql_sys_var *var,
 
142
                                    void *save, struct st_mysql_value *value);
128
143
 
129
144
/*
130
145
  SYNOPSIS
141
156
   For example, strings may require memory to be allocated.
142
157
*/
143
158
typedef void (*mysql_var_update_func)(Session *session,
144
 
                                      drizzle_sys_var *var,
 
159
                                      struct st_mysql_sys_var *var,
145
160
                                      void *var_ptr, const void *save);
146
161
 
147
162
 
148
 
 
149
 
/*
150
 
  skeleton of a plugin variable - portion of structure common to all.
151
 
*/
152
 
struct drizzle_sys_var
 
163
/* the following declarations are for internal use only */
 
164
 
 
165
 
 
166
#define PLUGIN_VAR_MASK \
 
167
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
168
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
169
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
170
 
 
171
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
172
  int flags;                    \
 
173
  const char *name;             \
 
174
  const char *comment;          \
 
175
  mysql_var_check_func check;   \
 
176
  mysql_var_update_func update
 
177
 
 
178
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
179
#define DRIZZLE_SYSVAR(name) \
 
180
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
181
 
 
182
/*
 
183
  for global variables, the value pointer is the first
 
184
  element after the header, the default value is the second.
 
185
  for thread variables, the value offset is the first
 
186
  element after the header, the default value is the second.
 
187
*/
 
188
 
 
189
 
 
190
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
191
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
192
  type *value;                  \
 
193
  const type def_val;           \
 
194
} DRIZZLE_SYSVAR_NAME(name)
 
195
 
 
196
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
197
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
198
  type *value; type def_val;    \
 
199
  type min_val; type max_val;   \
 
200
  type blk_sz;                  \
 
201
} DRIZZLE_SYSVAR_NAME(name)
 
202
 
 
203
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
 
204
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
205
  type *value; type def_val;    \
 
206
  TYPELIB *typelib;             \
 
207
} DRIZZLE_SYSVAR_NAME(name)
 
208
 
 
209
#define DECLARE_SessionVAR_FUNC(type) \
 
210
  type *(*resolve)(Session *session, int offset)
 
211
 
 
212
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
213
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
214
  int offset;                   \
 
215
  const type def_val;           \
 
216
  DECLARE_SessionVAR_FUNC(type);    \
 
217
} DRIZZLE_SYSVAR_NAME(name)
 
218
 
 
219
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
220
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
221
  int offset;                   \
 
222
  type def_val; type min_val;   \
 
223
  type max_val; type blk_sz;    \
 
224
  DECLARE_SessionVAR_FUNC(type);    \
 
225
} DRIZZLE_SYSVAR_NAME(name)
 
226
 
 
227
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
228
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
229
  int offset;                   \
 
230
  type def_val;                 \
 
231
  DECLARE_SessionVAR_FUNC(type);    \
 
232
  TYPELIB *typelib;             \
 
233
} DRIZZLE_SYSVAR_NAME(name)
 
234
 
 
235
 
 
236
/*
 
237
  the following declarations are for use by plugin implementors
 
238
*/
 
239
 
 
240
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
241
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
242
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
243
  #name, comment, check, update, &varname, def}
 
244
 
 
245
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
246
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
247
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
248
  #name, comment, check, update, &varname, def}
 
249
 
 
250
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
251
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
252
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
253
  #name, comment, check, update, &varname, def, min, max, blk }
 
254
 
 
255
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
256
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
257
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
258
  #name, comment, check, update, &varname, def, min, max, blk }
 
259
 
 
260
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
261
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
262
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
263
  #name, comment, check, update, &varname, def, min, max, blk }
 
264
 
 
265
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
266
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
267
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
268
  #name, comment, check, update, &varname, def, min, max, blk }
 
269
 
 
270
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
271
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
272
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
273
  #name, comment, check, update, &varname, def, min, max, blk }
 
274
 
 
275
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
276
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
277
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
278
  #name, comment, check, update, &varname, def, min, max, blk }
 
279
 
 
280
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
281
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
282
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
283
  #name, comment, check, update, &varname, def, typelib }
 
284
 
 
285
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
286
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
287
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
288
  #name, comment, check, update, &varname, def, typelib }
 
289
 
 
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), \
 
333
  #name, comment, check, update, -1, def, NULL, typelib }
 
334
 
 
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), \
 
338
  #name, comment, check, update, -1, def, NULL, typelib }
 
339
 
 
340
/* accessor macros */
 
341
 
 
342
#define SYSVAR(name) \
 
343
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
344
 
 
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
153
354
{
 
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
 
154
372
};
155
373
 
156
 
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
157
 
 
158
 
struct drizzle_value
 
374
/*************************************************************************
 
375
  st_mysql_value struct for reading values from mysqld.
 
376
  Used by server variables framework to parse user-provided values.
 
377
  Will be used for arguments when implementing UDFs.
 
378
 
 
379
  Note that val_str() returns a string in temporary memory
 
380
  that will be freed at the end of statement. Copy the string
 
381
  if you need it to persist.
 
382
*/
 
383
 
 
384
#define DRIZZLE_VALUE_TYPE_STRING 0
 
385
#define DRIZZLE_VALUE_TYPE_REAL   1
 
386
#define DRIZZLE_VALUE_TYPE_INT    2
 
387
 
 
388
struct st_mysql_value
159
389
{
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);
 
390
  int (*value_type)(struct st_mysql_value *);
 
391
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
392
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
393
  int (*val_int)(struct st_mysql_value *, int64_t *intbuf);
164
394
};
165
395
 
166
396
 
168
398
  Miscellaneous functions for plugin implementors
169
399
*/
170
400
 
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);
 
401
#ifdef __cplusplus
 
402
extern "C" {
 
403
#endif
179
404
 
180
405
int session_in_lock_tables(const Session *session);
181
406
int session_tablespace_op(const Session *session);
183
408
const char *get_session_proc_info(Session *session);
184
409
int64_t session_test_options(const Session *session, int64_t test_options);
185
410
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);
 
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
 
191
420
 
192
421
 
193
422
/**
200
429
 
201
430
  @param prefix  prefix for temporary file name
202
431
  @retval -1    error
203
 
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
 
432
  @retval >= 0  a file handle that can be passed to dup or my_close
204
433
*/
205
434
int mysql_tmpfile(const char *prefix);
206
435
 
207
 
} /* namespace drizzled */
208
 
 
209
 
#endif /* DRIZZLED_PLUGIN_H */
 
436
/**
 
437
  Check the killed state of a connection
 
438
 
 
439
  @details
 
440
  In MySQL support for the KILL statement is cooperative. The KILL
 
441
  statement only sets a "killed" flag. This function returns the value
 
442
  of that flag.  A thread should check it often, especially inside
 
443
  time-consuming loops, and gracefully abort the operation if it is
 
444
  non-zero.
 
445
 
 
446
  @param session  user thread connection handle
 
447
  @retval 0  the connection is active
 
448
  @retval 1  the connection has been killed
 
449
*/
 
450
int session_killed(const Session *session);
 
451
 
 
452
 
 
453
/**
 
454
  Return the thread id of a user thread
 
455
 
 
456
  @param session  user thread connection handle
 
457
  @return  thread id
 
458
*/
 
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);
 
465
 
 
466
 
 
467
/**
 
468
  Allocate memory in the connection's local memory pool
 
469
 
 
470
  @details
 
471
  When properly used in place of @c malloc(), this can significantly
 
472
  improve concurrency. Don't use this or related functions to allocate
 
473
  large chunks of memory. Use for temporary storage only. The memory
 
474
  will be freed automatically at the end of the statement; no explicit
 
475
  code is required to prevent memory leaks.
 
476
 
 
477
  @see alloc_root()
 
478
*/
 
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);
 
496
 
 
497
/**
 
498
  Get the XID for this connection's transaction
 
499
 
 
500
  @param session  user thread connection handle
 
501
  @param xid  location where identifier is stored
 
502
*/
 
503
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
 
504
 
 
505
/**
 
506
  Invalidate the query cache for a given table.
 
507
 
 
508
  @param session         user thread connection handle
 
509
  @param key         databasename\\0tablename\\0
 
510
  @param key_length  length of key in bytes, including the NUL bytes
 
511
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
512
*/
 
513
void mysql_query_cache_invalidate4(Session *session,
 
514
                                   const char *key, unsigned int key_length,
 
515
                                   int using_trx);
 
516
 
 
517
#ifdef __cplusplus
 
518
}
 
519
#endif
 
520
 
 
521
#ifdef __cplusplus
 
522
/**
 
523
  Provide a handler data getter to simplify coding
 
524
*/
 
525
inline
 
526
void *
 
527
session_get_ha_data(const Session *session, const struct StorageEngine *engine)
 
528
{
 
529
  return *session_ha_data(session, engine);
 
530
}
 
531
 
 
532
/**
 
533
  Provide a handler data setter to simplify coding
 
534
*/
 
535
inline
 
536
void
 
537
session_set_ha_data(const Session *session, const struct StorageEngine *engine,
 
538
                const void *ha_data)
 
539
{
 
540
  *session_ha_data(session, engine)= (void*) ha_data;
 
541
}
 
542
#endif
 
543
 
 
544
#endif /* _my_plugin_h */
210
545