~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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 by brian
clean slate
19
243.1.11 by Jay Pipes
* Added include guards in a couple places, and removed unecessary
20
/** 
21
 * @TODO There is plugin.h and also sql_plugin.h.  Ostensibly,  
22
 * it seems that the two files exist so that plugin.h can provide an
23
 * external API for plugin developers and sql_plugin.h will provide
24
 * and internal server API for dealing with those plugins.
25
 *
26
 * However, there are parts of plugin.h marked "INTERNAL USE ONLY" which
27
 * seems to contradict the above...
28
 *
29
 * Let's figure out a better way of dividing the public and internal API
30
 * and name the files more appropriately.
31
 *
32
 * Also, less #defines, more enums and bitmaps...
33
 *
34
 */
35
36
#ifndef DRIZZLE_SERVER_PLUGIN_H
37
#define DRIZZLE_SERVER_PLUGIN_H
1 by brian
clean slate
38
39
class sys_var;
40
41
/*
42
  the following flags are valid for plugin_init()
43
*/
44
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
45
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE    2
46
#define PLUGIN_INIT_SKIP_INITIALIZATION  4
47
48
#define INITIAL_LEX_PLUGIN_LIST_SIZE    16
49
50
/*
51
  the following #define adds server-only members to enum_mysql_show_type,
52
  that is defined in plugin.h
53
*/
54
#define SHOW_FUNC    SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
55
                     SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE,   \
56
                     SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
57
                     SHOW_LONGLONG_STATUS
212.5.10 by Monty Taylor
Moved drizzle/plugin*h to drizzled
58
#include <drizzled/plugin.h>
1 by brian
clean slate
59
#undef SHOW_FUNC
60
typedef enum enum_mysql_show_type SHOW_TYPE;
61
typedef struct st_mysql_show_var SHOW_VAR;
62
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
63
#define DRIZZLE_ANY_PLUGIN         -1
1 by brian
clean slate
64
65
/*
66
  different values of st_plugin_int::state
67
  though they look like a bitmap, plugin may only
68
  be in one of those eigenstates, not in a superposition of them :)
69
  It's a bitmap, because it makes it easier to test
70
  "whether the state is one of those..."
71
*/
72
#define PLUGIN_IS_FREED         1
73
#define PLUGIN_IS_DELETED       2
74
#define PLUGIN_IS_UNINITIALIZED 4
75
#define PLUGIN_IS_READY         8
76
#define PLUGIN_IS_DYING         16
77
78
/* A handle for the dynamic library containing a plugin or plugins. */
79
80
struct st_plugin_dl
81
{
82
  LEX_STRING dl;
83
  void *handle;
84
  struct st_mysql_plugin *plugins;
482 by Brian Aker
Remove uint.
85
  uint32_t ref_count;            /* number of plugins loaded from the library */
1 by brian
clean slate
86
};
87
88
/* A handle of a plugin */
89
90
struct st_plugin_int
91
{
92
  LEX_STRING name;
93
  struct st_mysql_plugin *plugin;
94
  struct st_plugin_dl *plugin_dl;
482 by Brian Aker
Remove uint.
95
  uint32_t state;
96
  uint32_t ref_count;               /* number of threads using the plugin */
1 by brian
clean slate
97
  void *data;                   /* plugin type specific, e.g. handlerton */
98
  MEM_ROOT mem_root;            /* memory for dynamic plugin structures */
99
  sys_var *system_vars;         /* server variables for this plugin */
100
};
101
102
103
/*
104
  See intern_plugin_lock() for the explanation for the
105
  conditionally defined plugin_ref type
106
*/
107
typedef struct st_plugin_int **plugin_ref;
108
#define plugin_decl(pi) ((pi)[0]->plugin)
109
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
110
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
111
#define plugin_name(pi) (&((pi)[0]->name))
112
#define plugin_state(pi) ((pi)[0]->state)
113
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
114
115
typedef int (*plugin_type_init)(struct st_plugin_int *);
116
117
extern char *opt_plugin_load;
118
extern char *opt_plugin_dir_ptr;
119
extern char opt_plugin_dir[FN_REFLEN];
120
extern const LEX_STRING plugin_type_names[];
121
122
extern int plugin_init(int *argc, char **argv, int init_flags);
123
extern void plugin_shutdown(void);
482 by Brian Aker
Remove uint.
124
extern void my_print_help_inc_plugins(struct my_option *options, uint32_t size);
1 by brian
clean slate
125
extern bool plugin_is_ready(const LEX_STRING *name, int type);
126
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
127
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
128
#define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO)
129
#define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO)
130
extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO);
131
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
132
                                      int type CALLER_INFO_PROTO);
133
extern void plugin_unlock(THD *thd, plugin_ref plugin);
482 by Brian Aker
Remove uint.
134
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint32_t count);
1 by brian
clean slate
135
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
136
                                 const LEX_STRING *dl);
137
extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name);
138
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
139
extern void plugin_thdvar_init(THD *thd);
140
extern void plugin_thdvar_cleanup(THD *thd);
141
149 by Brian Aker
More bool conversion.
142
typedef bool (plugin_foreach_func)(THD *thd,
143
                                   plugin_ref plugin,
144
                                   void *arg);
1 by brian
clean slate
145
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
146
extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
482 by Brian Aker
Remove uint.
147
                                     int type, uint32_t state_mask, void *arg);
243.1.11 by Jay Pipes
* Added include guards in a couple places, and removed unecessary
148
#endif /* DRIZZLE_SERVER_PLUGIN_H */