~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to sql/sql_plugin.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2011-11-08 11:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20111108113113-3ulw01fvi4vn8m25
Tags: upstream-5.5.17
ImportĀ upstreamĀ versionĀ 5.5.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
 
15
 
 
16
#ifndef _sql_plugin_h
 
17
#define _sql_plugin_h
 
18
 
 
19
#include <my_global.h>
 
20
 
 
21
/*
 
22
  the following #define adds server-only members to enum_mysql_show_type,
 
23
  that is defined in plugin.h
 
24
*/
 
25
#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
 
26
            SHOW_KEY_CACHE_LONGLONG, SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
 
27
            SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
 
28
            SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS, SHOW_LEX_STRING
 
29
#include <mysql/plugin.h>
 
30
#undef SHOW_always_last
 
31
 
 
32
#include "m_string.h"                       /* LEX_STRING */
 
33
#include "my_alloc.h"                       /* MEM_ROOT */
 
34
 
 
35
class sys_var;
 
36
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
 
37
enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE,
 
38
  PLUGIN_FORCE_PLUS_PERMANENT };
 
39
extern const char *global_plugin_typelib_names[];
 
40
 
 
41
#include <my_sys.h>
 
42
 
 
43
#ifdef DBUG_OFF
 
44
#define plugin_ref_to_int(A) A
 
45
#define plugin_int_to_ref(A) A
 
46
#else
 
47
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
 
48
#define plugin_int_to_ref(A) &(A)
 
49
#endif
 
50
 
 
51
/*
 
52
  the following flags are valid for plugin_init()
 
53
*/
 
54
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
 
55
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE    2
 
56
#define PLUGIN_INIT_SKIP_INITIALIZATION  4
 
57
 
 
58
#define INITIAL_LEX_PLUGIN_LIST_SIZE    16
 
59
 
 
60
typedef enum enum_mysql_show_type SHOW_TYPE;
 
61
typedef struct st_mysql_show_var SHOW_VAR;
 
62
typedef struct st_mysql_lex_string LEX_STRING;
 
63
 
 
64
#define MYSQL_ANY_PLUGIN         -1
 
65
 
 
66
/*
 
67
  different values of st_plugin_int::state
 
68
  though they look like a bitmap, plugin may only
 
69
  be in one of those eigenstates, not in a superposition of them :)
 
70
  It's a bitmap, because it makes it easier to test
 
71
  "whether the state is one of those..."
 
72
*/
 
73
#define PLUGIN_IS_FREED         1
 
74
#define PLUGIN_IS_DELETED       2
 
75
#define PLUGIN_IS_UNINITIALIZED 4
 
76
#define PLUGIN_IS_READY         8
 
77
#define PLUGIN_IS_DYING         16
 
78
#define PLUGIN_IS_DISABLED      32
 
79
 
 
80
/* A handle for the dynamic library containing a plugin or plugins. */
 
81
 
 
82
struct st_plugin_dl
 
83
{
 
84
  LEX_STRING dl;
 
85
  void *handle;
 
86
  struct st_mysql_plugin *plugins;
 
87
  int version;
 
88
  uint ref_count;            /* number of plugins loaded from the library */
 
89
};
 
90
 
 
91
/* A handle of a plugin */
 
92
 
 
93
struct st_plugin_int
 
94
{
 
95
  LEX_STRING name;
 
96
  struct st_mysql_plugin *plugin;
 
97
  struct st_plugin_dl *plugin_dl;
 
98
  uint state;
 
99
  uint ref_count;               /* number of threads using the plugin */
 
100
  void *data;                   /* plugin type specific, e.g. handlerton */
 
101
  MEM_ROOT mem_root;            /* memory for dynamic plugin structures */
 
102
  sys_var *system_vars;         /* server variables for this plugin */
 
103
  enum enum_plugin_load_option load_option; /* OFF, ON, FORCE, F+PERMANENT */
 
104
};
 
105
 
 
106
 
 
107
/*
 
108
  See intern_plugin_lock() for the explanation for the
 
109
  conditionally defined plugin_ref type
 
110
*/
 
111
#ifdef DBUG_OFF
 
112
typedef struct st_plugin_int *plugin_ref;
 
113
#define plugin_decl(pi) ((pi)->plugin)
 
114
#define plugin_dlib(pi) ((pi)->plugin_dl)
 
115
#define plugin_data(pi,cast) ((cast)((pi)->data))
 
116
#define plugin_name(pi) (&((pi)->name))
 
117
#define plugin_state(pi) ((pi)->state)
 
118
#define plugin_load_option(pi) ((pi)->load_option)
 
119
#define plugin_equals(p1,p2) ((p1) == (p2))
 
120
#else
 
121
typedef struct st_plugin_int **plugin_ref;
 
122
#define plugin_decl(pi) ((pi)[0]->plugin)
 
123
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
 
124
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
 
125
#define plugin_name(pi) (&((pi)[0]->name))
 
126
#define plugin_state(pi) ((pi)[0]->state)
 
127
#define plugin_load_option(pi) ((pi)[0]->load_option)
 
128
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
 
129
#endif
 
130
 
 
131
typedef int (*plugin_type_init)(struct st_plugin_int *);
 
132
 
 
133
extern char *opt_plugin_load;
 
134
extern char *opt_plugin_dir_ptr;
 
135
extern char opt_plugin_dir[FN_REFLEN];
 
136
extern const LEX_STRING plugin_type_names[];
 
137
 
 
138
extern int plugin_init(int *argc, char **argv, int init_flags);
 
139
extern void plugin_shutdown(void);
 
140
void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root);
 
141
extern bool plugin_is_ready(const LEX_STRING *name, int type);
 
142
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C)
 
143
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C)
 
144
#define my_plugin_lock(A,B) plugin_lock(A,B)
 
145
#define my_plugin_lock_ci(A,B) plugin_lock(A,B)
 
146
extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr);
 
147
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
 
148
                                      int type);
 
149
extern void plugin_unlock(THD *thd, plugin_ref plugin);
 
150
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
 
151
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
 
152
                                 const LEX_STRING *dl);
 
153
extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name);
 
154
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
 
155
extern void plugin_thdvar_init(THD *thd);
 
156
extern void plugin_thdvar_cleanup(THD *thd);
 
157
extern SHOW_COMP_OPTION plugin_status(const char *name, int len, size_t type);
 
158
extern bool check_valid_path(const char *path, size_t length);
 
159
 
 
160
typedef my_bool (plugin_foreach_func)(THD *thd,
 
161
                                      plugin_ref plugin,
 
162
                                      void *arg);
 
163
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
 
164
extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
 
165
                                     int type, uint state_mask, void *arg);
 
166
#endif