1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Mark Atwood
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.
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.
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
20
#include <drizzled/server_includes.h>
21
#include <drizzled/qcache.h>
23
int qcache_initializer(st_plugin_int *plugin)
27
p= (qcache_t *) malloc(sizeof(qcache_t));
28
if (p == NULL) return 1;
29
memset(p, 0, sizeof(qcache_t));
31
plugin->data= (void *)p;
33
if (plugin->plugin->init)
35
if (plugin->plugin->init((void *)p))
37
/* TRANSLATORS: The leading word "qcache" is the name
38
of the plugin api, and so should not be translated. */
39
sql_print_error(_("qcache plugin '%s' init() failed"),
51
int qcache_finalizer(st_plugin_int *plugin)
53
qcache_t *p= (qcache_t *) plugin->data;
55
if (plugin->plugin->deinit)
57
if (plugin->plugin->deinit((void *)p))
59
/* TRANSLATORS: The leading word "qcache" is the name
60
of the plugin api, and so should not be translated. */
61
sql_print_error(_("qcache plugin '%s' deinit() failed"),
71
/* The plugin_foreach() iterator requires that we
72
convert all the parameters of a plugin api entry point
73
into just one single void ptr, plus the thd.
74
So we will take all the additional paramters of qcache_do1,
75
and marshall them into a struct of this type, and
76
then just pass in a pointer to it.
78
typedef struct qcache_do1_parms_st
84
/* This gets called by plugin_foreach once for each loaded qcache plugin */
85
static bool qcache_do1_iterate (THD *thd, plugin_ref plugin, void *p)
87
qcache_t *l= plugin_data(plugin, qcache_t *);
88
qcache_do1_parms_t *parms= (qcache_do1_parms_t *) p;
90
/* call this loaded qcache plugin's qcache_func1 function pointer */
91
if (l && l->qcache_func1)
93
if (l->qcache_func1(thd, parms->parm1, parms->parm2))
95
/* TRANSLATORS: The leading word "qcache" is the name
96
of the plugin api, and so should not be translated. */
97
sql_print_error(_("qcache plugin '%s' do1() failed"),
98
(char *)plugin_name(plugin));
105
/* This is the qcache_do1 entry point.
106
This gets called by the rest of the Drizzle server code */
107
bool qcache_do1 (THD *thd, void *parm1, void *parm2)
109
qcache_do1_parms_t parms;
112
/* marshall the parameters so they will fit into the foreach */
116
/* call qcache_do1_iterate
117
once for each loaded qcache plugin */
118
foreach_rv= plugin_foreach(thd,
120
DRIZZLE_QCACHE_PLUGIN,
125
/* The plugin_foreach() iterator requires that we
126
convert all the parameters of a plugin api entry point
127
into just one single void ptr, plus the thd.
128
So we will take all the additional paramters of qcache_do2,
129
and marshall them into a struct of this type, and
130
then just pass in a pointer to it.
132
typedef struct qcache_do2_parms_st
136
} qcache_do2_parms_t;
138
/* This gets called by plugin_foreach once for each loaded qcache plugin */
139
static bool qcache_do2_iterate (THD *thd, plugin_ref plugin, void *p)
141
qcache_t *l= plugin_data(plugin, qcache_t *);
142
qcache_do2_parms_t *parms= (qcache_do2_parms_t *) p;
144
/* call this loaded qcache plugin's qcache_func1 function pointer */
145
if (l && l->qcache_func1)
147
if (l->qcache_func2(thd, parms->parm3, parms->parm4))
149
/* TRANSLATORS: The leading word "qcache" is the name
150
of the plugin api, and so should not be translated. */
151
sql_print_error(_("qcache plugin '%s' qcache_func2() failed"),
152
(char *)plugin_name(plugin));
160
/* This is the qcache_do2 entry point.
161
This gets called by the rest of the Drizzle server code */
162
bool qcache_do2 (THD *thd, void *parm3, void *parm4)
164
qcache_do2_parms_t parms;
167
/* marshall the parameters so they will fit into the foreach */
171
/* call qcache_do2_iterate
172
once for each loaded qcache plugin */
173
foreach_rv= plugin_foreach(thd,
175
DRIZZLE_QCACHE_PLUGIN,