~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-21 16:39:40 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20101221163940-c1pfo1jjvx7909xq
Tags: 2010.12.06-0ubuntu1
* New upstream release.
* Added libaio-dev build depend for InnoDB.
* Removed libpcre patch - applied upstream.

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
145
145
                                      void *var_ptr, const void *save);
146
146
 
147
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
348
148
 
349
149
/*
350
150
  skeleton of a plugin variable - portion of structure common to all.
351
151
*/
352
152
struct drizzle_sys_var
353
153
{
354
 
  DRIZZLE_PLUGIN_VAR_HEADER;
355
154
};
356
155
 
357
156
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);