17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
21
#include <drizzled/qcache.h>
22
#include <drizzled/gettext.h>
20
#include "drizzled/server_includes.h"
21
#include "drizzled/slot/query_cache.h"
22
#include "drizzled/plugin/query_cache.h"
23
23
#include "drizzled/plugin/registry.h"
25
#include "drizzled/gettext.h"
29
using namespace drizzled;
26
30
using namespace std;
28
static vector<QueryCache *> all_query_cache;
30
void add_query_cache(QueryCache *handler)
32
all_query_cache.push_back(handler);
35
void remove_query_cache(QueryCache *handler)
37
all_query_cache.erase(find(all_query_cache.begin(), all_query_cache.end(),
41
namespace query_cache_priv
43
44
/* Namespaces are here to prevent global symbol clashes with these classes */
46
namespace query_cache {
48
46
class TryFetchAndSendIterate
49
: public unary_function<QueryCache *, bool>
47
: public unary_function<plugin::QueryCache *, bool>
52
50
bool is_transactional;
54
52
TryFetchAndSendIterate(Session *session_arg, bool is_transactional_arg) :
55
unary_function<QueryCache *, bool>(),
53
unary_function<plugin::QueryCache *, bool>(),
56
54
session(session_arg), is_transactional(is_transactional_arg) { }
58
56
inline result_type operator()(argument_type handler)
175
189
rest of the Drizzle server code.
178
bool try_fetch_and_send(Session *session, bool transactional)
180
/* Use find_if instead of foreach so that we can collect return codes */
181
vector<QueryCache *>::iterator iter=
182
find_if(all_query_cache.begin(), all_query_cache.end(),
183
TryFetchAndSendIterate(session, transactional));
184
/* If iter is == end() here, that means that all of the plugins returned
185
* false, which in this case means they all succeeded. Since we want to
186
* return false on success, we return the value of the two being !=
188
return iter != all_query_cache.end();
191
bool set(Session *session, bool transactional)
193
/* Use find_if instead of foreach so that we can collect return codes */
194
vector<QueryCache *>::iterator iter=
195
find_if(all_query_cache.begin(), all_query_cache.end(),
196
SetIterate(session, transactional));
197
/* If iter is == end() here, that means that all of the plugins returned
198
* false, which in this case means they all succeeded. Since we want to
199
* return false on success, we return the value of the two being !=
201
return iter != all_query_cache.end();
204
bool invalidate_table(Session *session, bool transactional)
206
/* Use find_if instead of foreach so that we can collect return codes */
207
vector<QueryCache *>::iterator iter=
208
find_if(all_query_cache.begin(), all_query_cache.end(),
209
InvalidateTableIterate(session, transactional));
210
/* If iter is == end() here, that means that all of the plugins returned
211
* false, which in this case means they all succeeded. Since we want to
212
* return false on success, we return the value of the two being !=
214
return iter != all_query_cache.end();
217
bool invalidate_db(Session *session, const char *dbname,
220
/* Use find_if instead of foreach so that we can collect return codes */
221
vector<QueryCache *>::iterator iter=
222
find_if(all_query_cache.begin(), all_query_cache.end(),
223
InvalidateDbIterate(session, dbname, transactional));
224
/* If iter is == end() here, that means that all of the plugins returned
225
* false, which in this case means they all succeeded. Since we want to
226
* return false on success, we return the value of the two being !=
228
return iter != all_query_cache.end();
231
bool flush(Session *session)
233
/* Use find_if instead of foreach so that we can collect return codes */
234
vector<QueryCache *>::iterator iter=
235
find_if(all_query_cache.begin(), all_query_cache.end(),
236
FlushIterate(session));
237
/* If iter is == end() here, that means that all of the plugins returned
238
* false, which in this case means they all succeeded. Since we want to
239
* return false on success, we return the value of the two being !=
241
return iter != all_query_cache.end();
244
} /* namespace query_cache */
245
} /* namespace drizzled */
192
bool slot::QueryCache::try_fetch_and_send(Session *session, bool transactional)
194
/* Use find_if instead of foreach so that we can collect return codes */
195
vector<plugin::QueryCache *>::iterator iter=
196
find_if(all_query_cache.begin(), all_query_cache.end(),
197
slot::query_cache_priv::TryFetchAndSendIterate(session,
199
/* If iter is == end() here, that means that all of the plugins returned
200
* false, which in this case means they all succeeded. Since we want to
201
* return false on success, we return the value of the two being !=
203
return iter != all_query_cache.end();
206
bool slot::QueryCache::set(Session *session, bool transactional)
208
/* Use find_if instead of foreach so that we can collect return codes */
209
vector<plugin::QueryCache *>::iterator iter=
210
find_if(all_query_cache.begin(), all_query_cache.end(),
211
slot::query_cache_priv::SetIterate(session, transactional));
212
/* If iter is == end() here, that means that all of the plugins returned
213
* false, which in this case means they all succeeded. Since we want to
214
* return false on success, we return the value of the two being !=
216
return iter != all_query_cache.end();
219
bool slot::QueryCache::invalidate_table(Session *session, bool transactional)
221
/* Use find_if instead of foreach so that we can collect return codes */
222
vector<plugin::QueryCache *>::iterator iter=
223
find_if(all_query_cache.begin(), all_query_cache.end(),
224
slot::query_cache_priv::InvalidateTableIterate(session,
226
/* If iter is == end() here, that means that all of the plugins returned
227
* false, which in this case means they all succeeded. Since we want to
228
* return false on success, we return the value of the two being !=
230
return iter != all_query_cache.end();
233
bool slot::QueryCache::invalidate_db(Session *session, const char *dbname,
236
/* Use find_if instead of foreach so that we can collect return codes */
237
vector<plugin::QueryCache *>::iterator iter=
238
find_if(all_query_cache.begin(), all_query_cache.end(),
239
slot::query_cache_priv::InvalidateDbIterate(session,
242
/* If iter is == end() here, that means that all of the plugins returned
243
* false, which in this case means they all succeeded. Since we want to
244
* return false on success, we return the value of the two being !=
246
return iter != all_query_cache.end();
249
bool slot::QueryCache::flush(Session *session)
251
/* Use find_if instead of foreach so that we can collect return codes */
252
vector<plugin::QueryCache *>::iterator iter=
253
find_if(all_query_cache.begin(), all_query_cache.end(),
254
slot::query_cache_priv::FlushIterate(session));
255
/* If iter is == end() here, that means that all of the plugins returned
256
* false, which in this case means they all succeeded. Since we want to
257
* return false on success, we return the value of the two being !=
259
return iter != all_query_cache.end();