~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/sql_plugin.h

Put errmsg.c in sql-common since it can be built only once and used twice.
Put client.c and net_serv.c in libmysql so that we can only have one
link_sources section. 
Got rid of just about all copying and other weirdness, other than some stuff
in client and client.c/net_serv.c, which need to be reworked.

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
 
 */
19
 
 
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
/* 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 _sql_plugin_h
 
17
#define _sql_plugin_h
38
18
 
39
19
class sys_var;
40
20
 
55
35
                     SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE,   \
56
36
                     SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
57
37
                     SHOW_LONGLONG_STATUS
58
 
#include <drizzled/plugin.h>
 
38
#include <mysql/plugin.h>
59
39
#undef SHOW_FUNC
60
40
typedef enum enum_mysql_show_type SHOW_TYPE;
61
41
typedef struct st_mysql_show_var SHOW_VAR;
62
42
 
63
 
#define DRIZZLE_ANY_PLUGIN         -1
 
43
#define MYSQL_ANY_PLUGIN         -1
64
44
 
65
45
/*
66
46
  different values of st_plugin_int::state
82
62
  LEX_STRING dl;
83
63
  void *handle;
84
64
  struct st_mysql_plugin *plugins;
85
 
  uint32_t ref_count;            /* number of plugins loaded from the library */
 
65
  int version;
 
66
  uint ref_count;            /* number of plugins loaded from the library */
86
67
};
87
68
 
88
69
/* A handle of a plugin */
92
73
  LEX_STRING name;
93
74
  struct st_mysql_plugin *plugin;
94
75
  struct st_plugin_dl *plugin_dl;
95
 
  uint32_t state;
96
 
  uint32_t ref_count;               /* number of threads using the plugin */
 
76
  uint state;
 
77
  uint ref_count;               /* number of threads using the plugin */
97
78
  void *data;                   /* plugin type specific, e.g. handlerton */
98
79
  MEM_ROOT mem_root;            /* memory for dynamic plugin structures */
99
80
  sys_var *system_vars;         /* server variables for this plugin */
104
85
  See intern_plugin_lock() for the explanation for the
105
86
  conditionally defined plugin_ref type
106
87
*/
 
88
#ifdef DBUG_OFF
 
89
typedef struct st_plugin_int *plugin_ref;
 
90
#define plugin_decl(pi) ((pi)->plugin)
 
91
#define plugin_dlib(pi) ((pi)->plugin_dl)
 
92
#define plugin_data(pi,cast) ((cast)((pi)->data))
 
93
#define plugin_name(pi) (&((pi)->name))
 
94
#define plugin_state(pi) ((pi)->state)
 
95
#define plugin_equals(p1,p2) ((p1) == (p2))
 
96
#else
107
97
typedef struct st_plugin_int **plugin_ref;
108
98
#define plugin_decl(pi) ((pi)[0]->plugin)
109
99
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
111
101
#define plugin_name(pi) (&((pi)[0]->name))
112
102
#define plugin_state(pi) ((pi)[0]->state)
113
103
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
 
104
#endif
114
105
 
115
106
typedef int (*plugin_type_init)(struct st_plugin_int *);
116
107
 
121
112
 
122
113
extern int plugin_init(int *argc, char **argv, int init_flags);
123
114
extern void plugin_shutdown(void);
124
 
extern void my_print_help_inc_plugins(struct my_option *options, uint32_t size);
 
115
extern void my_print_help_inc_plugins(struct my_option *options, uint size);
125
116
extern bool plugin_is_ready(const LEX_STRING *name, int type);
126
117
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
127
118
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
131
122
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
132
123
                                      int type CALLER_INFO_PROTO);
133
124
extern void plugin_unlock(THD *thd, plugin_ref plugin);
134
 
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint32_t count);
 
125
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
135
126
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
136
127
                                 const LEX_STRING *dl);
137
128
extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name);
139
130
extern void plugin_thdvar_init(THD *thd);
140
131
extern void plugin_thdvar_cleanup(THD *thd);
141
132
 
142
 
typedef bool (plugin_foreach_func)(THD *thd,
143
 
                                   plugin_ref plugin,
144
 
                                   void *arg);
 
133
typedef my_bool (plugin_foreach_func)(THD *thd,
 
134
                                      plugin_ref plugin,
 
135
                                      void *arg);
145
136
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
146
137
extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
147
 
                                     int type, uint32_t state_mask, void *arg);
148
 
#endif /* DRIZZLE_SERVER_PLUGIN_H */
 
138
                                     int type, uint state_mask, void *arg);
 
139
#endif