~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
33
33
#include "drizzled/sys_var.h"
34
34
#include "drizzled/xid.h"
35
35
 
36
 
#include "drizzled/visibility.h"
37
 
 
38
36
namespace drizzled
39
37
{
40
38
 
48
46
 
49
47
 
50
48
class sys_var;
 
49
typedef drizzle_lex_string LEX_STRING;
51
50
struct option;
52
51
 
53
52
extern boost::filesystem::path plugin_dir;
64
63
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
65
64
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
66
65
#define DRIZZLE_DECLARE_PLUGIN \
67
 
  DRIZZLED_API ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
 
66
  ::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)= 
68
67
 
69
68
 
70
69
#define DRIZZLE_DECLARE_PLUGIN_END
77
76
    STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
78
77
    STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
79
78
    PANDORA_MODULE_LICENSE, \
80
 
    init, \
81
 
    STRINGIFY_ARG(PANDORA_MODULE_DEPENDENCIES), \
82
 
    options \
 
79
    init, system, options \
83
80
  } 
84
81
 
85
82
 
108
105
 
109
106
/*
110
107
  SYNOPSIS
111
 
    (*var_check_func)()
 
108
    (*mysql_var_check_func)()
112
109
      session               thread handle
113
110
      var               dynamic variable being altered
114
111
      save              pointer to temporary storage
125
122
  automatically at the end of the statement.
126
123
*/
127
124
 
128
 
typedef int (*var_check_func)(Session *session,
 
125
typedef int (*mysql_var_check_func)(Session *session,
129
126
                                    drizzle_sys_var *var,
130
127
                                    void *save, drizzle_value *value);
131
128
 
132
129
/*
133
130
  SYNOPSIS
134
 
    (*var_update_func)()
 
131
    (*mysql_var_update_func)()
135
132
      session               thread handle
136
133
      var               dynamic variable being altered
137
134
      var_ptr           pointer to dynamic variable
143
140
   and persist it in the provided pointer to the dynamic variable.
144
141
   For example, strings may require memory to be allocated.
145
142
*/
146
 
typedef void (*var_update_func)(Session *session,
 
143
typedef void (*mysql_var_update_func)(Session *session,
147
144
                                      drizzle_sys_var *var,
148
145
                                      void *var_ptr, const void *save);
149
146
 
150
147
 
 
148
/* the following declarations are for internal use only */
 
149
 
 
150
 
 
151
#define PLUGIN_VAR_MASK \
 
152
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
153
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
154
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
155
 
 
156
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
157
  int flags;                    \
 
158
  const char *name;             \
 
159
  const char *comment;          \
 
160
  mysql_var_check_func check;   \
 
161
  mysql_var_update_func update
 
162
 
 
163
#define DRIZZLE_SYSVAR_NAME(name) drizzle_sysvar_ ## name
 
164
#define DRIZZLE_SYSVAR(name) \
 
165
  ((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
 
166
 
 
167
/*
 
168
  for global variables, the value pointer is the first
 
169
  element after the header, the default value is the second.
 
170
  for thread variables, the value offset is the first
 
171
  element after the header, the default value is the second.
 
172
*/
 
173
 
 
174
 
 
175
#define DECLARE_DRIZZLE_SYSVAR_BOOL(name) struct { \
 
176
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
177
  bool *value;                  \
 
178
  bool def_val;           \
 
179
} DRIZZLE_SYSVAR_NAME(name)
 
180
 
 
181
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
182
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
183
  type *value;                  \
 
184
  const type def_val;           \
 
185
} DRIZZLE_SYSVAR_NAME(name)
 
186
 
 
187
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
 
188
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
189
  type *value; type def_val;    \
 
190
  type min_val; type max_val;   \
 
191
  type blk_sz;                  \
 
192
} DRIZZLE_SYSVAR_NAME(name)
 
193
 
 
194
#define DECLARE_SessionVAR_FUNC(type) \
 
195
  type *(*resolve)(Session *session, int offset)
 
196
 
 
197
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
 
198
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
199
  int offset;                   \
 
200
  const type def_val;           \
 
201
  DECLARE_SessionVAR_FUNC(type);    \
 
202
} DRIZZLE_SYSVAR_NAME(name)
 
203
 
 
204
#define DECLARE_DRIZZLE_SessionVAR_BOOL(name) struct { \
 
205
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
206
  int offset;                   \
 
207
  bool def_val;           \
 
208
  DECLARE_SessionVAR_FUNC(bool);    \
 
209
} DRIZZLE_SYSVAR_NAME(name)
 
210
 
 
211
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
 
212
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
213
  int offset;                   \
 
214
  type def_val; type min_val;   \
 
215
  type max_val; type blk_sz;    \
 
216
  DECLARE_SessionVAR_FUNC(type);    \
 
217
} DRIZZLE_SYSVAR_NAME(name)
 
218
 
 
219
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
 
220
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
221
  int offset;                   \
 
222
  type def_val;                 \
 
223
  DECLARE_SessionVAR_FUNC(type);    \
 
224
  TYPELIB *typelib;             \
 
225
} DRIZZLE_SYSVAR_NAME(name)
 
226
 
 
227
 
 
228
/*
 
229
  the following declarations are for use by plugin implementors
 
230
*/
 
231
 
 
232
#define DECLARE_DRIZZLE_SYSVAR_BOOL(name) struct { \
 
233
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
234
  bool *value;                  \
 
235
  bool def_val;           \
 
236
} DRIZZLE_SYSVAR_NAME(name)
 
237
 
 
238
 
 
239
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
240
  DECLARE_DRIZZLE_SYSVAR_BOOL(name) = { \
 
241
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
242
  #name, comment, check, update, &varname, def}
 
243
 
 
244
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
 
245
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
246
  type *value;                  \
 
247
  const type def_val;           \
 
248
} DRIZZLE_SYSVAR_NAME(name)
 
249
 
 
250
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
251
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
252
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
253
  #name, comment, check, update, &varname, def}
 
254
 
 
255
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
256
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
257
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
258
  #name, comment, check, update, &varname, def, min, max, blk }
 
259
 
 
260
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
261
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
262
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
263
  #name, comment, check, update, &varname, def, min, max, blk }
 
264
 
 
265
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
266
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
267
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
268
  #name, comment, check, update, &varname, def, min, max, blk }
 
269
 
 
270
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
271
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
272
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
273
  #name, comment, check, update, &varname, def, min, max, blk }
 
274
 
 
275
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
276
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
277
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
278
  #name, comment, check, update, &varname, def, min, max, blk }
 
279
 
 
280
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
281
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
282
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
283
  #name, comment, check, update, &varname, def, min, max, blk }
 
284
 
 
285
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
 
286
DECLARE_DRIZZLE_SessionVAR_BOOL(name) = { \
 
287
  PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
288
  #name, comment, check, update, -1, def, NULL}
 
289
 
 
290
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
 
291
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
 
292
  PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
293
  #name, comment, check, update, -1, def, NULL}
 
294
 
 
295
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
296
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
 
297
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
298
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
299
 
 
300
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
301
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
 
302
  PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
303
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
304
 
 
305
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
306
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
 
307
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
308
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
309
 
 
310
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
311
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
 
312
  PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
313
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
314
 
 
315
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
316
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
 
317
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
318
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
319
 
 
320
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
321
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
 
322
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
323
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
324
 
 
325
/* accessor macros */
 
326
 
 
327
#define SYSVAR(name) \
 
328
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
329
 
 
330
/* when session == null, result points to global value */
 
331
#define SessionVAR(session, name) \
 
332
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
 
333
 
 
334
 
 
335
/*************************************************************************
 
336
  drizzle_value struct for reading values from mysqld.
 
337
  Used by server variables framework to parse user-provided values.
 
338
  Will be used for arguments when implementing UDFs.
 
339
 
 
340
  Note that val_str() returns a string in temporary memory
 
341
  that will be freed at the end of statement. Copy the string
 
342
  if you need it to persist.
 
343
*/
 
344
 
 
345
#define DRIZZLE_VALUE_TYPE_STRING 0
 
346
#define DRIZZLE_VALUE_TYPE_REAL   1
 
347
#define DRIZZLE_VALUE_TYPE_INT    2
151
348
 
152
349
/*
153
350
  skeleton of a plugin variable - portion of structure common to all.
154
351
*/
155
352
struct drizzle_sys_var
156
353
{
 
354
  DRIZZLE_PLUGIN_VAR_HEADER;
157
355
};
158
356
 
159
357
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
174
372
extern bool plugin_init(module::Registry &registry,
175
373
                        boost::program_options::options_description &long_options);
176
374
extern bool plugin_finalize(module::Registry &registry);
177
 
extern void plugin_startup_window(module::Registry &registry, drizzled::Session &session);
178
375
extern void my_print_help_inc_plugins(option *options);
179
376
extern bool plugin_is_ready(const LEX_STRING *name, int type);
180
377
extern void plugin_sessionvar_init(Session *session);
181
378
extern void plugin_sessionvar_cleanup(Session *session);
 
379
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
182
380
 
183
381
int session_in_lock_tables(const Session *session);
184
 
DRIZZLED_API int64_t session_test_options(const Session *session, int64_t test_options);
 
382
int session_tablespace_op(const Session *session);
 
383
void set_session_proc_info(Session *session, const char *info);
 
384
const char *get_session_proc_info(Session *session);
 
385
int64_t session_test_options(const Session *session, int64_t test_options);
 
386
int session_sql_command(const Session *session);
 
387
enum_tx_isolation session_tx_isolation(const Session *session);
 
388
 
185
389
void compose_plugin_add(std::vector<std::string> options);
186
390
void compose_plugin_remove(std::vector<std::string> options);
187
391
void notify_plugin_load(std::string in_plugin_load);
199
403
  @retval -1    error
200
404
  @retval >= 0  a file handle that can be passed to dup or internal::my_close
201
405
*/
202
 
DRIZZLED_API int tmpfile(const char *prefix);
 
406
int mysql_tmpfile(const char *prefix);
203
407
 
204
408
} /* namespace drizzled */
205
409