~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to include/mysql/plugin.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 */
 
15
 
 
16
#ifndef _my_plugin_h
 
17
#define _my_plugin_h
 
18
 
 
19
#ifdef __cplusplus
 
20
class THD;
 
21
class Item;
 
22
#define MYSQL_THD THD*
 
23
#else
 
24
#define MYSQL_THD void*
 
25
#endif
 
26
 
 
27
#ifndef _m_string_h
 
28
/* This definition must match the one given in m_string.h */
 
29
struct st_mysql_lex_string
 
30
{
 
31
  char *str;
 
32
  unsigned int length;
 
33
};
 
34
#endif /* _m_string_h */
 
35
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
 
36
 
 
37
#define MYSQL_XIDDATASIZE 128
 
38
/**
 
39
  struct st_mysql_xid is binary compatible with the XID structure as
 
40
  in the X/Open CAE Specification, Distributed Transaction Processing:
 
41
  The XA Specification, X/Open Company Ltd., 1991.
 
42
  http://www.opengroup.org/bookstore/catalog/c193.htm
 
43
 
 
44
  @see XID in sql/handler.h
 
45
*/
 
46
struct st_mysql_xid {
 
47
  long formatID;
 
48
  long gtrid_length;
 
49
  long bqual_length;
 
50
  char data[MYSQL_XIDDATASIZE];  /* Not \0-terminated */
 
51
};
 
52
typedef struct st_mysql_xid MYSQL_XID;
 
53
 
 
54
/*************************************************************************
 
55
  Plugin API. Common for all plugin types.
 
56
*/
 
57
 
 
58
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0100
 
59
 
 
60
/*
 
61
  The allowable types of plugins
 
62
*/
 
63
#define MYSQL_UDF_PLUGIN             0  /* User-defined function        */
 
64
#define MYSQL_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine               */
 
65
#define MYSQL_FTPARSER_PLUGIN        2  /* Full-text parser plugin      */
 
66
#define MYSQL_DAEMON_PLUGIN          3  /* The daemon/raw plugin type */
 
67
#define MYSQL_INFORMATION_SCHEMA_PLUGIN  4  /* The I_S plugin type */
 
68
#define MYSQL_AUDIT_PLUGIN           5  /* The Audit plugin type        */
 
69
#define MYSQL_MAX_PLUGIN_TYPE_NUM    6  /* The number of plugin types   */
 
70
 
 
71
/* We use the following strings to define licenses for plugins */
 
72
#define PLUGIN_LICENSE_PROPRIETARY 0
 
73
#define PLUGIN_LICENSE_GPL 1
 
74
#define PLUGIN_LICENSE_BSD 2
 
75
 
 
76
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
 
77
#define PLUGIN_LICENSE_GPL_STRING "GPL"
 
78
#define PLUGIN_LICENSE_BSD_STRING "BSD"
 
79
 
 
80
/*
 
81
  Macros for beginning and ending plugin declarations.  Between
 
82
  mysql_declare_plugin and mysql_declare_plugin_end there should
 
83
  be a st_mysql_plugin struct for each plugin to be declared.
 
84
*/
 
85
 
 
86
 
 
87
#ifndef MYSQL_DYNAMIC_PLUGIN
 
88
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \
 
89
int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION;                                  \
 
90
int PSIZE= sizeof(struct st_mysql_plugin);                                    \
 
91
struct st_mysql_plugin DECLS[]= {
 
92
#else
 
93
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS)                   \
 
94
int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION;         \
 
95
int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin);          \
 
96
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
 
97
#endif
 
98
 
 
99
#define mysql_declare_plugin(NAME) \
 
100
__MYSQL_DECLARE_PLUGIN(NAME, \
 
101
                 builtin_ ## NAME ## _plugin_interface_version, \
 
102
                 builtin_ ## NAME ## _sizeof_struct_st_plugin, \
 
103
                 builtin_ ## NAME ## _plugin)
 
104
 
 
105
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0}}
 
106
 
 
107
/*
 
108
  declarations for SHOW STATUS support in plugins
 
109
*/
 
110
enum enum_mysql_show_type
 
111
{
 
112
  SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG,
 
113
  SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR,
 
114
  SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
 
115
};
 
116
 
 
117
struct st_mysql_show_var {
 
118
  const char *name;
 
119
  char *value;
 
120
  enum enum_mysql_show_type type;
 
121
};
 
122
 
 
123
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
 
124
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *);
 
125
 
 
126
 
 
127
/*
 
128
  declarations for server variables and command line options
 
129
*/
 
130
 
 
131
 
 
132
#define PLUGIN_VAR_BOOL         0x0001
 
133
#define PLUGIN_VAR_INT          0x0002
 
134
#define PLUGIN_VAR_LONG         0x0003
 
135
#define PLUGIN_VAR_LONGLONG     0x0004
 
136
#define PLUGIN_VAR_STR          0x0005
 
137
#define PLUGIN_VAR_ENUM         0x0006
 
138
#define PLUGIN_VAR_SET          0x0007
 
139
#define PLUGIN_VAR_UNSIGNED     0x0080
 
140
#define PLUGIN_VAR_THDLOCAL     0x0100 /* Variable is per-connection */
 
141
#define PLUGIN_VAR_READONLY     0x0200 /* Server variable is read only */
 
142
#define PLUGIN_VAR_NOSYSVAR     0x0400 /* Not a server variable */
 
143
#define PLUGIN_VAR_NOCMDOPT     0x0800 /* Not a command line option */
 
144
#define PLUGIN_VAR_NOCMDARG     0x1000 /* No argument for cmd line */
 
145
#define PLUGIN_VAR_RQCMDARG     0x0000 /* Argument required for cmd line */
 
146
#define PLUGIN_VAR_OPCMDARG     0x2000 /* Argument optional for cmd line */
 
147
#define PLUGIN_VAR_MEMALLOC     0x8000 /* String needs memory allocated */
 
148
 
 
149
struct st_mysql_sys_var;
 
150
struct st_mysql_value;
 
151
 
 
152
/*
 
153
  SYNOPSIS
 
154
    (*mysql_var_check_func)()
 
155
      thd               thread handle
 
156
      var               dynamic variable being altered
 
157
      save              pointer to temporary storage
 
158
      value             user provided value
 
159
  RETURN
 
160
    0   user provided value is OK and the update func may be called.
 
161
    any other value indicates error.
 
162
  
 
163
  This function should parse the user provided value and store in the
 
164
  provided temporary storage any data as required by the update func.
 
165
  There is sufficient space in the temporary storage to store a double.
 
166
  Note that the update func may not be called if any other error occurs
 
167
  so any memory allocated should be thread-local so that it may be freed
 
168
  automatically at the end of the statement.
 
169
*/
 
170
 
 
171
typedef int (*mysql_var_check_func)(MYSQL_THD thd,
 
172
                                    struct st_mysql_sys_var *var,
 
173
                                    void *save, struct st_mysql_value *value);
 
174
 
 
175
/*
 
176
  SYNOPSIS
 
177
    (*mysql_var_update_func)()
 
178
      thd               thread handle
 
179
      var               dynamic variable being altered
 
180
      var_ptr           pointer to dynamic variable
 
181
      save              pointer to temporary storage
 
182
   RETURN
 
183
     NONE
 
184
   
 
185
   This function should use the validated value stored in the temporary store
 
186
   and persist it in the provided pointer to the dynamic variable.
 
187
   For example, strings may require memory to be allocated.
 
188
*/
 
189
typedef void (*mysql_var_update_func)(MYSQL_THD thd,
 
190
                                      struct st_mysql_sys_var *var,
 
191
                                      void *var_ptr, const void *save);
 
192
 
 
193
 
 
194
/* the following declarations are for internal use only */
 
195
 
 
196
 
 
197
#define PLUGIN_VAR_MASK \
 
198
        (PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
 
199
         PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
 
200
         PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
 
201
 
 
202
#define MYSQL_PLUGIN_VAR_HEADER \
 
203
  int flags;                    \
 
204
  const char *name;             \
 
205
  const char *comment;          \
 
206
  mysql_var_check_func check;   \
 
207
  mysql_var_update_func update
 
208
 
 
209
#define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
 
210
#define MYSQL_SYSVAR(name) \
 
211
  ((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
 
212
 
 
213
/*
 
214
  for global variables, the value pointer is the first
 
215
  element after the header, the default value is the second.
 
216
  for thread variables, the value offset is the first
 
217
  element after the header, the default value is the second.
 
218
*/
 
219
   
 
220
 
 
221
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
 
222
  MYSQL_PLUGIN_VAR_HEADER;      \
 
223
  type *value;                  \
 
224
  const type def_val;           \
 
225
} MYSQL_SYSVAR_NAME(name)
 
226
 
 
227
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
 
228
  MYSQL_PLUGIN_VAR_HEADER;      \
 
229
  type *value; type def_val;    \
 
230
  type min_val; type max_val;   \
 
231
  type blk_sz;                  \
 
232
} MYSQL_SYSVAR_NAME(name)
 
233
 
 
234
#define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
 
235
  MYSQL_PLUGIN_VAR_HEADER;      \
 
236
  type *value; type def_val;    \
 
237
  TYPELIB *typelib;             \
 
238
} MYSQL_SYSVAR_NAME(name)
 
239
 
 
240
#define DECLARE_THDVAR_FUNC(type) \
 
241
  type *(*resolve)(MYSQL_THD thd, int offset)
 
242
 
 
243
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
 
244
  MYSQL_PLUGIN_VAR_HEADER;      \
 
245
  int offset;                   \
 
246
  const type def_val;           \
 
247
  DECLARE_THDVAR_FUNC(type);    \
 
248
} MYSQL_SYSVAR_NAME(name)
 
249
 
 
250
#define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
 
251
  MYSQL_PLUGIN_VAR_HEADER;      \
 
252
  int offset;                   \
 
253
  type def_val; type min_val;   \
 
254
  type max_val; type blk_sz;    \
 
255
  DECLARE_THDVAR_FUNC(type);    \
 
256
} MYSQL_SYSVAR_NAME(name)
 
257
 
 
258
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
 
259
  MYSQL_PLUGIN_VAR_HEADER;      \
 
260
  int offset;                   \
 
261
  type def_val;                 \
 
262
  DECLARE_THDVAR_FUNC(type);    \
 
263
  TYPELIB *typelib;             \
 
264
} MYSQL_SYSVAR_NAME(name)
 
265
 
 
266
 
 
267
/*
 
268
  the following declarations are for use by plugin implementors
 
269
*/
 
270
 
 
271
#define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
 
272
DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \
 
273
  PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
 
274
  #name, comment, check, update, &varname, def}
 
275
 
 
276
#define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
 
277
DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
 
278
  PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
 
279
  #name, comment, check, update, &varname, def}
 
280
 
 
281
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
282
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
 
283
  PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
 
284
  #name, comment, check, update, &varname, def, min, max, blk }
 
285
 
 
286
#define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
 
287
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
 
288
  PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
289
  #name, comment, check, update, &varname, def, min, max, blk }
 
290
 
 
291
#define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
292
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
 
293
  PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
 
294
  #name, comment, check, update, &varname, def, min, max, blk }
 
295
 
 
296
#define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
297
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
 
298
  PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
299
  #name, comment, check, update, &varname, def, min, max, blk }
 
300
 
 
301
#define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
302
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \
 
303
  PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
 
304
  #name, comment, check, update, &varname, def, min, max, blk }
 
305
 
 
306
#define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
 
307
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
 
308
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
309
  #name, comment, check, update, &varname, def, min, max, blk }
 
310
 
 
311
#define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
 
312
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
 
313
  PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
 
314
  #name, comment, check, update, &varname, def, typelib }
 
315
 
 
316
#define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
 
317
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \
 
318
  PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
 
319
  #name, comment, check, update, &varname, def, typelib }
 
320
 
 
321
#define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
 
322
DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \
 
323
  PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
324
  #name, comment, check, update, -1, def, NULL}
 
325
 
 
326
#define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
 
327
DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
 
328
  PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
329
  #name, comment, check, update, -1, def, NULL}
 
330
 
 
331
#define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
 
332
DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
 
333
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
334
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
335
 
 
336
#define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
 
337
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
 
338
  PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
339
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
340
 
 
341
#define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
 
342
DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
 
343
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
344
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
345
 
 
346
#define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
 
347
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
 
348
  PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
349
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
350
 
 
351
#define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
352
DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \
 
353
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
354
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
355
 
 
356
#define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
 
357
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \
 
358
  PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
 
359
  #name, comment, check, update, -1, def, min, max, blk, NULL }
 
360
 
 
361
#define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
 
362
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
 
363
  PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
364
  #name, comment, check, update, -1, def, NULL, typelib }
 
365
 
 
366
#define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
 
367
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \
 
368
  PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
 
369
  #name, comment, check, update, -1, def, NULL, typelib }
 
370
 
 
371
/* accessor macros */
 
372
 
 
373
#define SYSVAR(name) \
 
374
  (*(MYSQL_SYSVAR_NAME(name).value))
 
375
 
 
376
/* when thd == null, result points to global value */
 
377
#define THDVAR(thd, name) \
 
378
  (*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
 
379
 
 
380
 
 
381
/*
 
382
  Plugin description structure.
 
383
*/
 
384
 
 
385
struct st_mysql_plugin
 
386
{
 
387
  int type;             /* the plugin type (a MYSQL_XXX_PLUGIN value)   */
 
388
  void *info;           /* pointer to type-specific plugin descriptor   */
 
389
  const char *name;     /* plugin name                                  */
 
390
  const char *author;   /* plugin author (for SHOW PLUGINS)             */
 
391
  const char *descr;    /* general descriptive text (for SHOW PLUGINS ) */
 
392
  int license;          /* the plugin license (PLUGIN_LICENSE_XXX)      */
 
393
  int (*init)(void *);  /* the function to invoke when plugin is loaded */
 
394
  int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
 
395
  unsigned int version; /* plugin version (for SHOW PLUGINS)            */
 
396
  struct st_mysql_show_var *status_vars;
 
397
  struct st_mysql_sys_var **system_vars;
 
398
  void * __reserved1;   /* reserved for dependency checking             */
 
399
};
 
400
 
 
401
/*************************************************************************
 
402
  API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
 
403
*/
 
404
#include "plugin_ftparser.h"
 
405
 
 
406
/*************************************************************************
 
407
  API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
 
408
*/
 
409
 
 
410
/* handlertons of different MySQL releases are incompatible */
 
411
#define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
412
 
 
413
/*
 
414
  Here we define only the descriptor structure, that is referred from
 
415
  st_mysql_plugin.
 
416
*/
 
417
 
 
418
struct st_mysql_daemon
 
419
{
 
420
  int interface_version;
 
421
};
 
422
 
 
423
 
 
424
/*************************************************************************
 
425
  API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
 
426
*/
 
427
 
 
428
/* handlertons of different MySQL releases are incompatible */
 
429
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
430
 
 
431
/*
 
432
  Here we define only the descriptor structure, that is referred from
 
433
  st_mysql_plugin.
 
434
*/
 
435
 
 
436
struct st_mysql_information_schema
 
437
{
 
438
  int interface_version;
 
439
};
 
440
 
 
441
 
 
442
/*************************************************************************
 
443
  API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
 
444
*/
 
445
 
 
446
/* handlertons of different MySQL releases are incompatible */
 
447
#define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
 
448
 
 
449
/*
 
450
  The real API is in the sql/handler.h
 
451
  Here we define only the descriptor structure, that is referred from
 
452
  st_mysql_plugin.
 
453
*/
 
454
 
 
455
struct st_mysql_storage_engine
 
456
{
 
457
  int interface_version;
 
458
};
 
459
 
 
460
struct handlerton;
 
461
 
 
462
 
 
463
/*************************************************************************
 
464
  st_mysql_value struct for reading values from mysqld.
 
465
  Used by server variables framework to parse user-provided values.
 
466
  Will be used for arguments when implementing UDFs.
 
467
 
 
468
  Note that val_str() returns a string in temporary memory
 
469
  that will be freed at the end of statement. Copy the string
 
470
  if you need it to persist.
 
471
*/
 
472
 
 
473
#define MYSQL_VALUE_TYPE_STRING 0
 
474
#define MYSQL_VALUE_TYPE_REAL   1
 
475
#define MYSQL_VALUE_TYPE_INT    2
 
476
 
 
477
struct st_mysql_value
 
478
{
 
479
  int (*value_type)(struct st_mysql_value *);
 
480
  const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
 
481
  int (*val_real)(struct st_mysql_value *, double *realbuf);
 
482
  int (*val_int)(struct st_mysql_value *, long long *intbuf);
 
483
};
 
484
 
 
485
 
 
486
/*************************************************************************
 
487
  Miscellaneous functions for plugin implementors
 
488
*/
 
489
 
 
490
#ifdef __cplusplus
 
491
extern "C" {
 
492
#endif
 
493
 
 
494
int thd_in_lock_tables(const MYSQL_THD thd);
 
495
int thd_tablespace_op(const MYSQL_THD thd);
 
496
long long thd_test_options(const MYSQL_THD thd, long long test_options);
 
497
int thd_sql_command(const MYSQL_THD thd);
 
498
const char *thd_proc_info(MYSQL_THD thd, const char *info);
 
499
void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
 
500
int thd_tx_isolation(const MYSQL_THD thd);
 
501
char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
 
502
                           unsigned int max_query_len);
 
503
/* Increments the row counter, see THD::row_count */
 
504
void thd_inc_row_count(MYSQL_THD thd);
 
505
 
 
506
/**
 
507
  Create a temporary file.
 
508
 
 
509
  @details
 
510
  The temporary file is created in a location specified by the mysql
 
511
  server configuration (--tmpdir option).  The caller does not need to
 
512
  delete the file, it will be deleted automatically.
 
513
 
 
514
  @param prefix  prefix for temporary file name
 
515
  @retval -1    error
 
516
  @retval >= 0  a file handle that can be passed to dup or my_close
 
517
*/
 
518
int mysql_tmpfile(const char *prefix);
 
519
 
 
520
/**
 
521
  Check the killed state of a connection
 
522
 
 
523
  @details
 
524
  In MySQL support for the KILL statement is cooperative. The KILL
 
525
  statement only sets a "killed" flag. This function returns the value
 
526
  of that flag.  A thread should check it often, especially inside
 
527
  time-consuming loops, and gracefully abort the operation if it is
 
528
  non-zero.
 
529
 
 
530
  @param thd  user thread connection handle
 
531
  @retval 0  the connection is active
 
532
  @retval 1  the connection has been killed
 
533
*/
 
534
int thd_killed(const MYSQL_THD thd);
 
535
 
 
536
 
 
537
/**
 
538
  Return the thread id of a user thread
 
539
 
 
540
  @param thd  user thread connection handle
 
541
  @return  thread id
 
542
*/
 
543
unsigned long thd_get_thread_id(const MYSQL_THD thd);
 
544
 
 
545
 
 
546
/**
 
547
  Allocate memory in the connection's local memory pool
 
548
 
 
549
  @details
 
550
  When properly used in place of @c my_malloc(), this can significantly
 
551
  improve concurrency. Don't use this or related functions to allocate
 
552
  large chunks of memory. Use for temporary storage only. The memory
 
553
  will be freed automatically at the end of the statement; no explicit
 
554
  code is required to prevent memory leaks.
 
555
 
 
556
  @see alloc_root()
 
557
*/
 
558
void *thd_alloc(MYSQL_THD thd, unsigned int size);
 
559
/**
 
560
  @see thd_alloc()
 
561
*/
 
562
void *thd_calloc(MYSQL_THD thd, unsigned int size);
 
563
/**
 
564
  @see thd_alloc()
 
565
*/
 
566
char *thd_strdup(MYSQL_THD thd, const char *str);
 
567
/**
 
568
  @see thd_alloc()
 
569
*/
 
570
char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
 
571
/**
 
572
  @see thd_alloc()
 
573
*/
 
574
void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
 
575
 
 
576
/**
 
577
  Create a LEX_STRING in this connection's local memory pool
 
578
 
 
579
  @param thd      user thread connection handle
 
580
  @param lex_str  pointer to LEX_STRING object to be initialized
 
581
  @param str      initializer to be copied into lex_str
 
582
  @param size     length of str, in bytes
 
583
  @param allocate_lex_string  flag: if TRUE, allocate new LEX_STRING object,
 
584
                              instead of using lex_str value
 
585
  @return  NULL on failure, or pointer to the LEX_STRING object
 
586
 
 
587
  @see thd_alloc()
 
588
*/
 
589
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
 
590
                                      const char *str, unsigned int size,
 
591
                                      int allocate_lex_string);
 
592
 
 
593
/**
 
594
  Get the XID for this connection's transaction
 
595
 
 
596
  @param thd  user thread connection handle
 
597
  @param xid  location where identifier is stored
 
598
*/
 
599
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
 
600
 
 
601
/**
 
602
  Invalidate the query cache for a given table.
 
603
 
 
604
  @param thd         user thread connection handle
 
605
  @param key         databasename\\0tablename\\0
 
606
  @param key_length  length of key in bytes, including the NUL bytes
 
607
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
 
608
*/
 
609
void mysql_query_cache_invalidate4(MYSQL_THD thd,
 
610
                                   const char *key, unsigned int key_length,
 
611
                                   int using_trx);
 
612
 
 
613
#ifdef __cplusplus
 
614
}
 
615
#endif
 
616
 
 
617
#ifdef __cplusplus
 
618
/**
 
619
  Provide a handler data getter to simplify coding
 
620
*/
 
621
inline
 
622
void *
 
623
thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton)
 
624
{
 
625
  return *thd_ha_data(thd, hton);
 
626
}
 
627
 
 
628
/**
 
629
  Provide a handler data setter to simplify coding
 
630
*/
 
631
inline
 
632
void
 
633
thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton,
 
634
                const void *ha_data)
 
635
{
 
636
  *thd_ha_data(thd, hton)= (void*) ha_data;
 
637
}
 
638
#endif
 
639
 
 
640
#endif
 
641