58
56
if (plugin->plugin->deinit((void *)p))
60
/* TRANSLATORS: The leading word "qcache" is the name
61
of the plugin api, and so should not be translated. */
62
58
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' deinit() failed"),
72
/* The plugin_foreach() iterator requires that we
73
convert all the parameters of a plugin api entry point
74
into just one single void ptr, plus the session.
75
So we will take all the additional paramters of qcache_do1,
76
and marshall them into a struct of this type, and
77
then just pass in a pointer to it.
79
typedef struct qcache_do1_parms_st
85
/* This gets called by plugin_foreach once for each loaded qcache plugin */
86
static bool qcache_do1_iterate (Session *session, plugin_ref plugin, void *p)
88
qcache_t *l= plugin_data(plugin, qcache_t *);
89
qcache_do1_parms_t *parms= (qcache_do1_parms_t *) p;
91
/* call this loaded qcache plugin's qcache_func1 function pointer */
92
if (l && l->qcache_func1)
94
if (l->qcache_func1(session, parms->parm1, parms->parm2))
96
/* TRANSLATORS: The leading word "qcache" is the name
97
of the plugin api, and so should not be translated. */
98
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' do1() failed"),
99
(char *)plugin_name(plugin));
106
/* This is the qcache_do1 entry point.
107
This gets called by the rest of the Drizzle server code */
108
bool qcache_do1 (Session *session, void *parm1, void *parm2)
110
qcache_do1_parms_t parms;
113
/* marshall the parameters so they will fit into the foreach */
117
/* call qcache_do1_iterate
118
once for each loaded qcache plugin */
119
foreach_rv= plugin_foreach(session,
121
DRIZZLE_QCACHE_PLUGIN,
126
/* The plugin_foreach() iterator requires that we
127
convert all the parameters of a plugin api entry point
128
into just one single void ptr, plus the session.
129
So we will take all the additional paramters of qcache_do2,
130
and marshall them into a struct of this type, and
131
then just pass in a pointer to it.
133
typedef struct qcache_do2_parms_st
137
} qcache_do2_parms_t;
139
/* This gets called by plugin_foreach once for each loaded qcache plugin */
140
static bool qcache_do2_iterate (Session *session, plugin_ref plugin, void *p)
142
qcache_t *l= plugin_data(plugin, qcache_t *);
143
qcache_do2_parms_t *parms= (qcache_do2_parms_t *) p;
145
/* call this loaded qcache plugin's qcache_func1 function pointer */
146
if (l && l->qcache_func1)
148
if (l->qcache_func2(session, parms->parm3, parms->parm4))
150
/* TRANSLATORS: The leading word "qcache" is the name
151
of the plugin api, and so should not be translated. */
152
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' qcache_func2() failed"),
153
(char *)plugin_name(plugin));
161
/* This is the qcache_do2 entry point.
162
This gets called by the rest of the Drizzle server code */
163
bool qcache_do2 (Session *session, void *parm3, void *parm4)
165
qcache_do2_parms_t parms;
168
/* marshall the parameters so they will fit into the foreach */
172
/* call qcache_do2_iterate
173
once for each loaded qcache plugin */
174
foreach_rv= plugin_foreach(session,
176
DRIZZLE_QCACHE_PLUGIN,
68
The plugin_foreach() iterator requires that we convert all the parameters
69
of a plugin API entry point into a single void pointer, plus the session.
70
So we need the following structure for qcache_invalidate_db() which requires
73
typedef struct db_invalidation_parms
77
} db_invalidation_parms_t;
83
qcache_try_fetch_and_send_iterate();
85
qcache_invalidate_table_iterate();
86
qcache_invalidate_db_iterate();
87
qcache_flush_iterate();
89
are called by plugin_foreach() _once_ for each Query Cache plugin.
92
static bool qcache_try_fetch_and_send_iterate(Session *session,
93
plugin_ref plugin, void *p)
95
qcache_t *l= plugin_data(plugin, qcache_t *);
96
bool is_transactional = (bool *)p;
98
if (l && l->qcache_try_fetch_and_send)
100
if (l->qcache_try_fetch_and_send(session, is_transactional))
102
errmsg_printf(ERRMSG_LVL_ERROR,
103
_("qcache plugin '%s' try_fetch_and_send() failed"),
104
(char *)plugin_name(plugin));
111
static bool qcache_set_iterate(Session *session, plugin_ref plugin, void *p)
113
qcache_t *l = plugin_data(plugin, qcache_t *);
114
bool transactional = (bool *)p;
116
if (l && l->qcache_set)
118
if (l->qcache_set(session, transactional))
120
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' set() failed"),
121
(char *)plugin_name(plugin));
128
static bool qcache_invalidate_table_iterate(Session *session,
129
plugin_ref plugin, void *p)
131
qcache_t *l = plugin_data(plugin, qcache_t *);
132
bool transactional = (bool *)p;
134
if (l && l->qcache_invalidate_table)
136
if (l->qcache_invalidate_table(session, transactional))
138
errmsg_printf(ERRMSG_LVL_ERROR,
139
_("qcache plugin '%s' invalidate_table() failed"),
140
(char *)plugin_name(plugin));
147
static bool qcache_invalidate_db_iterate(Session *session,
148
plugin_ref plugin, void *p)
150
qcache_t *l = plugin_data(plugin, qcache_t *);
151
db_invalidation_parms_t *parms = (db_invalidation_parms_t *)p;
153
if (l && l->qcache_invalidate_db)
155
if (l->qcache_invalidate_db(session, parms->dbname, parms->transactional))
157
errmsg_printf(ERRMSG_LVL_ERROR,
158
_("qcache plugin '%s' invalidate_db() failed"),
159
(char *)plugin_name(plugin));
166
static bool qcache_flush_iterate(Session *session, plugin_ref plugin, void *p)
168
qcache_t *l = plugin_data(plugin, qcache_t *);
170
if (p) return true; /* flush has no parameters, return failure */
172
if (l && l->qcache_flush)
174
if (l->qcache_flush(session))
176
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' flush() failed"),
177
(char *)plugin_name(plugin));
188
drizzle_qcache_try_fetch_and_send();
189
drizzle_qcache_set();
190
drizzle_qcache_invalidate_table();
191
drizzle_qcache_invalidate_db();
192
drizzle_qcache_flush();
194
are the entry points to the query cache plugin that is called by the
195
rest of the Drizzle server code.
198
bool drizzle_qcache_try_fetch_and_send(Session *session, bool transactional)
201
foreach_rv= plugin_foreach(session,
202
qcache_try_fetch_and_send_iterate,
203
DRIZZLE_QCACHE_PLUGIN,
204
(void *) &transactional);
208
bool drizzle_qcache_set(Session *session, bool transactional)
211
foreach_rv= plugin_foreach(session,
213
DRIZZLE_QCACHE_PLUGIN,
214
(void *) &transactional);
218
bool drizzle_qcache_invalidate_table(Session *session, bool transactional)
221
foreach_rv= plugin_foreach(session,
222
qcache_invalidate_table_iterate,
223
DRIZZLE_QCACHE_PLUGIN,
224
(void *) &transactional);
228
bool drizzle_qcache_invalidate_db(Session *session, const char *dbname,
232
db_invalidation_parms_t parms;
234
/* marshall the parameters */
235
parms.dbname = dbname;
236
parms.transactional = transactional;
238
foreach_rv= plugin_foreach(session,
239
qcache_invalidate_db_iterate,
240
DRIZZLE_QCACHE_PLUGIN,
245
bool drizzle_qcache_flush(Session *session)
248
foreach_rv= plugin_foreach(session,
249
qcache_flush_iterate,
250
DRIZZLE_QCACHE_PLUGIN,
178
252
return foreach_rv;