~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/mysql/plugin.h

  • Committer: Monty Taylor
  • Date: 2008-07-15 21:40:58 UTC
  • mfrom: (77.1.113 codestyle32)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: mordred@camelot-20080715214058-rm3phulldos9xehv
Merged from codestyle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
 
1
/* Copyright (C) 2005 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
15
 
20
16
#ifndef _my_plugin_h
21
17
#define _my_plugin_h
22
18
 
23
 
#include <drizzled/global.h>
24
 
 
25
19
#ifdef __cplusplus
26
20
class THD;
27
21
class Item;
28
 
#define DRIZZLE_THD THD*
 
22
#define MYSQL_THD THD*
29
23
#else
30
 
#define DRIZZLE_THD void*
 
24
#define MYSQL_THD void*
31
25
#endif
32
26
 
33
 
#define DRIZZLE_XIDDATASIZE 128
 
27
#include <stdint.h>
 
28
 
 
29
#ifndef _m_string_h
 
30
/* This definition must match the one given in m_string.h */
 
31
struct st_mysql_lex_string
 
32
{
 
33
  char *str;
 
34
  unsigned int length;
 
35
};
 
36
#endif /* _m_string_h */
 
37
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
 
38
 
 
39
#define MYSQL_XIDDATASIZE 128
34
40
/**
35
41
  struct st_mysql_xid is binary compatible with the XID structure as
36
42
  in the X/Open CAE Specification, Distributed Transaction Processing:
43
49
  long formatID;
44
50
  long gtrid_length;
45
51
  long bqual_length;
46
 
  char data[DRIZZLE_XIDDATASIZE];  /* Not \0-terminated */
 
52
  char data[MYSQL_XIDDATASIZE];  /* Not \0-terminated */
47
53
};
48
 
typedef struct st_mysql_xid DRIZZLE_XID;
 
54
typedef struct st_mysql_xid MYSQL_XID;
49
55
 
50
56
/*************************************************************************
51
57
  Plugin API. Common for all plugin types.
52
58
*/
53
59
 
 
60
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0100
 
61
 
54
62
/*
55
63
  The allowable types of plugins
56
64
*/
57
 
#define DRIZZLE_DAEMON_PLUGIN          0  /* Daemon / Raw */
58
 
#define DRIZZLE_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine */
59
 
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN  2  /* Information Schema */
60
 
#define DRIZZLE_UDF_PLUGIN             3  /* User-Defined Function */
61
 
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate function */
62
 
#define DRIZZLE_AUDIT_PLUGIN           5  /* Audit */
63
 
#define DRIZZLE_LOGGER_PLUGIN          6  /* Logging */
64
 
#define DRIZZLE_AUTH_PLUGIN            7  /* Authorization */
65
 
 
66
 
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
 
65
#define MYSQL_UDF_PLUGIN             0  /* User-Defined Function */
 
66
#define MYSQL_UDA_PLUGIN             1  /* User-Defined Aggregate function */
 
67
#define MYSQL_STORAGE_ENGINE_PLUGIN  2  /* Storage Engine */
 
68
#define MYSQL_DAEMON_PLUGIN          4  /* Daemon / Raw */
 
69
#define MYSQL_INFORMATION_SCHEMA_PLUGIN  5  /* Information Schema */
 
70
#define MYSQL_AUDIT_PLUGIN           6  /* Audit */
 
71
#define MYSQL_LOG_PLUGIN             7  /* Logging */
 
72
#define MYSQL_AUTH_PLUGIN            8  /* Authorization */
 
73
#define MYSQL_MAX_PLUGIN_TYPE_NUM    9  /* The number of plugin types   */
67
74
 
68
75
/* We use the following strings to define licenses for plugins */
69
76
#define PLUGIN_LICENSE_PROPRIETARY 0
81
88
*/
82
89
 
83
90
 
84
 
#ifndef DRIZZLE_DYNAMIC_PLUGIN
85
 
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
91
#ifndef MYSQL_DYNAMIC_PLUGIN
 
92
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \
 
93
int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION;                                  \
 
94
int PSIZE= sizeof(struct st_mysql_plugin);                                    \
86
95
struct st_mysql_plugin DECLS[]= {
87
96
#else
88
 
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
 
97
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \
 
98
int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION;         \
 
99
int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin);          \
89
100
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
90
101
#endif
91
102
 
92
103
#define mysql_declare_plugin(NAME) \
93
 
__DRIZZLE_DECLARE_PLUGIN(NAME, \
 
104
__MYSQL_DECLARE_PLUGIN(NAME, \
 
105
                 builtin_ ## NAME ## _plugin_interface_version, \
 
106
                 builtin_ ## NAME ## _sizeof_struct_st_plugin, \
94
107
                 builtin_ ## NAME ## _plugin)
95
108
 
96
 
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
 
109
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0}}
97
110
 
98
111
/*
99
112
  declarations for SHOW STATUS support in plugins
113
126
 
114
127
 
115
128
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
116
 
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
129
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *);
117
130
 
118
131
struct st_show_var_func_container {
119
132
  mysql_show_var_func func;
162
175
  automatically at the end of the statement.
163
176
*/
164
177
 
165
 
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
178
typedef int (*mysql_var_check_func)(MYSQL_THD thd,
166
179
                                    struct st_mysql_sys_var *var,
167
180
                                    void *save, struct st_mysql_value *value);
168
181
 
180
193
   and persist it in the provided pointer to the dynamic variable.
181
194
   For example, strings may require memory to be allocated.
182
195
*/
183
 
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
196
typedef void (*mysql_var_update_func)(MYSQL_THD thd,
184
197
                                      struct st_mysql_sys_var *var,
185
198
                                      void *var_ptr, const void *save);
186
199
 
193
206
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
194
207
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
195
208
 
196
 
#define DRIZZLE_PLUGIN_VAR_HEADER \
 
209
#define MYSQL_PLUGIN_VAR_HEADER \
197
210
  int flags;                    \
198
211
  const char *name;             \
199
212
  const char *comment;          \
200
213
  mysql_var_check_func check;   \
201
214
  mysql_var_update_func update
202
215
 
203
 
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
204
 
#define DRIZZLE_SYSVAR(name) \
205
 
  ((struct st_mysql_sys_var *)&(DRIZZLE_SYSVAR_NAME(name)))
 
216
#define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
217
#define MYSQL_SYSVAR(name) \
 
218
  ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
206
219
 
207
220
/*
208
221
  for global variables, the value pointer is the first
212
225
*/
213
226
   
214
227
 
215
 
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
216
 
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
228
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
 
229
  MYSQL_PLUGIN_VAR_HEADER;      \
217
230
  type *value;                  \
218
231
  const type def_val;           \
219
 
} DRIZZLE_SYSVAR_NAME(name)
 
232
} MYSQL_SYSVAR_NAME(name)
220
233
 
221
 
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
222
 
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
234
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
 
235
  MYSQL_PLUGIN_VAR_HEADER;      \
223
236
  type *value; type def_val;    \
224
237
  type min_val; type max_val;   \
225
238
  type blk_sz;                  \
226
 
} DRIZZLE_SYSVAR_NAME(name)
 
239
} MYSQL_SYSVAR_NAME(name)
227
240
 
228
 
#define DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, type) struct { \
229
 
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
241
#define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
 
242
  MYSQL_PLUGIN_VAR_HEADER;      \
230
243
  type *value; type def_val;    \
231
244
  TYPELIB *typelib;             \
232
 
} DRIZZLE_SYSVAR_NAME(name)
 
245
} MYSQL_SYSVAR_NAME(name)
233
246
 
234
247
#define DECLARE_THDVAR_FUNC(type) \
235
 
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
248
  type *(*resolve)(MYSQL_THD thd, int offset)
236
249
 
237
 
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
238
 
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
250
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
 
251
  MYSQL_PLUGIN_VAR_HEADER;      \
239
252
  int offset;                   \
240
253
  const type def_val;           \
241
254
  DECLARE_THDVAR_FUNC(type);    \
242
 
} DRIZZLE_SYSVAR_NAME(name)
 
255
} MYSQL_SYSVAR_NAME(name)
243
256
 
244
 
#define DECLARE_DRIZZLE_THDVAR_SIMPLE(name, type) struct { \
245
 
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
257
#define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
 
258
  MYSQL_PLUGIN_VAR_HEADER;      \
246
259
  int offset;                   \
247
260
  type def_val; type min_val;   \
248
261
  type max_val; type blk_sz;    \
249
262
  DECLARE_THDVAR_FUNC(type);    \
250
 
} DRIZZLE_SYSVAR_NAME(name)
 
263
} MYSQL_SYSVAR_NAME(name)
251
264
 
252
 
#define DECLARE_DRIZZLE_THDVAR_TYPELIB(name, type) struct { \
253
 
  DRIZZLE_PLUGIN_VAR_HEADER;      \
 
265
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
 
266
  MYSQL_PLUGIN_VAR_HEADER;      \
254
267
  int offset;                   \
255
268
  type def_val;                 \
256
269
  DECLARE_THDVAR_FUNC(type);    \
257
270
  TYPELIB *typelib;             \
258
 
} DRIZZLE_SYSVAR_NAME(name)
 
271
} MYSQL_SYSVAR_NAME(name)
259
272
 
260
273
 
261
274
/*
262
275
  the following declarations are for use by plugin implementors
263
276
*/
264
277
 
265
 
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
266
 
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
 
278
#define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
279
DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \
267
280
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
268
281
  #name, comment, check, update, &varname, def}
269
282
 
270
 
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
271
 
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
 
283
#define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
284
DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
272
285
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
273
286
  #name, comment, check, update, &varname, def}
274
287
 
275
 
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
276
 
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
 
288
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
289
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
277
290
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
278
291
  #name, comment, check, update, &varname, def, min, max, blk }
279
292
 
280
 
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
281
 
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
 
293
#define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
294
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
282
295
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
283
296
  #name, comment, check, update, &varname, def, min, max, blk }
284
297
 
285
 
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
286
 
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
 
298
#define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
299
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
287
300
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
288
301
  #name, comment, check, update, &varname, def, min, max, blk }
289
302
 
290
 
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
291
 
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
 
303
#define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
304
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
292
305
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
293
306
  #name, comment, check, update, &varname, def, min, max, blk }
294
307
 
295
 
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
296
 
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
 
308
#define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
309
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int64_t) = { \
297
310
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
298
311
  #name, comment, check, update, &varname, def, min, max, blk }
299
312
 
300
 
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
301
 
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
 
313
#define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
314
DECLARE_MYSQL_SYSVAR_SIMPLE(name, uint64_t) = { \
302
315
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
303
316
  #name, comment, check, update, &varname, def, min, max, blk }
304
317
 
305
 
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
306
 
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
 
318
#define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
319
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
307
320
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
308
321
  #name, comment, check, update, &varname, def, typelib }
309
322
 
310
 
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
311
 
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
 
323
#define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
324
DECLARE_MYSQL_SYSVAR_TYPELIB(name, uint64_t) = { \
312
325
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
313
326
  #name, comment, check, update, &varname, def, typelib }
314
327
 
315
 
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
316
 
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
 
328
#define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
 
329
DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \
317
330
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
318
331
  #name, comment, check, update, -1, def, NULL}
319
332
 
320
 
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
321
 
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
 
333
#define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
 
334
DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
322
335
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
323
336
  #name, comment, check, update, -1, def, NULL}
324
337
 
325
 
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
326
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
 
338
#define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
339
DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
327
340
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
328
341
  #name, comment, check, update, -1, def, min, max, blk, NULL }
329
342
 
330
 
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
331
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
 
343
#define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
344
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
332
345
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
333
346
  #name, comment, check, update, -1, def, min, max, blk, NULL }
334
347
 
335
 
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
336
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
 
348
#define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
349
DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
337
350
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
338
351
  #name, comment, check, update, -1, def, min, max, blk, NULL }
339
352
 
340
 
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
341
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
 
353
#define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
354
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
342
355
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
343
356
  #name, comment, check, update, -1, def, min, max, blk, NULL }
344
357
 
345
 
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
346
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
 
358
#define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
359
DECLARE_MYSQL_THDVAR_SIMPLE(name, int64_t) = { \
347
360
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
348
361
  #name, comment, check, update, -1, def, min, max, blk, NULL }
349
362
 
350
 
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
351
 
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
 
363
#define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
364
DECLARE_MYSQL_THDVAR_SIMPLE(name, uint64_t) = { \
352
365
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
353
366
  #name, comment, check, update, -1, def, min, max, blk, NULL }
354
367
 
355
 
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
356
 
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
 
368
#define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
369
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
357
370
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
358
371
  #name, comment, check, update, -1, def, NULL, typelib }
359
372
 
360
 
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
361
 
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
 
373
#define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
 
374
DECLARE_MYSQL_THDVAR_TYPELIB(name, uint64_t) = { \
362
375
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
363
376
  #name, comment, check, update, -1, def, NULL, typelib }
364
377
 
365
378
/* accessor macros */
366
379
 
367
380
#define SYSVAR(name) \
368
 
  (*(DRIZZLE_SYSVAR_NAME(name).value))
 
381
  (*(MYSQL_SYSVAR_NAME(name).value))
369
382
 
370
383
/* when thd == null, result points to global value */
371
384
#define THDVAR(thd, name) \
372
 
  (*(DRIZZLE_SYSVAR_NAME(name).resolve(thd, DRIZZLE_SYSVAR_NAME(name).offset)))
 
385
  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
373
386
 
374
387
 
375
388
/*
378
391
 
379
392
struct st_mysql_plugin
380
393
{
381
 
  int type;             /* the plugin type (a DRIZZLE_XXX_PLUGIN value)   */
382
 
  const char *name;     /* plugin name (for SHOW PLUGINS)               */
383
 
  const char *version;  /* plugin version (for SHOW PLUGINS)            */
 
394
  int type;             /* the plugin type (a MYSQL_XXX_PLUGIN value)   */
 
395
  void *info;           /* pointer to type-specific plugin descriptor   */
 
396
  const char *name;     /* plugin name                                  */
384
397
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
385
398
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
386
399
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
387
400
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
388
401
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
 
402
  unsigned int version; /* plugin version (for SHOW PLUGINS)            */
389
403
  struct st_mysql_show_var *status_vars;
390
404
  struct st_mysql_sys_var **system_vars;
391
405
  void * __reserved1;   /* reserved for dependency checking             */
392
406
};
393
407
 
 
408
/*************************************************************************
 
409
  API for Daemon plugin. (MYSQL_DAEMON_PLUGIN)
 
410
*/
 
411
 
 
412
/* handlertons of different MySQL releases are incompatible */
 
413
#define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
414
 
 
415
/*
 
416
  Here we define only the descriptor structure, that is referred from
 
417
  st_mysql_plugin.
 
418
*/
 
419
 
 
420
struct st_mysql_daemon
 
421
{
 
422
  int interface_version;
 
423
};
 
424
 
 
425
 
 
426
/*************************************************************************
 
427
  API for UDF plugin. (MYSQL_UDF_PLUGIN)
 
428
*/
 
429
 
 
430
/* handlertons of different MySQL releases are incompatible */
 
431
#define MYSQL_UDF_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
432
 
 
433
/*
 
434
  Here we define only the descriptor structure, that is referred from
 
435
  st_mysql_plugin.
 
436
*/
 
437
 
 
438
struct st_mysql_udf
 
439
{
 
440
  int interface_version;
 
441
};
 
442
 
 
443
 
 
444
/*************************************************************************
 
445
  API for UDA plugin. (MYSQL_UDA_PLUGIN)
 
446
*/
 
447
 
 
448
/* handlertons of different MySQL releases are incompatible */
 
449
#define MYSQL_UDA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
450
 
 
451
/*
 
452
  Here we define only the descriptor structure, that is referred from
 
453
  st_mysql_plugin.
 
454
*/
 
455
 
 
456
struct st_mysql_uda
 
457
{
 
458
  int interface_version;
 
459
};
 
460
 
 
461
 
 
462
/*************************************************************************
 
463
  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
 
464
*/
 
465
 
 
466
/* handlertons of different MySQL releases are incompatible */
 
467
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
468
 
 
469
/*
 
470
  Here we define only the descriptor structure, that is referred from
 
471
  st_mysql_plugin.
 
472
*/
 
473
 
 
474
struct st_mysql_information_schema
 
475
{
 
476
  int interface_version;
 
477
};
 
478
 
 
479
 
 
480
/*************************************************************************
 
481
  API for Log plugin. (MYSQL_LOG_PLUGIN)
 
482
*/
 
483
 
 
484
/* handlertons of different MySQL releases are incompatible */
 
485
#define MYSQL_LOG_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
486
 
 
487
/*
 
488
  Here we define only the descriptor structure, that is referred from
 
489
  st_mysql_plugin.
 
490
*/
 
491
 
 
492
struct st_mysql_log
 
493
{
 
494
  int interface_version;
 
495
};
 
496
 
 
497
 
 
498
/*************************************************************************
 
499
  API for Auth plugin. (MYSQL_AUTH_PLUGIN)
 
500
*/
 
501
 
 
502
/* handlertons of different MySQL releases are incompatible */
 
503
#define MYSQL_AUTH_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
504
 
 
505
/*
 
506
  Here we define only the descriptor structure, that is referred from
 
507
  st_mysql_plugin.
 
508
*/
 
509
 
 
510
struct st_auth_schema
 
511
{
 
512
  int interface_version;
 
513
};
 
514
 
 
515
 
 
516
/*************************************************************************
 
517
  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
 
518
*/
 
519
 
 
520
/* handlertons of different MySQL releases are incompatible */
 
521
#define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
522
 
 
523
/*
 
524
  The real API is in the sql/handler.h
 
525
  Here we define only the descriptor structure, that is referred from
 
526
  st_mysql_plugin.
 
527
*/
 
528
 
 
529
struct st_mysql_storage_engine
 
530
{
 
531
  int interface_version;
 
532
};
 
533
 
394
534
struct handlerton;
395
535
 
396
536
 
404
544
  if you need it to persist.
405
545
*/
406
546
 
407
 
#define DRIZZLE_VALUE_TYPE_STRING 0
408
 
#define DRIZZLE_VALUE_TYPE_REAL   1
409
 
#define DRIZZLE_VALUE_TYPE_INT    2
 
547
#define MYSQL_VALUE_TYPE_STRING 0
 
548
#define MYSQL_VALUE_TYPE_REAL   1
 
549
#define MYSQL_VALUE_TYPE_INT    2
410
550
 
411
551
struct st_mysql_value
412
552
{
425
565
extern "C" {
426
566
#endif
427
567
 
428
 
int thd_in_lock_tables(const DRIZZLE_THD thd);
429
 
int thd_tablespace_op(const DRIZZLE_THD thd);
430
 
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
431
 
int thd_sql_command(const DRIZZLE_THD thd);
432
 
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
433
 
int thd_tx_isolation(const DRIZZLE_THD thd);
 
568
int thd_in_lock_tables(const MYSQL_THD thd);
 
569
int thd_tablespace_op(const MYSQL_THD thd);
 
570
int64_t thd_test_options(const MYSQL_THD thd, int64_t test_options);
 
571
int thd_sql_command(const MYSQL_THD thd);
 
572
const char *thd_proc_info(MYSQL_THD thd, const char *info);
 
573
void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
 
574
int thd_tx_isolation(const MYSQL_THD thd);
 
575
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
 
576
                           unsigned int max_query_len);
434
577
/* Increments the row counter, see THD::row_count */
435
 
void thd_inc_row_count(DRIZZLE_THD thd);
 
578
void thd_inc_row_count(MYSQL_THD thd);
436
579
 
437
580
/**
438
581
  Create a temporary file.
462
605
  @retval 0  the connection is active
463
606
  @retval 1  the connection has been killed
464
607
*/
465
 
int thd_killed(const DRIZZLE_THD thd);
 
608
int thd_killed(const MYSQL_THD thd);
466
609
 
467
610
 
468
611
/**
471
614
  @param thd  user thread connection handle
472
615
  @return  thread id
473
616
*/
474
 
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
617
unsigned long thd_get_thread_id(const MYSQL_THD thd);
475
618
 
476
619
 
477
620
/**
486
629
 
487
630
  @see alloc_root()
488
631
*/
489
 
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
490
 
/**
491
 
  @see thd_alloc()
492
 
*/
493
 
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
494
 
/**
495
 
  @see thd_alloc()
496
 
*/
497
 
char *thd_strdup(DRIZZLE_THD thd, const char *str);
498
 
/**
499
 
  @see thd_alloc()
500
 
*/
501
 
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
502
 
/**
503
 
  @see thd_alloc()
504
 
*/
505
 
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
 
632
void *thd_alloc(MYSQL_THD thd, unsigned int size);
 
633
/**
 
634
  @see thd_alloc()
 
635
*/
 
636
void *thd_calloc(MYSQL_THD thd, unsigned int size);
 
637
/**
 
638
  @see thd_alloc()
 
639
*/
 
640
char *thd_strdup(MYSQL_THD thd, const char *str);
 
641
/**
 
642
  @see thd_alloc()
 
643
*/
 
644
char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
 
645
/**
 
646
  @see thd_alloc()
 
647
*/
 
648
void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
 
649
 
 
650
/**
 
651
  Create a LEX_STRING in this connection's local memory pool
 
652
 
 
653
  @param thd      user thread connection handle
 
654
  @param lex_str  pointer to LEX_STRING object to be initialized
 
655
  @param str      initializer to be copied into lex_str
 
656
  @param size     length of str, in bytes
 
657
  @param allocate_lex_string  flag: if TRUE, allocate new LEX_STRING object,
 
658
                              instead of using lex_str value
 
659
  @return  NULL on failure, or pointer to the LEX_STRING object
 
660
 
 
661
  @see thd_alloc()
 
662
*/
 
663
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
 
664
                                      const char *str, unsigned int size,
 
665
                                      int allocate_lex_string);
506
666
 
507
667
/**
508
668
  Get the XID for this connection's transaction
510
670
  @param thd  user thread connection handle
511
671
  @param xid  location where identifier is stored
512
672
*/
513
 
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
673
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
514
674
 
515
675
/**
516
676
  Invalidate the query cache for a given table.
520
680
  @param key_length  length of key in bytes, including the NUL bytes
521
681
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
522
682
*/
523
 
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
683
void mysql_query_cache_invalidate4(MYSQL_THD thd,
524
684
                                   const char *key, unsigned int key_length,
525
685
                                   int using_trx);
526
686
 
534
694
*/
535
695
inline
536
696
void *
537
 
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
697
thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton)
538
698
{
539
699
  return *thd_ha_data(thd, hton);
540
700
}
544
704
*/
545
705
inline
546
706
void
547
 
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
707
thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton,
548
708
                const void *ha_data)
549
709
{
550
710
  *thd_ha_data(thd, hton)= (void*) ha_data;