35
vector<plugin::QueryCache *> all_query_cache;
36
typedef vector<plugin::QueryCache *> QueryCaches;
37
QueryCaches all_query_cache;
37
39
/* Namespaces are here to prevent global symbol clashes with these classes */
39
class TryFetchAndSendIterate
40
: public unary_function<plugin::QueryCache *, bool>
43
bool is_transactional;
45
TryFetchAndSendIterate(Session *session_arg, bool is_transactional_arg) :
46
unary_function<plugin::QueryCache *, bool>(),
47
session(session_arg), is_transactional(is_transactional_arg) { }
49
inline result_type operator()(argument_type handler)
51
if (handler->tryFetchAndSend(session, is_transactional))
53
errmsg_printf(ERRMSG_LVL_ERROR,
54
_("qcache plugin '%s' try_fetch_and_send() failed"),
55
handler->getName().c_str());
63
: public unary_function<plugin::QueryCache *, bool>
66
bool is_transactional;
68
SetIterate(Session *session_arg, bool is_transactional_arg) :
69
unary_function<plugin::QueryCache *, bool>(),
70
session(session_arg), is_transactional(is_transactional_arg) { }
72
inline result_type operator()(argument_type handler)
75
if (handler->set(session, is_transactional))
77
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' set() failed"),
78
handler->getName().c_str());
85
class InvalidateTableIterate
86
: public unary_function<plugin::QueryCache *, bool>
89
bool is_transactional;
91
InvalidateTableIterate(Session *session_arg, bool is_transactional_arg) :
92
unary_function<plugin::QueryCache *, bool>(),
93
session(session_arg), is_transactional(is_transactional_arg) { }
95
inline result_type operator()(argument_type handler)
98
if (handler->invalidateTable(session, is_transactional))
100
errmsg_printf(ERRMSG_LVL_ERROR,
101
_("qcache plugin '%s' invalidateTable() failed"),
102
handler->getName().c_str());
110
class InvalidateDbIterate
111
: public unary_function<plugin::QueryCache *, bool>
115
bool is_transactional;
117
InvalidateDbIterate(Session *session_arg, const char *dbname_arg,
118
bool is_transactional_arg) :
119
unary_function<plugin::QueryCache *, bool>(),
120
session(session_arg), dbname(dbname_arg),
121
is_transactional(is_transactional_arg) { }
123
inline result_type operator()(argument_type handler)
125
if (handler->invalidateDb(session, dbname, is_transactional))
127
errmsg_printf(ERRMSG_LVL_ERROR,
128
_("qcache plugin '%s' invalidateDb() failed"),
129
handler->getName().c_str());
137
: public unary_function<plugin::QueryCache *, bool>
141
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) :
142
103
unary_function<plugin::QueryCache *, bool>(), session(session_arg) { }
144
105
inline result_type operator()(argument_type handler)
146
if (handler->flush(session))
148
errmsg_printf(ERRMSG_LVL_ERROR, _("qcache plugin '%s' flush() failed"),
149
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();
156
181
bool plugin::QueryCache::addPlugin(plugin::QueryCache *handler)
169
bool plugin::QueryCache::tryFetchAndSendDo(Session *session,
172
/* Use find_if instead of foreach so that we can collect return codes */
173
vector<plugin::QueryCache *>::iterator iter=
174
find_if(all_query_cache.begin(), all_query_cache.end(),
175
TryFetchAndSendIterate(session, transactional));
176
/* If iter is == end() here, that means that all of the plugins returned
177
* false, which in this case means they all succeeded. Since we want to
178
* return false on success, we return the value of the two being !=
180
return iter != all_query_cache.end();
183
bool plugin::QueryCache::setDo(Session *session, bool transactional)
185
/* Use find_if instead of foreach so that we can collect return codes */
186
vector<plugin::QueryCache *>::iterator iter=
187
find_if(all_query_cache.begin(), all_query_cache.end(),
188
SetIterate(session, transactional));
189
/* If iter is == end() here, that means that all of the plugins returned
190
* false, which in this case means they all succeeded. Since we want to
191
* return false on success, we return the value of the two being !=
193
return iter != all_query_cache.end();
196
bool plugin::QueryCache::invalidateTableDo(Session *session,
199
/* Use find_if instead of foreach so that we can collect return codes */
200
vector<plugin::QueryCache *>::iterator iter=
201
find_if(all_query_cache.begin(), all_query_cache.end(),
202
InvalidateTableIterate(session, transactional));
203
/* If iter is == end() here, that means that all of the plugins returned
204
* false, which in this case means they all succeeded. Since we want to
205
* return false on success, we return the value of the two being !=
207
return iter != all_query_cache.end();
210
bool plugin::QueryCache::invalidateDbDo(Session *session, const char *dbname,
213
/* Use find_if instead of foreach so that we can collect return codes */
214
vector<plugin::QueryCache *>::iterator iter=
215
find_if(all_query_cache.begin(), all_query_cache.end(),
216
InvalidateDbIterate(session, dbname, transactional));
217
/* If iter is == end() here, that means that all of the plugins returned
218
* false, which in this case means they all succeeded. Since we want to
219
* return false on success, we return the value of the two being !=
221
return iter != all_query_cache.end();
224
bool plugin::QueryCache::flushDo(Session *session)
226
/* Use find_if instead of foreach so that we can collect return codes */
227
vector<plugin::QueryCache *>::iterator iter=
228
find_if(all_query_cache.begin(), all_query_cache.end(),
229
FlushIterate(session));
230
/* If iter is == end() here, that means that all of the plugins returned
231
* false, which in this case means they all succeeded. Since we want to
232
* return false on success, we return the value of the two being !=
234
return iter != all_query_cache.end();
237
193
} /* namespace drizzled */