~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin.h

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:33:16 UTC
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016113316-ff6jdt31ck90sjdh
an implemention of the errmsg plugin

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
 
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
 */
 
19
 
 
20
#ifndef DRIZZLED_PLUGIN_H
 
21
#define DRIZZLED_PLUGIN_H
18
22
 
19
23
#include <drizzled/global.h>
20
24
 
21
 
#ifdef __cplusplus
22
25
class THD;
23
26
class Item;
24
 
#define DRIZZLE_THD THD*
25
 
#else
26
 
#define DRIZZLE_THD void*
27
 
#endif
28
 
 
29
 
 
30
 
#ifndef _m_string_h
31
 
/* This definition must match the one given in m_string.h */
32
 
struct st_mysql_lex_string
33
 
{
34
 
  char *str;
35
 
  unsigned int length;
36
 
};
37
 
#endif /* _m_string_h */
38
 
typedef struct st_mysql_lex_string DRIZZLE_LEX_STRING;
39
27
 
40
28
#define DRIZZLE_XIDDATASIZE 128
41
29
/**
65
53
#define DRIZZLE_STORAGE_ENGINE_PLUGIN  1  /* Storage Engine */
66
54
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN  2  /* Information Schema */
67
55
#define DRIZZLE_UDF_PLUGIN             3  /* User-Defined Function */
68
 
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate function */
 
56
#define DRIZZLE_UDA_PLUGIN             4  /* User-Defined Aggregate Function */
69
57
#define DRIZZLE_AUDIT_PLUGIN           5  /* Audit */
70
 
#define DRIZZLE_LOGGER_PLUGIN          6  /* Logging */
71
 
#define DRIZZLE_AUTH_PLUGIN            7  /* Authorization */
 
58
#define DRIZZLE_LOGGER_PLUGIN          6  /* Query Logging */
 
59
#define DRIZZLE_ERRMSG_PLUGIN          7  /* Error Messages */
 
60
#define DRIZZLE_AUTH_PLUGIN            8  /* Authorization */
 
61
#define DRIZZLE_CONFIGVAR_PLUGIN       9  /* Configuration */
 
62
#define DRIZZLE_QCACHE_PLUGIN         10  /* Query Cache */
72
63
 
73
 
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM    8  /* The number of plugin types */
 
64
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM   11  /* The number of plugin types */
74
65
 
75
66
/* We use the following strings to define licenses for plugins */
76
67
#define PLUGIN_LICENSE_PROPRIETARY 0
120
111
 
121
112
 
122
113
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
123
 
typedef int (*mysql_show_var_func)(DRIZZLE_THD, struct st_mysql_show_var*, char *);
 
114
typedef int (*mysql_show_var_func)(THD *, struct st_mysql_show_var *, char *);
124
115
 
125
116
struct st_show_var_func_container {
126
117
  mysql_show_var_func func;
169
160
  automatically at the end of the statement.
170
161
*/
171
162
 
172
 
typedef int (*mysql_var_check_func)(DRIZZLE_THD thd,
 
163
typedef int (*mysql_var_check_func)(THD *thd,
173
164
                                    struct st_mysql_sys_var *var,
174
165
                                    void *save, struct st_mysql_value *value);
175
166
 
187
178
   and persist it in the provided pointer to the dynamic variable.
188
179
   For example, strings may require memory to be allocated.
189
180
*/
190
 
typedef void (*mysql_var_update_func)(DRIZZLE_THD thd,
 
181
typedef void (*mysql_var_update_func)(THD *thd,
191
182
                                      struct st_mysql_sys_var *var,
192
183
                                      void *var_ptr, const void *save);
193
184
 
239
230
} DRIZZLE_SYSVAR_NAME(name)
240
231
 
241
232
#define DECLARE_THDVAR_FUNC(type) \
242
 
  type *(*resolve)(DRIZZLE_THD thd, int offset)
 
233
  type *(*resolve)(THD *thd, int offset)
243
234
 
244
235
#define DECLARE_DRIZZLE_THDVAR_BASIC(name, type) struct { \
245
236
  DRIZZLE_PLUGIN_VAR_HEADER;      \
432
423
extern "C" {
433
424
#endif
434
425
 
435
 
int thd_in_lock_tables(const DRIZZLE_THD thd);
436
 
int thd_tablespace_op(const DRIZZLE_THD thd);
437
 
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
438
 
int thd_sql_command(const DRIZZLE_THD thd);
439
 
const char *thd_proc_info(DRIZZLE_THD thd, const char *info);
440
 
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
441
 
int thd_tx_isolation(const DRIZZLE_THD thd);
 
426
int thd_in_lock_tables(const THD *thd);
 
427
int thd_tablespace_op(const THD *thd);
 
428
int64_t thd_test_options(const THD *thd, int64_t test_options);
 
429
int thd_sql_command(const THD *thd);
 
430
void **thd_ha_data(const THD *thd, const struct handlerton *hton);
 
431
int thd_tx_isolation(const THD *thd);
442
432
/* Increments the row counter, see THD::row_count */
443
 
void thd_inc_row_count(DRIZZLE_THD thd);
 
433
void thd_inc_row_count(THD *thd);
444
434
 
445
435
/**
446
436
  Create a temporary file.
470
460
  @retval 0  the connection is active
471
461
  @retval 1  the connection has been killed
472
462
*/
473
 
int thd_killed(const DRIZZLE_THD thd);
 
463
int thd_killed(const THD *thd);
474
464
 
475
465
 
476
466
/**
479
469
  @param thd  user thread connection handle
480
470
  @return  thread id
481
471
*/
482
 
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
 
472
unsigned long thd_get_thread_id(const THD *thd);
483
473
 
484
474
 
485
475
/**
494
484
 
495
485
  @see alloc_root()
496
486
*/
497
 
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
498
 
/**
499
 
  @see thd_alloc()
500
 
*/
501
 
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
502
 
/**
503
 
  @see thd_alloc()
504
 
*/
505
 
char *thd_strdup(DRIZZLE_THD thd, const char *str);
506
 
/**
507
 
  @see thd_alloc()
508
 
*/
509
 
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
510
 
/**
511
 
  @see thd_alloc()
512
 
*/
513
 
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
514
 
 
515
 
/**
516
 
  Create a LEX_STRING in this connection's local memory pool
517
 
 
518
 
  @param thd      user thread connection handle
519
 
  @param lex_str  pointer to LEX_STRING object to be initialized
520
 
  @param str      initializer to be copied into lex_str
521
 
  @param size     length of str, in bytes
522
 
  @param allocate_lex_string  flag: if TRUE, allocate new LEX_STRING object,
523
 
                              instead of using lex_str value
524
 
  @return  NULL on failure, or pointer to the LEX_STRING object
525
 
 
526
 
  @see thd_alloc()
527
 
*/
528
 
DRIZZLE_LEX_STRING *thd_make_lex_string(DRIZZLE_THD thd, DRIZZLE_LEX_STRING *lex_str,
529
 
                                      const char *str, unsigned int size,
530
 
                                      int allocate_lex_string);
 
487
void *thd_alloc(THD *thd, unsigned int size);
 
488
/**
 
489
  @see thd_alloc()
 
490
*/
 
491
void *thd_calloc(THD *thd, unsigned int size);
 
492
/**
 
493
  @see thd_alloc()
 
494
*/
 
495
char *thd_strdup(THD *thd, const char *str);
 
496
/**
 
497
  @see thd_alloc()
 
498
*/
 
499
char *thd_strmake(THD *thd, const char *str, unsigned int size);
 
500
/**
 
501
  @see thd_alloc()
 
502
*/
 
503
void *thd_memdup(THD *thd, const void* str, unsigned int size);
531
504
 
532
505
/**
533
506
  Get the XID for this connection's transaction
535
508
  @param thd  user thread connection handle
536
509
  @param xid  location where identifier is stored
537
510
*/
538
 
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
 
511
void thd_get_xid(const THD *thd, DRIZZLE_XID *xid);
539
512
 
540
513
/**
541
514
  Invalidate the query cache for a given table.
545
518
  @param key_length  length of key in bytes, including the NUL bytes
546
519
  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
547
520
*/
548
 
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
 
521
void mysql_query_cache_invalidate4(THD *thd,
549
522
                                   const char *key, unsigned int key_length,
550
523
                                   int using_trx);
551
524
 
559
532
*/
560
533
inline
561
534
void *
562
 
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
 
535
thd_get_ha_data(const THD *thd, const struct handlerton *hton)
563
536
{
564
537
  return *thd_ha_data(thd, hton);
565
538
}
569
542
*/
570
543
inline
571
544
void
572
 
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
 
545
thd_set_ha_data(const THD *thd, const struct handlerton *hton,
573
546
                const void *ha_data)
574
547
{
575
548
  *thd_ha_data(thd, hton)= (void*) ha_data;
576
549
}
577
550
#endif
578
551
 
579
 
#endif
 
552
#endif /* _my_plugin_h */
580
553