36
vector<plugin::QueryCache *> all_query_cache;
36
typedef vector<plugin::QueryCache *> QueryCaches;
37
QueryCaches all_query_cache;
38
39
/* Namespaces are here to prevent global symbol clashes with these classes */
40
class TryFetchAndSendIterate
41
: public unary_function<plugin::QueryCache *, bool>
44
bool is_transactional;
46
TryFetchAndSendIterate(Session *session_arg, bool is_transactional_arg) :
47
unary_function<plugin::QueryCache *, bool>(),
48
session(session_arg), is_transactional(is_transactional_arg) { }
50
inline result_type operator()(argument_type handler)
52
if (handler->tryFetchAndSend(session, is_transactional))
54
errmsg_printf(ERRMSG_LVL_ERROR,
55
_("qcache plugin '%s' try_fetch_and_send() failed"),
56
handler->getName().c_str());
64
: public unary_function<plugin::QueryCache *, bool>
67
bool is_transactional;
69
SetIterate(Session *session_arg, bool is_transactional_arg) :
70
unary_function<plugin::QueryCache *, bool>(),
71
session(session_arg), is_transactional(is_transactional_arg) { }
73
inline result_type operator()(argument_type handler)
76
if (handler->set(session, is_transactional))
78
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' set() failed"),
79
handler->getName().c_str());
86
class InvalidateTableIterate
87
: public unary_function<plugin::QueryCache *, bool>
90
bool is_transactional;
92
InvalidateTableIterate(Session *session_arg, bool is_transactional_arg) :
93
unary_function<plugin::QueryCache *, bool>(),
94
session(session_arg), is_transactional(is_transactional_arg) { }
96
inline result_type operator()(argument_type handler)
99
if (handler->invalidateTable(session, is_transactional))
101
errmsg_printf(ERRMSG_LVL_ERROR,
102
_("qcache plugin '%s' invalidateTable() failed"),
103
handler->getName().c_str());
111
class InvalidateDbIterate
112
: public unary_function<plugin::QueryCache *, bool>
116
bool is_transactional;
118
InvalidateDbIterate(Session *session_arg, const char *dbname_arg,
119
bool is_transactional_arg) :
120
unary_function<plugin::QueryCache *, bool>(),
121
session(session_arg), dbname(dbname_arg),
122
is_transactional(is_transactional_arg) { }
124
inline result_type operator()(argument_type handler)
126
if (handler->invalidateDb(session, dbname, is_transactional))
128
errmsg_printf(ERRMSG_LVL_ERROR,
129
_("qcache plugin '%s' invalidateDb() failed"),
130
handler->getName().c_str());
138
: public unary_function<plugin::QueryCache *, bool>
142
FlushIterate(Session *session_arg) :
42
: public unary_function<plugin::QueryCache *, bool>
46
IsCachedIterate(Session* session_arg) :
47
unary_function<plugin::QueryCache *, bool>(),
48
session(session_arg) { }
50
inline result_type operator()(argument_type handler)
52
return handler->doIsCached(session);
56
bool plugin::QueryCache::isCached(Session *session)
58
/* Use find_if instead of foreach so that we can collect return codes */
59
QueryCaches::iterator iter=
60
find_if(all_query_cache.begin(), all_query_cache.end(),
61
IsCachedIterate(session));
62
/* If iter is == end() here, that means that all of the plugins returned
63
* false, which in this case means they all succeeded. Since we want to
64
* return false on success, we return the value of the two being !=
66
return iter != all_query_cache.end();
70
class SendCachedResultsetIterate
71
: public unary_function<plugin::QueryCache *, bool>
75
SendCachedResultsetIterate(Session *session_arg) :
76
unary_function<plugin::QueryCache *, bool>(),
77
session(session_arg) { }
79
inline result_type operator()(argument_type handler)
81
return handler->doSendCachedResultset(session);
84
bool plugin::QueryCache::sendCachedResultset(Session *session)
86
/* Use find_if instead of foreach so that we can collect return codes */
87
QueryCaches::iterator iter=
88
find_if(all_query_cache.begin(), all_query_cache.end(),
89
SendCachedResultsetIterate(session));
90
/* If iter is == end() here, that means that all of the plugins returned
91
* false, which in this case means they all succeeded. Since we want to
92
* return false on success, we return the value of the two being !=
94
return iter != all_query_cache.end();
97
class PrepareResultsetIterate
98
: public unary_function<plugin::QueryCache *, bool>
102
PrepareResultsetIterate(Session *session_arg) :
143
103
unary_function<plugin::QueryCache *, bool>(), session(session_arg) { }
145
105
inline result_type operator()(argument_type handler)
147
if (handler->flush(session))
149
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' flush() failed"),
150
handler->getName().c_str());
107
return handler->doPrepareResultset(session);
110
bool plugin::QueryCache::prepareResultset(Session *session)
112
/* Use find_if instead of foreach so that we can collect return codes */
113
QueryCaches::iterator iter=
114
find_if(all_query_cache.begin(), all_query_cache.end(),
115
PrepareResultsetIterate(session));
116
/* If iter is == end() here, that means that all of the plugins returned
117
* false, which in this case means they all succeeded. Since we want to
118
* return false on success, we return the value of the two being !=
120
return iter != all_query_cache.end();
123
class SetResultsetIterate
124
: public unary_function<plugin::QueryCache *, bool>
128
SetResultsetIterate(Session *session_arg) :
129
unary_function<plugin::QueryCache *, bool>(),
130
session(session_arg) { }
132
inline result_type operator()(argument_type handler)
134
return handler->doSetResultset(session);
138
bool plugin::QueryCache::setResultset(Session *session)
140
/* Use find_if instead of foreach so that we can collect return codes */
141
QueryCaches::iterator iter=
142
find_if(all_query_cache.begin(), all_query_cache.end(),
143
SetResultsetIterate(session));
144
/* If iter is == end() here, that means that all of the plugins returned
145
* false, which in this case means they all succeeded. Since we want to
146
* return false on success, we return the value of the two being !=
148
return iter != all_query_cache.end();
151
class InsertRecordIterate
152
: public unary_function<plugin::QueryCache *, bool>
157
InsertRecordIterate(Session *session_arg, List<Item> &item_arg) :
158
unary_function<plugin::QueryCache *, bool>(),
159
session(session_arg), item(item_arg) { }
161
inline result_type operator()(argument_type handler)
163
return handler->doInsertRecord(session, item);
166
bool plugin::QueryCache::insertRecord(Session *session, List<Item> &items)
168
/* Use find_if instead of foreach so that we can collect return codes */
169
QueryCaches::iterator iter=
170
find_if(all_query_cache.begin(), all_query_cache.end(),
171
InsertRecordIterate(session, items));
172
/* If iter is == end() here, that means that all of the plugins returned
173
* false, which in this case means they all succeeded. Since we want to
174
* return false on success, we return the value of the two being !=
176
return iter != all_query_cache.end();
157
181
bool plugin::QueryCache::addPlugin(plugin::QueryCache *handler)
170
bool plugin::QueryCache::tryFetchAndSendDo(Session *session,
173
/* Use find_if instead of foreach so that we can collect return codes */
174
vector<plugin::QueryCache *>::iterator iter=
175
find_if(all_query_cache.begin(), all_query_cache.end(),
176
TryFetchAndSendIterate(session, transactional));
177
/* If iter is == end() here, that means that all of the plugins returned
178
* false, which in this case means they all succeeded. Since we want to
179
* return false on success, we return the value of the two being !=
181
return iter != all_query_cache.end();
184
bool plugin::QueryCache::setDo(Session *session, bool transactional)
186
/* Use find_if instead of foreach so that we can collect return codes */
187
vector<plugin::QueryCache *>::iterator iter=
188
find_if(all_query_cache.begin(), all_query_cache.end(),
189
SetIterate(session, transactional));
190
/* If iter is == end() here, that means that all of the plugins returned
191
* false, which in this case means they all succeeded. Since we want to
192
* return false on success, we return the value of the two being !=
194
return iter != all_query_cache.end();
197
bool plugin::QueryCache::invalidateTableDo(Session *session,
200
/* Use find_if instead of foreach so that we can collect return codes */
201
vector<plugin::QueryCache *>::iterator iter=
202
find_if(all_query_cache.begin(), all_query_cache.end(),
203
InvalidateTableIterate(session, transactional));
204
/* If iter is == end() here, that means that all of the plugins returned
205
* false, which in this case means they all succeeded. Since we want to
206
* return false on success, we return the value of the two being !=
208
return iter != all_query_cache.end();
211
bool plugin::QueryCache::invalidateDbDo(Session *session, const char *dbname,
214
/* Use find_if instead of foreach so that we can collect return codes */
215
vector<plugin::QueryCache *>::iterator iter=
216
find_if(all_query_cache.begin(), all_query_cache.end(),
217
InvalidateDbIterate(session, dbname, transactional));
218
/* If iter is == end() here, that means that all of the plugins returned
219
* false, which in this case means they all succeeded. Since we want to
220
* return false on success, we return the value of the two being !=
222
return iter != all_query_cache.end();
225
bool plugin::QueryCache::flushDo(Session *session)
227
/* Use find_if instead of foreach so that we can collect return codes */
228
vector<plugin::QueryCache *>::iterator iter=
229
find_if(all_query_cache.begin(), all_query_cache.end(),
230
FlushIterate(session));
231
/* If iter is == end() here, that means that all of the plugins returned
232
* false, which in this case means they all succeeded. Since we want to
233
* return false on success, we return the value of the two being !=
235
return iter != all_query_cache.end();
238
193
} /* namespace drizzled */